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