Commit | Line | Data |
4633a7c4 |
1 | #include <signal.h> |
2 | |
3 | /* HAS_IOCTL: |
4 | * This symbol, if defined, indicates that the ioctl() routine is |
5 | * available to set I/O characteristics |
6 | */ |
7 | #define HAS_IOCTL /**/ |
8 | |
9 | /* HAS_UTIME: |
10 | * This symbol, if defined, indicates that the routine utime() is |
11 | * available to update the access and modification times of files. |
12 | */ |
13 | #define HAS_UTIME /**/ |
14 | |
15 | #define HAS_KILL |
16 | #define HAS_WAIT |
4ea6d94f |
17 | #define HAS_DLERROR |
18 | |
19 | /* USEMYBINMODE |
20 | * This symbol, if defined, indicates that the program should |
21 | * use the routine my_binmode(FILE *fp, char iotype) to insure |
22 | * that a file is in "binary" mode -- that is, that no translation |
23 | * of bytes occurs on read or write operations. |
24 | */ |
25 | #undef USEMYBINMODE |
26 | |
27 | /* USE_STAT_RDEV: |
28 | * This symbol is defined if this system has a stat structure declaring |
29 | * st_rdev |
30 | */ |
31 | #define USE_STAT_RDEV /**/ |
32 | |
33 | /* ACME_MESS: |
34 | * This symbol, if defined, indicates that error messages should be |
35 | * should be generated in a format that allows the use of the Acme |
36 | * GUI/editor's autofind feature. |
37 | */ |
38 | #undef ACME_MESS /**/ |
4633a7c4 |
39 | |
40 | #ifndef SIGABRT |
41 | # define SIGABRT SIGILL |
42 | #endif |
43 | #ifndef SIGILL |
44 | # define SIGILL 6 /* blech */ |
45 | #endif |
46 | #define ABORT() kill(getpid(),SIGABRT); |
47 | |
c07a80fd |
48 | #define BIT_BUCKET "/dev/null" /* Will this work? */ |
49 | |
365eb7b5 |
50 | void Perl_OS2_init(); |
51 | |
52 | #define PERL_SYS_INIT(argcp, argvp) STMT_START { \ |
eacfb5f1 |
53 | _response(argcp, argvp); \ |
c0c09dfd |
54 | _wildcard(argcp, argvp); \ |
365eb7b5 |
55 | Perl_OS2_init(); } STMT_END |
56 | |
57 | #define PERL_SYS_TERM() |
58 | |
4ea6d94f |
59 | /* #define PERL_SYS_TERM() STMT_START { \ |
60 | if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */ |
61 | |
365eb7b5 |
62 | #define dXSUB_SYS int fake = OS2_XS_init() |
eacfb5f1 |
63 | |
4ea6d94f |
64 | #ifdef PERL_IS_AOUT |
65 | #define NO_SYS_ALLOC |
66 | #endif |
67 | |
c0c09dfd |
68 | #define TMPPATH tmppath |
69 | #define TMPPATH1 "plXXXXXX" |
70 | extern char *tmppath; |
eacfb5f1 |
71 | |
4633a7c4 |
72 | /* |
73 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
74 | * but which outputs all of the bytes requested as a single stream (unlike |
75 | * fwrite() itself, which on some systems outputs several distinct records |
76 | * if the number_of_items parameter is >1). |
77 | */ |
78 | #define fwrite1 fwrite |
79 | |
80 | #define my_getenv(var) getenv(var) |
81 | |
82 | /*****************************************************************************/ |
83 | |
84 | #include <stdlib.h> /* before the following definitions */ |
85 | #include <unistd.h> /* before the following definitions */ |
86 | |
87 | #define chdir _chdir2 |
88 | #define getcwd _getcwd2 |
89 | |
90 | /* This guy is needed for quick stdstd */ |
91 | |
92 | #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE) |
93 | # define _filbuf _fill |
94 | /* Perl uses ungetc only with successful return */ |
95 | # define ungetc(c,fp) \ |
96 | (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \ |
97 | ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp)) |
98 | #endif |
99 | |
100 | #define OP_BINARY O_BINARY |
101 | |
102 | #define OS2_STAT_HACK 1 |
103 | #if OS2_STAT_HACK |
104 | |
105 | #define Stat(fname,bufptr) os2_stat((fname),(bufptr)) |
106 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
107 | #define Fflush(fp) fflush(fp) |
4633a7c4 |
108 | |
109 | #undef S_IFBLK |
110 | #undef S_ISBLK |
111 | #define S_IFBLK 0120000 |
112 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) |
113 | |
114 | #else |
115 | |
116 | #define Stat(fname,bufptr) stat((fname),(bufptr)) |
117 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
118 | #define Fflush(fp) fflush(fp) |
4633a7c4 |
119 | |
120 | #endif |
365eb7b5 |
121 | |
122 | /* Our private OS/2 specific data. */ |
123 | |
124 | typedef struct OS2_Perl_data { |
125 | unsigned long flags; |
126 | unsigned long phab; |
127 | int (*xs_init)(); |
4ea6d94f |
128 | unsigned long rc; |
129 | unsigned long severity; |
365eb7b5 |
130 | } OS2_Perl_data_t; |
131 | |
132 | extern OS2_Perl_data_t OS2_Perl_data; |
133 | |
4ea6d94f |
134 | #define Perl_hab ((HAB)OS2_Perl_data.phab) |
135 | #define Perl_rc (OS2_Perl_data.rc) |
136 | #define Perl_severity (OS2_Perl_data.severity) |
137 | #define errno_isOS2 12345678 |
138 | #define OS2_Perl_flags (OS2_Perl_data.flags) |
365eb7b5 |
139 | #define Perl_HAB_set_f 1 |
4ea6d94f |
140 | #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f) |
141 | #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f) |
142 | #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h) |
365eb7b5 |
143 | #define OS2_XS_init() (*OS2_Perl_data.xs_init)() |
4ea6d94f |
144 | /* The expressions below return true on error. */ |
145 | /* INCL_DOSERRORS needed. */ |
146 | #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1)) |
147 | /* INCL_WINERRORS needed. */ |
148 | #define SaveWinError(expr) ((expr) ? : (FillWinError, 0)) |
149 | #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1)) |
150 | #define FillOSError(rc) (Perl_rc = rc, \ |
151 | errno = errno_isOS2, \ |
152 | Perl_severity = SEVERITY_ERROR) |
153 | #define FillWinError (Perl_rc = WinGetLastError(Perl_hab), \ |
154 | errno = errno_isOS2, \ |
155 | Perl_severity = ERRORIDSEV(Perl_rc), \ |
156 | Perl_rc = ERRORIDERROR(Perl_rc)) |
157 | #define Acquire_hab() if (!Perl_HAB_set) { \ |
158 | Perl_hab = WinInitialize(0); \ |
159 | if (!Perl_hab) die("WinInitialize failed"); \ |
160 | set_Perl_HAB_f; \ |
161 | } |
162 | |
163 | extern char sh_path[33]; |
164 | #define SH_PATH sh_path |
165 | |
166 | char *os2error(int rc); |
167 | |
168 | /* ************************************************************ */ |
169 | #define Dos32QuerySysState DosQuerySysState |
170 | #define QuerySysState(flags, pid, buf, bufsz) \ |
171 | Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz) |
172 | |
173 | #define QSS_PROCESS 1 |
174 | #define QSS_MODULE 2 |
175 | #define QSS_SEMAPHORES 4 |
176 | #define QSS_FILE 8 /* Buggy until fixpack18 */ |
177 | #define QSS_SHARED 16 |
178 | |
179 | #ifdef _OS2EMX_H |
180 | |
181 | APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid, |
182 | ULONG _res_,PVOID buf,ULONG bufsz); |
183 | typedef struct { |
184 | ULONG threadcnt; |
185 | ULONG proccnt; |
186 | ULONG modulecnt; |
187 | } QGLOBAL, *PQGLOBAL; |
188 | |
189 | typedef struct { |
190 | ULONG rectype; |
191 | USHORT threadid; |
192 | USHORT slotid; |
193 | ULONG sleepid; |
194 | ULONG priority; |
195 | ULONG systime; |
196 | ULONG usertime; |
197 | UCHAR state; |
198 | UCHAR _reserved1_; /* padding to ULONG */ |
199 | USHORT _reserved2_; /* padding to ULONG */ |
200 | } QTHREAD, *PQTHREAD; |
201 | |
202 | typedef struct { |
203 | USHORT sfn; |
204 | USHORT refcnt; |
205 | USHORT flags1; |
206 | USHORT flags2; |
207 | USHORT accmode1; |
208 | USHORT accmode2; |
209 | ULONG filesize; |
210 | USHORT volhnd; |
211 | USHORT attrib; |
212 | USHORT _reserved_; |
213 | } QFDS, *PQFDS; |
214 | |
215 | typedef struct qfile { |
216 | ULONG rectype; |
217 | struct qfile *next; |
218 | ULONG opencnt; |
219 | PQFDS filedata; |
220 | char name[1]; |
221 | } QFILE, *PQFILE; |
222 | |
223 | typedef struct { |
224 | ULONG rectype; |
225 | PQTHREAD threads; |
226 | USHORT pid; |
227 | USHORT ppid; |
228 | ULONG type; |
229 | ULONG state; |
230 | ULONG sessid; |
231 | USHORT hndmod; |
232 | USHORT threadcnt; |
233 | ULONG privsem32cnt; |
234 | ULONG _reserved2_; |
235 | USHORT sem16cnt; |
236 | USHORT dllcnt; |
237 | USHORT shrmemcnt; |
238 | USHORT fdscnt; |
239 | PUSHORT sem16s; |
240 | PUSHORT dlls; |
241 | PUSHORT shrmems; |
242 | PUSHORT fds; |
243 | } QPROCESS, *PQPROCESS; |
244 | |
245 | typedef struct sema { |
246 | struct sema *next; |
247 | USHORT refcnt; |
248 | UCHAR sysflags; |
249 | UCHAR sysproccnt; |
250 | ULONG _reserved1_; |
251 | USHORT index; |
252 | CHAR name[1]; |
253 | } QSEMA, *PQSEMA; |
254 | |
255 | typedef struct { |
256 | ULONG rectype; |
257 | ULONG _reserved1_; |
258 | USHORT _reserved2_; |
259 | USHORT syssemidx; |
260 | ULONG index; |
261 | QSEMA sema; |
262 | } QSEMSTRUC, *PQSEMSTRUC; |
263 | |
264 | typedef struct { |
265 | USHORT pid; |
266 | USHORT opencnt; |
267 | } QSEMOWNER32, *PQSEMOWNER32; |
268 | |
269 | typedef struct { |
270 | PQSEMOWNER32 own; |
271 | PCHAR name; |
272 | PVOID semrecs; /* array of associated sema's */ |
273 | USHORT flags; |
274 | USHORT semreccnt; |
275 | USHORT waitcnt; |
276 | USHORT _reserved_; /* padding to ULONG */ |
277 | } QSEMSMUX32, *PQSEMSMUX32; |
278 | |
279 | typedef struct { |
280 | PQSEMOWNER32 own; |
281 | PCHAR name; |
282 | PQSEMSMUX32 mux; |
283 | USHORT flags; |
284 | USHORT postcnt; |
285 | } QSEMEV32, *PQSEMEV32; |
286 | |
287 | typedef struct { |
288 | PQSEMOWNER32 own; |
289 | PCHAR name; |
290 | PQSEMSMUX32 mux; |
291 | USHORT flags; |
292 | USHORT refcnt; |
293 | USHORT thrdnum; |
294 | USHORT _reserved_; /* padding to ULONG */ |
295 | } QSEMMUX32, *PQSEMMUX32; |
296 | |
297 | typedef struct semstr32 { |
298 | struct semstr *next; |
299 | QSEMEV32 evsem; |
300 | QSEMMUX32 muxsem; |
301 | QSEMSMUX32 smuxsem; |
302 | } QSEMSTRUC32, *PQSEMSTRUC32; |
303 | |
304 | typedef struct shrmem { |
305 | struct shrmem *next; |
306 | USHORT hndshr; |
307 | USHORT selshr; |
308 | USHORT refcnt; |
309 | CHAR name[1]; |
310 | } QSHRMEM, *PQSHRMEM; |
311 | |
312 | typedef struct module { |
313 | struct module *next; |
314 | USHORT hndmod; |
315 | USHORT type; |
316 | ULONG refcnt; |
317 | ULONG segcnt; |
318 | PVOID _reserved_; |
319 | PCHAR name; |
320 | USHORT modref[1]; |
321 | } QMODULE, *PQMODULE; |
322 | |
323 | typedef struct { |
324 | PQGLOBAL gbldata; |
325 | PQPROCESS procdata; |
326 | PQSEMSTRUC semadata; |
327 | PQSEMSTRUC32 sem32data; |
328 | PQSHRMEM shrmemdata; |
329 | PQMODULE moddata; |
330 | PVOID _reserved2_; |
331 | PQFILE filedata; |
332 | } QTOPLEVEL, *PQTOPLEVEL; |
333 | /* ************************************************************ */ |
334 | |
335 | PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags); |
336 | |
337 | #endif /* _OS2EMX_H */ |