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 | |
44a8e56a |
40 | /* ALTERNATE_SHEBANG: |
41 | * This symbol, if defined, contains a "magic" string which may be used |
42 | * as the first line of a Perl program designed to be executed directly |
43 | * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG |
44 | * begins with a character other then #, then Perl will only treat |
45 | * it as a command line if if finds the string "perl" in the first |
46 | * word; otherwise it's treated as the first line of code in the script. |
47 | * (IOW, Perl won't hand off to another interpreter via an alternate |
48 | * shebang sequence that might be legal Perl code.) |
49 | */ |
50 | /* #define ALTERNATE_SHEBANG "#!" / **/ |
51 | |
4633a7c4 |
52 | #ifndef SIGABRT |
53 | # define SIGABRT SIGILL |
54 | #endif |
55 | #ifndef SIGILL |
56 | # define SIGILL 6 /* blech */ |
57 | #endif |
58 | #define ABORT() kill(getpid(),SIGABRT); |
59 | |
760ac839 |
60 | #define BIT_BUCKET "/dev/nul" /* Will this work? */ |
c07a80fd |
61 | |
4a6a15c8 |
62 | #if defined(I_SYS_UN) && !defined(TCPIPV4) |
63 | /* It is not working without TCPIPV4 defined. */ |
64 | # undef I_SYS_UN |
65 | #endif |
66 | |
365eb7b5 |
67 | void Perl_OS2_init(); |
68 | |
69 | #define PERL_SYS_INIT(argcp, argvp) STMT_START { \ |
eacfb5f1 |
70 | _response(argcp, argvp); \ |
c0c09dfd |
71 | _wildcard(argcp, argvp); \ |
365eb7b5 |
72 | Perl_OS2_init(); } STMT_END |
73 | |
74 | #define PERL_SYS_TERM() |
75 | |
4ea6d94f |
76 | /* #define PERL_SYS_TERM() STMT_START { \ |
77 | if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */ |
78 | |
365eb7b5 |
79 | #define dXSUB_SYS int fake = OS2_XS_init() |
eacfb5f1 |
80 | |
4ea6d94f |
81 | #ifdef PERL_IS_AOUT |
4a6a15c8 |
82 | /* # define HAS_FORK */ |
760ac839 |
83 | /* # define HIDEMYMALLOC */ |
84 | /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */ |
85 | #else /* !PERL_IS_AOUT */ |
86 | # ifndef PERL_FOR_X2P |
4a6a15c8 |
87 | # ifdef EMX_BAD_SBRK |
88 | # define USE_PERL_SBRK |
89 | # endif |
90 | # else |
91 | # define PerlIO FILE |
760ac839 |
92 | # endif |
93 | # define SYSTEM_ALLOC(a) sys_alloc(a) |
94 | |
95 | void *sys_alloc(int size); |
96 | |
97 | #endif /* !PERL_IS_AOUT */ |
4a6a15c8 |
98 | #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */ |
99 | # define PerlIO FILE |
100 | #endif |
4ea6d94f |
101 | |
c0c09dfd |
102 | #define TMPPATH tmppath |
103 | #define TMPPATH1 "plXXXXXX" |
104 | extern char *tmppath; |
4a6a15c8 |
105 | PerlIO *my_syspopen(char *cmd, char *mode); |
106 | /* Cannot prototype with I32 at this point. */ |
107 | int my_syspclose(PerlIO *f); |
55497cff |
108 | FILE *my_tmpfile (void); |
109 | char *my_tmpnam (char *); |
110 | |
111 | #define tmpfile my_tmpfile |
112 | #define tmpnam my_tmpnam |
3ed26a2c |
113 | #define isatty _isterm |
44a8e56a |
114 | #define rand random |
115 | #define srand srandom |
eacfb5f1 |
116 | |
4633a7c4 |
117 | /* |
118 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
119 | * but which outputs all of the bytes requested as a single stream (unlike |
120 | * fwrite() itself, which on some systems outputs several distinct records |
121 | * if the number_of_items parameter is >1). |
122 | */ |
123 | #define fwrite1 fwrite |
124 | |
125 | #define my_getenv(var) getenv(var) |
126 | |
df3ef7a9 |
127 | void *emx_calloc (size_t, size_t); |
128 | void emx_free (void *); |
129 | void *emx_malloc (size_t); |
130 | void *emx_realloc (void *, size_t); |
131 | |
4633a7c4 |
132 | /*****************************************************************************/ |
133 | |
134 | #include <stdlib.h> /* before the following definitions */ |
135 | #include <unistd.h> /* before the following definitions */ |
136 | |
137 | #define chdir _chdir2 |
138 | #define getcwd _getcwd2 |
139 | |
140 | /* This guy is needed for quick stdstd */ |
141 | |
142 | #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE) |
143 | # define _filbuf _fill |
144 | /* Perl uses ungetc only with successful return */ |
145 | # define ungetc(c,fp) \ |
146 | (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \ |
147 | ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp)) |
148 | #endif |
149 | |
150 | #define OP_BINARY O_BINARY |
151 | |
152 | #define OS2_STAT_HACK 1 |
153 | #if OS2_STAT_HACK |
154 | |
155 | #define Stat(fname,bufptr) os2_stat((fname),(bufptr)) |
156 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
157 | #define Fflush(fp) fflush(fp) |
4633a7c4 |
158 | |
159 | #undef S_IFBLK |
160 | #undef S_ISBLK |
161 | #define S_IFBLK 0120000 |
162 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) |
163 | |
164 | #else |
165 | |
166 | #define Stat(fname,bufptr) stat((fname),(bufptr)) |
167 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
168 | #define Fflush(fp) fflush(fp) |
4633a7c4 |
169 | |
170 | #endif |
365eb7b5 |
171 | |
44a8e56a |
172 | /* With SD386 it is impossible to debug register variables. */ |
173 | #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register) |
174 | # define register |
175 | #endif |
176 | |
365eb7b5 |
177 | /* Our private OS/2 specific data. */ |
178 | |
179 | typedef struct OS2_Perl_data { |
180 | unsigned long flags; |
181 | unsigned long phab; |
182 | int (*xs_init)(); |
4ea6d94f |
183 | unsigned long rc; |
184 | unsigned long severity; |
365eb7b5 |
185 | } OS2_Perl_data_t; |
186 | |
187 | extern OS2_Perl_data_t OS2_Perl_data; |
188 | |
4ea6d94f |
189 | #define Perl_hab ((HAB)OS2_Perl_data.phab) |
190 | #define Perl_rc (OS2_Perl_data.rc) |
191 | #define Perl_severity (OS2_Perl_data.severity) |
192 | #define errno_isOS2 12345678 |
193 | #define OS2_Perl_flags (OS2_Perl_data.flags) |
365eb7b5 |
194 | #define Perl_HAB_set_f 1 |
4ea6d94f |
195 | #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f) |
196 | #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f) |
197 | #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h) |
365eb7b5 |
198 | #define OS2_XS_init() (*OS2_Perl_data.xs_init)() |
4ea6d94f |
199 | /* The expressions below return true on error. */ |
4a6a15c8 |
200 | /* INCL_DOSERRORS needed. rc should be declared outside. */ |
4ea6d94f |
201 | #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1)) |
202 | /* INCL_WINERRORS needed. */ |
203 | #define SaveWinError(expr) ((expr) ? : (FillWinError, 0)) |
204 | #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1)) |
205 | #define FillOSError(rc) (Perl_rc = rc, \ |
206 | errno = errno_isOS2, \ |
207 | Perl_severity = SEVERITY_ERROR) |
208 | #define FillWinError (Perl_rc = WinGetLastError(Perl_hab), \ |
209 | errno = errno_isOS2, \ |
210 | Perl_severity = ERRORIDSEV(Perl_rc), \ |
211 | Perl_rc = ERRORIDERROR(Perl_rc)) |
212 | #define Acquire_hab() if (!Perl_HAB_set) { \ |
213 | Perl_hab = WinInitialize(0); \ |
214 | if (!Perl_hab) die("WinInitialize failed"); \ |
215 | set_Perl_HAB_f; \ |
216 | } |
217 | |
760ac839 |
218 | #define STATIC_FILE_LENGTH 127 |
ff68c719 |
219 | |
760ac839 |
220 | #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n)) |
221 | char *perllib_mangle(char *, unsigned int); |
4ea6d94f |
222 | |
223 | char *os2error(int rc); |
224 | |
225 | /* ************************************************************ */ |
226 | #define Dos32QuerySysState DosQuerySysState |
227 | #define QuerySysState(flags, pid, buf, bufsz) \ |
228 | Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz) |
229 | |
230 | #define QSS_PROCESS 1 |
df3ef7a9 |
231 | #define QSS_MODULE 4 |
232 | #define QSS_SEMAPHORES 2 |
4ea6d94f |
233 | #define QSS_FILE 8 /* Buggy until fixpack18 */ |
234 | #define QSS_SHARED 16 |
235 | |
236 | #ifdef _OS2EMX_H |
237 | |
238 | APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid, |
239 | ULONG _res_,PVOID buf,ULONG bufsz); |
240 | typedef struct { |
241 | ULONG threadcnt; |
242 | ULONG proccnt; |
243 | ULONG modulecnt; |
244 | } QGLOBAL, *PQGLOBAL; |
245 | |
246 | typedef struct { |
247 | ULONG rectype; |
248 | USHORT threadid; |
249 | USHORT slotid; |
250 | ULONG sleepid; |
251 | ULONG priority; |
252 | ULONG systime; |
253 | ULONG usertime; |
254 | UCHAR state; |
255 | UCHAR _reserved1_; /* padding to ULONG */ |
256 | USHORT _reserved2_; /* padding to ULONG */ |
257 | } QTHREAD, *PQTHREAD; |
258 | |
259 | typedef struct { |
260 | USHORT sfn; |
261 | USHORT refcnt; |
262 | USHORT flags1; |
263 | USHORT flags2; |
264 | USHORT accmode1; |
265 | USHORT accmode2; |
266 | ULONG filesize; |
267 | USHORT volhnd; |
268 | USHORT attrib; |
269 | USHORT _reserved_; |
270 | } QFDS, *PQFDS; |
271 | |
272 | typedef struct qfile { |
273 | ULONG rectype; |
274 | struct qfile *next; |
275 | ULONG opencnt; |
276 | PQFDS filedata; |
277 | char name[1]; |
278 | } QFILE, *PQFILE; |
279 | |
280 | typedef struct { |
281 | ULONG rectype; |
282 | PQTHREAD threads; |
283 | USHORT pid; |
284 | USHORT ppid; |
285 | ULONG type; |
286 | ULONG state; |
287 | ULONG sessid; |
288 | USHORT hndmod; |
289 | USHORT threadcnt; |
290 | ULONG privsem32cnt; |
291 | ULONG _reserved2_; |
292 | USHORT sem16cnt; |
293 | USHORT dllcnt; |
294 | USHORT shrmemcnt; |
295 | USHORT fdscnt; |
296 | PUSHORT sem16s; |
297 | PUSHORT dlls; |
298 | PUSHORT shrmems; |
299 | PUSHORT fds; |
300 | } QPROCESS, *PQPROCESS; |
301 | |
302 | typedef struct sema { |
303 | struct sema *next; |
304 | USHORT refcnt; |
305 | UCHAR sysflags; |
306 | UCHAR sysproccnt; |
307 | ULONG _reserved1_; |
308 | USHORT index; |
309 | CHAR name[1]; |
310 | } QSEMA, *PQSEMA; |
311 | |
312 | typedef struct { |
313 | ULONG rectype; |
314 | ULONG _reserved1_; |
315 | USHORT _reserved2_; |
316 | USHORT syssemidx; |
317 | ULONG index; |
318 | QSEMA sema; |
319 | } QSEMSTRUC, *PQSEMSTRUC; |
320 | |
321 | typedef struct { |
322 | USHORT pid; |
323 | USHORT opencnt; |
324 | } QSEMOWNER32, *PQSEMOWNER32; |
325 | |
326 | typedef struct { |
327 | PQSEMOWNER32 own; |
328 | PCHAR name; |
329 | PVOID semrecs; /* array of associated sema's */ |
330 | USHORT flags; |
331 | USHORT semreccnt; |
332 | USHORT waitcnt; |
333 | USHORT _reserved_; /* padding to ULONG */ |
334 | } QSEMSMUX32, *PQSEMSMUX32; |
335 | |
336 | typedef struct { |
337 | PQSEMOWNER32 own; |
338 | PCHAR name; |
339 | PQSEMSMUX32 mux; |
340 | USHORT flags; |
341 | USHORT postcnt; |
342 | } QSEMEV32, *PQSEMEV32; |
343 | |
344 | typedef struct { |
345 | PQSEMOWNER32 own; |
346 | PCHAR name; |
347 | PQSEMSMUX32 mux; |
348 | USHORT flags; |
349 | USHORT refcnt; |
350 | USHORT thrdnum; |
351 | USHORT _reserved_; /* padding to ULONG */ |
352 | } QSEMMUX32, *PQSEMMUX32; |
353 | |
354 | typedef struct semstr32 { |
355 | struct semstr *next; |
356 | QSEMEV32 evsem; |
357 | QSEMMUX32 muxsem; |
358 | QSEMSMUX32 smuxsem; |
359 | } QSEMSTRUC32, *PQSEMSTRUC32; |
360 | |
361 | typedef struct shrmem { |
362 | struct shrmem *next; |
363 | USHORT hndshr; |
364 | USHORT selshr; |
365 | USHORT refcnt; |
366 | CHAR name[1]; |
367 | } QSHRMEM, *PQSHRMEM; |
368 | |
369 | typedef struct module { |
370 | struct module *next; |
371 | USHORT hndmod; |
372 | USHORT type; |
373 | ULONG refcnt; |
374 | ULONG segcnt; |
375 | PVOID _reserved_; |
376 | PCHAR name; |
377 | USHORT modref[1]; |
378 | } QMODULE, *PQMODULE; |
379 | |
380 | typedef struct { |
381 | PQGLOBAL gbldata; |
382 | PQPROCESS procdata; |
383 | PQSEMSTRUC semadata; |
384 | PQSEMSTRUC32 sem32data; |
385 | PQSHRMEM shrmemdata; |
386 | PQMODULE moddata; |
387 | PVOID _reserved2_; |
388 | PQFILE filedata; |
389 | } QTOPLEVEL, *PQTOPLEVEL; |
390 | /* ************************************************************ */ |
391 | |
392 | PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags); |
393 | |
394 | #endif /* _OS2EMX_H */ |
5ae7bdf7 |
395 | |