Commit | Line | Data |
4633a7c4 |
1 | #include <signal.h> |
2d766320 |
2 | #include <io.h> |
3 | /* #include <sys/select.h> */ |
4633a7c4 |
4 | |
5 | /* HAS_IOCTL: |
6 | * This symbol, if defined, indicates that the ioctl() routine is |
7 | * available to set I/O characteristics |
8 | */ |
9 | #define HAS_IOCTL /**/ |
10 | |
11 | /* HAS_UTIME: |
12 | * This symbol, if defined, indicates that the routine utime() is |
13 | * available to update the access and modification times of files. |
14 | */ |
15 | #define HAS_UTIME /**/ |
16 | |
17 | #define HAS_KILL |
18 | #define HAS_WAIT |
4ea6d94f |
19 | #define HAS_DLERROR |
367f3c24 |
20 | #define HAS_WAITPID_RUNTIME (_emx_env & 0x200) |
4ea6d94f |
21 | |
f72c975a |
22 | /* HAS_PASSWD |
23 | * This symbol, if defined, indicates that the getpwnam() and |
24 | * getpwuid() routines are available to get password entries. |
25 | * The getpwent() has a separate definition, HAS_GETPWENT. |
26 | */ |
27 | #define HAS_PASSWD |
28 | |
29 | /* HAS_GROUP |
30 | * This symbol, if defined, indicates that the getgrnam() and |
31 | * getgrgid() routines are available to get group entries. |
32 | * The getgrent() has a separate definition, HAS_GETGRENT. |
33 | */ |
34 | #define HAS_GROUP |
35 | #define HAS_GETGRENT /* fake */ |
36 | #define HAS_SETGRENT /* fake */ |
37 | #define HAS_ENDGRENT /* fake */ |
38 | |
4ea6d94f |
39 | /* USEMYBINMODE |
40 | * This symbol, if defined, indicates that the program should |
16fe6d59 |
41 | * use the routine my_binmode(FILE *fp, char iotype, int mode) to insure |
4ea6d94f |
42 | * that a file is in "binary" mode -- that is, that no translation |
43 | * of bytes occurs on read or write operations. |
44 | */ |
45 | #undef USEMYBINMODE |
46 | |
61bb5906 |
47 | /* Stat_t: |
48 | * This symbol holds the type used to declare buffers for information |
49 | * returned by stat(). It's usually just struct stat. It may be necessary |
50 | * to include <sys/stat.h> and <sys/types.h> to get any typedef'ed |
51 | * information. |
52 | */ |
53 | #define Stat_t struct stat |
54 | |
4ea6d94f |
55 | /* USE_STAT_RDEV: |
56 | * This symbol is defined if this system has a stat structure declaring |
57 | * st_rdev |
58 | */ |
59 | #define USE_STAT_RDEV /**/ |
60 | |
61 | /* ACME_MESS: |
62 | * This symbol, if defined, indicates that error messages should be |
63 | * should be generated in a format that allows the use of the Acme |
64 | * GUI/editor's autofind feature. |
65 | */ |
66 | #undef ACME_MESS /**/ |
4633a7c4 |
67 | |
44a8e56a |
68 | /* ALTERNATE_SHEBANG: |
69 | * This symbol, if defined, contains a "magic" string which may be used |
70 | * as the first line of a Perl program designed to be executed directly |
71 | * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG |
72 | * begins with a character other then #, then Perl will only treat |
73 | * it as a command line if if finds the string "perl" in the first |
74 | * word; otherwise it's treated as the first line of code in the script. |
75 | * (IOW, Perl won't hand off to another interpreter via an alternate |
76 | * shebang sequence that might be legal Perl code.) |
77 | */ |
aa689395 |
78 | #define ALTERNATE_SHEBANG "extproc " |
44a8e56a |
79 | |
4633a7c4 |
80 | #ifndef SIGABRT |
81 | # define SIGABRT SIGILL |
82 | #endif |
83 | #ifndef SIGILL |
84 | # define SIGILL 6 /* blech */ |
85 | #endif |
7766f137 |
86 | #define ABORT() kill(PerlProc_getpid(),SIGABRT); |
4633a7c4 |
87 | |
760ac839 |
88 | #define BIT_BUCKET "/dev/nul" /* Will this work? */ |
c07a80fd |
89 | |
202975e6 |
90 | /* Apparently TCPIPV4 defines may be included even with only IAK present */ |
91 | |
92 | #if !defined(NO_TCPIPV4) && !defined(TCPIPV4) |
93 | # define TCPIPV4 |
94 | # define TCPIPV4_FORCED /* Just in case */ |
95 | #endif |
96 | |
4a6a15c8 |
97 | #if defined(I_SYS_UN) && !defined(TCPIPV4) |
98 | /* It is not working without TCPIPV4 defined. */ |
99 | # undef I_SYS_UN |
100 | #endif |
dd96f567 |
101 | |
102 | #ifdef USE_THREADS |
103 | |
23da6c43 |
104 | #define do_spawn(a) os2_do_spawn(aTHX_ (a)) |
105 | #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c)) |
106 | |
dd96f567 |
107 | #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */ |
108 | |
109 | extern int rc; |
110 | |
111 | #define MUTEX_INIT(m) \ |
112 | STMT_START { \ |
113 | int rc; \ |
114 | if ((rc = _rmutex_create(m,0))) \ |
23da6c43 |
115 | Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \ |
dd96f567 |
116 | } STMT_END |
117 | #define MUTEX_LOCK(m) \ |
118 | STMT_START { \ |
119 | int rc; \ |
120 | if ((rc = _rmutex_request(m,_FMR_IGNINT))) \ |
23da6c43 |
121 | Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \ |
dd96f567 |
122 | } STMT_END |
123 | #define MUTEX_UNLOCK(m) \ |
124 | STMT_START { \ |
125 | int rc; \ |
126 | if ((rc = _rmutex_release(m))) \ |
23da6c43 |
127 | Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \ |
dd96f567 |
128 | } STMT_END |
129 | #define MUTEX_DESTROY(m) \ |
130 | STMT_START { \ |
131 | int rc; \ |
132 | if ((rc = _rmutex_close(m))) \ |
23da6c43 |
133 | Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \ |
dd96f567 |
134 | } STMT_END |
135 | |
136 | #define COND_INIT(c) \ |
137 | STMT_START { \ |
138 | int rc; \ |
139 | if ((rc = DosCreateEventSem(NULL,c,0,0))) \ |
23da6c43 |
140 | Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \ |
dd96f567 |
141 | } STMT_END |
142 | #define COND_SIGNAL(c) \ |
143 | STMT_START { \ |
144 | int rc; \ |
23da6c43 |
145 | if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\ |
146 | Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \ |
dd96f567 |
147 | } STMT_END |
148 | #define COND_BROADCAST(c) \ |
149 | STMT_START { \ |
150 | int rc; \ |
151 | if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\ |
23da6c43 |
152 | Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \ |
dd96f567 |
153 | } STMT_END |
154 | /* #define COND_WAIT(c, m) \ |
155 | STMT_START { \ |
156 | if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \ |
23da6c43 |
157 | Perl_croak_nocontext("panic: COND_WAIT"); \ |
dd96f567 |
158 | } STMT_END |
159 | */ |
160 | #define COND_WAIT(c, m) os2_cond_wait(c,m) |
161 | |
162 | #define COND_WAIT_win32(c, m) \ |
163 | STMT_START { \ |
164 | int rc; \ |
23da6c43 |
165 | if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \ |
166 | Perl_croak_nocontext("panic: COND_WAIT"); \ |
dd96f567 |
167 | else \ |
168 | MUTEX_LOCK(m); \ |
169 | } STMT_END |
170 | #define COND_DESTROY(c) \ |
171 | STMT_START { \ |
172 | int rc; \ |
173 | if ((rc = DosCloseEventSem(*(c)))) \ |
23da6c43 |
174 | Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \ |
dd96f567 |
175 | } STMT_END |
6b88bc9c |
176 | /*#define THR ((struct thread *) TlsGetValue(PL_thr_key)) |
dd96f567 |
177 | */ |
178 | |
90866323 |
179 | #ifdef USE_SLOW_THREAD_SPECIFIC |
180 | # define pthread_getspecific(k) (*_threadstore()) |
181 | # define pthread_setspecific(k,v) (*_threadstore()=v,0) |
182 | # define pthread_key_create(keyp,flag) (*keyp=_gettid(),0) |
23da6c43 |
183 | #else /* USE_SLOW_THREAD_SPECIFIC */ |
90866323 |
184 | # define pthread_getspecific(k) (*(k)) |
185 | # define pthread_setspecific(k,v) (*(k)=(v),0) |
23da6c43 |
186 | # define pthread_key_create(keyp,flag) \ |
187 | ( DosAllocThreadLocalMemory(1,(U32*)keyp) \ |
188 | ? Perl_croak_nocontext("LocalMemory"),1 \ |
189 | : 0 \ |
190 | ) |
191 | #endif /* USE_SLOW_THREAD_SPECIFIC */ |
90866323 |
192 | #define pthread_key_delete(keyp) |
dd96f567 |
193 | #define pthread_self() _gettid() |
27139dc0 |
194 | #define YIELD DosSleep(0) |
dd96f567 |
195 | |
196 | #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */ |
197 | int pthread_join(pthread_t tid, void **status); |
198 | int pthread_detach(pthread_t tid); |
199 | int pthread_create(pthread_t *tid, const pthread_attr_t *attr, |
200 | void *(*start_routine)(void*), void *arg); |
23da6c43 |
201 | #endif /* PTHREAD_INCLUDED */ |
dd96f567 |
202 | |
203 | #define THREADS_ELSEWHERE |
204 | |
23da6c43 |
205 | #else /* USE_THREADS */ |
206 | |
207 | #define do_spawn(a) os2_do_spawn(a) |
208 | #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c)) |
209 | |
210 | #endif /* USE_THREADS */ |
4a6a15c8 |
211 | |
aa689395 |
212 | void Perl_OS2_init(char **); |
213 | |
214 | /* XXX This code hideously puts env inside: */ |
365eb7b5 |
215 | |
ed344e4f |
216 | #ifdef PERL_CORE |
217 | # define PERL_SYS_INIT3(argcp, argvp, envp) STMT_START { \ |
218 | _response(argcp, argvp); \ |
219 | _wildcard(argcp, argvp); \ |
220 | Perl_OS2_init(*envp); } STMT_END |
aab1f907 |
221 | # define PERL_SYS_INIT(argcp, argvp) STMT_START { \ |
eacfb5f1 |
222 | _response(argcp, argvp); \ |
c0c09dfd |
223 | _wildcard(argcp, argvp); \ |
ed344e4f |
224 | Perl_OS2_init(NULL); } STMT_END |
225 | #else /* Compiling embedded Perl or Perl extension */ |
226 | # define PERL_SYS_INIT3(argcp, argvp, envp) STMT_START { \ |
227 | Perl_OS2_init(*envp); } STMT_END |
aab1f907 |
228 | # define PERL_SYS_INIT(argcp, argvp) STMT_START { \ |
ed344e4f |
229 | Perl_OS2_init(NULL); } STMT_END |
230 | #endif |
231 | |
232 | #ifndef __EMX__ |
aab1f907 |
233 | # define PERL_CALLCONV _System |
234 | #endif |
ed344e4f |
235 | |
18f739ee |
236 | #define PERL_SYS_TERM() MALLOC_TERM |
365eb7b5 |
237 | |
4ea6d94f |
238 | /* #define PERL_SYS_TERM() STMT_START { \ |
239 | if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */ |
240 | |
8cc95fdb |
241 | #define dXSUB_SYS OS2_XS_init() |
eacfb5f1 |
242 | |
4ea6d94f |
243 | #ifdef PERL_IS_AOUT |
4a6a15c8 |
244 | /* # define HAS_FORK */ |
760ac839 |
245 | /* # define HIDEMYMALLOC */ |
246 | /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */ |
247 | #else /* !PERL_IS_AOUT */ |
248 | # ifndef PERL_FOR_X2P |
4a6a15c8 |
249 | # ifdef EMX_BAD_SBRK |
250 | # define USE_PERL_SBRK |
251 | # endif |
252 | # else |
253 | # define PerlIO FILE |
760ac839 |
254 | # endif |
255 | # define SYSTEM_ALLOC(a) sys_alloc(a) |
256 | |
257 | void *sys_alloc(int size); |
258 | |
259 | #endif /* !PERL_IS_AOUT */ |
4a6a15c8 |
260 | #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */ |
261 | # define PerlIO FILE |
262 | #endif |
4ea6d94f |
263 | |
23da6c43 |
264 | /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being |
265 | * defined. Hack around this to get us to compile. |
266 | */ |
267 | #ifdef PTHX_UNUSED |
268 | # ifndef pTHX |
269 | # define pTHX |
270 | # endif |
271 | # ifndef pTHX_ |
272 | # define pTHX_ |
273 | # endif |
274 | #endif |
275 | |
c0c09dfd |
276 | #define TMPPATH1 "plXXXXXX" |
277 | extern char *tmppath; |
23da6c43 |
278 | PerlIO *my_syspopen(pTHX_ char *cmd, char *mode); |
4a6a15c8 |
279 | /* Cannot prototype with I32 at this point. */ |
280 | int my_syspclose(PerlIO *f); |
55497cff |
281 | FILE *my_tmpfile (void); |
282 | char *my_tmpnam (char *); |
5ba48348 |
283 | int my_mkdir (__const__ char *, long); |
284 | int my_rmdir (__const__ char *); |
f72c975a |
285 | struct passwd *my_getpwent (void); |
286 | void my_setpwent (void); |
287 | void my_endpwent (void); |
288 | |
289 | struct group *getgrent (void); |
290 | void setgrent (void); |
291 | void endgrent (void); |
292 | |
293 | struct passwd *my_getpwuid (uid_t); |
294 | struct passwd *my_getpwnam (__const__ char *); |
55497cff |
295 | |
bddf7535 |
296 | #undef L_tmpnam |
297 | #define L_tmpnam MAXPATHLEN |
298 | |
55497cff |
299 | #define tmpfile my_tmpfile |
300 | #define tmpnam my_tmpnam |
3ed26a2c |
301 | #define isatty _isterm |
44a8e56a |
302 | #define rand random |
303 | #define srand srandom |
e75931a7 |
304 | #define strtoll _strtoll |
305 | #define strtoull _strtoull |
eacfb5f1 |
306 | |
4633a7c4 |
307 | /* |
308 | * fwrite1() should be a routine with the same calling sequence as fwrite(), |
309 | * but which outputs all of the bytes requested as a single stream (unlike |
310 | * fwrite() itself, which on some systems outputs several distinct records |
311 | * if the number_of_items parameter is >1). |
312 | */ |
313 | #define fwrite1 fwrite |
314 | |
315 | #define my_getenv(var) getenv(var) |
367f3c24 |
316 | #define flock my_flock |
5ba48348 |
317 | #define rmdir my_rmdir |
318 | #define mkdir my_mkdir |
f72c975a |
319 | #define setpwent my_setpwent |
320 | #define getpwent my_getpwent |
321 | #define endpwent my_endpwent |
322 | #define getpwuid my_getpwuid |
323 | #define getpwnam my_getpwnam |
4633a7c4 |
324 | |
df3ef7a9 |
325 | void *emx_calloc (size_t, size_t); |
326 | void emx_free (void *); |
327 | void *emx_malloc (size_t); |
328 | void *emx_realloc (void *, size_t); |
329 | |
4633a7c4 |
330 | /*****************************************************************************/ |
331 | |
332 | #include <stdlib.h> /* before the following definitions */ |
333 | #include <unistd.h> /* before the following definitions */ |
334 | |
335 | #define chdir _chdir2 |
336 | #define getcwd _getcwd2 |
337 | |
338 | /* This guy is needed for quick stdstd */ |
339 | |
340 | #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE) |
4633a7c4 |
341 | /* Perl uses ungetc only with successful return */ |
342 | # define ungetc(c,fp) \ |
343 | (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \ |
344 | ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp)) |
345 | #endif |
346 | |
46e87256 |
347 | /* ctermid is missing from emx0.9d */ |
348 | char *ctermid(char *s); |
349 | |
4633a7c4 |
350 | #define OP_BINARY O_BINARY |
351 | |
352 | #define OS2_STAT_HACK 1 |
353 | #if OS2_STAT_HACK |
354 | |
355 | #define Stat(fname,bufptr) os2_stat((fname),(bufptr)) |
356 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
357 | #define Fflush(fp) fflush(fp) |
8cc95fdb |
358 | #define Mkdir(path,mode) mkdir((path),(mode)) |
4633a7c4 |
359 | |
360 | #undef S_IFBLK |
361 | #undef S_ISBLK |
362 | #define S_IFBLK 0120000 |
363 | #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) |
364 | |
365 | #else |
366 | |
367 | #define Stat(fname,bufptr) stat((fname),(bufptr)) |
368 | #define Fstat(fd,bufptr) fstat((fd),(bufptr)) |
365eb7b5 |
369 | #define Fflush(fp) fflush(fp) |
8cc95fdb |
370 | #define Mkdir(path,mode) mkdir((path),(mode)) |
4633a7c4 |
371 | |
372 | #endif |
365eb7b5 |
373 | |
44a8e56a |
374 | /* With SD386 it is impossible to debug register variables. */ |
375 | #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register) |
376 | # define register |
377 | #endif |
378 | |
365eb7b5 |
379 | /* Our private OS/2 specific data. */ |
380 | |
381 | typedef struct OS2_Perl_data { |
382 | unsigned long flags; |
383 | unsigned long phab; |
384 | int (*xs_init)(); |
4ea6d94f |
385 | unsigned long rc; |
386 | unsigned long severity; |
4bfbfac5 |
387 | unsigned long phmq; /* Handle to message queue */ |
388 | unsigned long phmq_refcnt; |
389 | unsigned long phmq_servers; |
390 | unsigned long initial_mode; /* VIO etc. mode we were started in */ |
365eb7b5 |
391 | } OS2_Perl_data_t; |
392 | |
393 | extern OS2_Perl_data_t OS2_Perl_data; |
394 | |
4ea6d94f |
395 | #define Perl_hab ((HAB)OS2_Perl_data.phab) |
396 | #define Perl_rc (OS2_Perl_data.rc) |
397 | #define Perl_severity (OS2_Perl_data.severity) |
398 | #define errno_isOS2 12345678 |
ed344e4f |
399 | #define errno_isOS2_set 12345679 |
4ea6d94f |
400 | #define OS2_Perl_flags (OS2_Perl_data.flags) |
365eb7b5 |
401 | #define Perl_HAB_set_f 1 |
4ea6d94f |
402 | #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f) |
403 | #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f) |
404 | #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h) |
4bfbfac5 |
405 | #define _obtain_Perl_HAB (init_PMWIN_entries(), \ |
406 | Perl_hab = (*PMWIN_entries.Initialize)(0), \ |
407 | set_Perl_HAB_f, Perl_hab) |
408 | #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB) |
409 | #define Acquire_hab() perl_hab_GET() |
410 | #define Perl_hmq ((HMQ)OS2_Perl_data.phmq) |
411 | #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt) |
412 | #define Perl_hmq_servers (OS2_Perl_data.phmq_servers) |
413 | #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode) |
414 | |
415 | unsigned long Perl_hab_GET(); |
416 | unsigned long Perl_Register_MQ(int serve); |
417 | void Perl_Deregister_MQ(int serve); |
418 | int Perl_Serve_Messages(int force); |
419 | /* Cannot prototype with I32 at this point. */ |
420 | int Perl_Process_Messages(int force, long *cntp); |
23da6c43 |
421 | char *os2_execname(pTHX); |
4bfbfac5 |
422 | |
423 | struct _QMSG; |
424 | struct PMWIN_entries_t { |
425 | unsigned long (*Initialize)( unsigned long fsOptions ); |
426 | unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg); |
427 | int (*DestroyMsgQueue)(unsigned long hmq); |
428 | int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg, |
429 | unsigned long hwndFilter, unsigned long msgFilterFirst, |
430 | unsigned long msgFilterLast, unsigned long fl); |
431 | int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg, |
432 | unsigned long hwndFilter, unsigned long msgFilterFirst, |
433 | unsigned long msgFilterLast); |
434 | void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg); |
5ba48348 |
435 | unsigned long (*GetLastError)(unsigned long hab); |
436 | unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways); |
4bfbfac5 |
437 | }; |
438 | extern struct PMWIN_entries_t PMWIN_entries; |
439 | void init_PMWIN_entries(void); |
440 | |
ed344e4f |
441 | #define perl_hmq_GET(serve) Perl_Register_MQ(serve) |
442 | #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve) |
4bfbfac5 |
443 | |
23da6c43 |
444 | #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX) |
ed344e4f |
445 | |
446 | #if _EMX_CRT_REV_ >= 60 |
447 | # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \ |
448 | _setsyserrno(rc)) |
449 | #else |
450 | # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2) |
451 | #endif |
452 | |
4ea6d94f |
453 | /* The expressions below return true on error. */ |
4a6a15c8 |
454 | /* INCL_DOSERRORS needed. rc should be declared outside. */ |
4ea6d94f |
455 | #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1)) |
456 | /* INCL_WINERRORS needed. */ |
457 | #define SaveWinError(expr) ((expr) ? : (FillWinError, 0)) |
458 | #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1)) |
ed344e4f |
459 | #define FillOSError(rc) (os2_setsyserrno(rc), \ |
4ea6d94f |
460 | Perl_severity = SEVERITY_ERROR) |
5ba48348 |
461 | |
462 | /* At this moment init_PMWIN_entries() should be a nop (WinInitialize should |
463 | be called already, right?), so we do not risk stepping over our own error */ |
464 | #define FillWinError ( init_PMWIN_entries(), \ |
465 | Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()),\ |
466 | Perl_severity = ERRORIDSEV(Perl_rc), \ |
467 | Perl_rc = ERRORIDERROR(Perl_rc), \ |
468 | os2_setsyserrno(Perl_rc)) |
4ea6d94f |
469 | |
760ac839 |
470 | #define STATIC_FILE_LENGTH 127 |
ff68c719 |
471 | |
760ac839 |
472 | #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n)) |
473 | char *perllib_mangle(char *, unsigned int); |
4ea6d94f |
474 | |
475 | char *os2error(int rc); |
2d766320 |
476 | int os2_stat(const char *name, struct stat *st); |
477 | int setpriority(int which, int pid, int val); |
478 | int getpriority(int which /* ignored */, int pid); |
479 | |
480 | #ifdef PERL_CORE |
481 | int os2_do_spawn(pTHX_ char *cmd); |
482 | int os2_do_aspawn(pTHX_ SV *really, void **vmark, void **vsp); |
483 | #endif |
4ea6d94f |
484 | |
485 | /* ************************************************************ */ |
486 | #define Dos32QuerySysState DosQuerySysState |
487 | #define QuerySysState(flags, pid, buf, bufsz) \ |
488 | Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz) |
489 | |
490 | #define QSS_PROCESS 1 |
df3ef7a9 |
491 | #define QSS_MODULE 4 |
492 | #define QSS_SEMAPHORES 2 |
4ea6d94f |
493 | #define QSS_FILE 8 /* Buggy until fixpack18 */ |
494 | #define QSS_SHARED 16 |
495 | |
ed344e4f |
496 | #ifdef _OS2_H |
4ea6d94f |
497 | |
498 | APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid, |
499 | ULONG _res_,PVOID buf,ULONG bufsz); |
500 | typedef struct { |
501 | ULONG threadcnt; |
502 | ULONG proccnt; |
503 | ULONG modulecnt; |
504 | } QGLOBAL, *PQGLOBAL; |
505 | |
506 | typedef struct { |
507 | ULONG rectype; |
508 | USHORT threadid; |
509 | USHORT slotid; |
510 | ULONG sleepid; |
511 | ULONG priority; |
512 | ULONG systime; |
513 | ULONG usertime; |
514 | UCHAR state; |
515 | UCHAR _reserved1_; /* padding to ULONG */ |
516 | USHORT _reserved2_; /* padding to ULONG */ |
517 | } QTHREAD, *PQTHREAD; |
518 | |
519 | typedef struct { |
520 | USHORT sfn; |
521 | USHORT refcnt; |
522 | USHORT flags1; |
523 | USHORT flags2; |
524 | USHORT accmode1; |
525 | USHORT accmode2; |
526 | ULONG filesize; |
527 | USHORT volhnd; |
528 | USHORT attrib; |
529 | USHORT _reserved_; |
530 | } QFDS, *PQFDS; |
531 | |
532 | typedef struct qfile { |
533 | ULONG rectype; |
534 | struct qfile *next; |
535 | ULONG opencnt; |
536 | PQFDS filedata; |
537 | char name[1]; |
538 | } QFILE, *PQFILE; |
539 | |
540 | typedef struct { |
541 | ULONG rectype; |
542 | PQTHREAD threads; |
543 | USHORT pid; |
544 | USHORT ppid; |
545 | ULONG type; |
546 | ULONG state; |
547 | ULONG sessid; |
548 | USHORT hndmod; |
549 | USHORT threadcnt; |
550 | ULONG privsem32cnt; |
551 | ULONG _reserved2_; |
552 | USHORT sem16cnt; |
553 | USHORT dllcnt; |
554 | USHORT shrmemcnt; |
555 | USHORT fdscnt; |
556 | PUSHORT sem16s; |
557 | PUSHORT dlls; |
558 | PUSHORT shrmems; |
559 | PUSHORT fds; |
560 | } QPROCESS, *PQPROCESS; |
561 | |
562 | typedef struct sema { |
563 | struct sema *next; |
564 | USHORT refcnt; |
565 | UCHAR sysflags; |
566 | UCHAR sysproccnt; |
567 | ULONG _reserved1_; |
568 | USHORT index; |
569 | CHAR name[1]; |
570 | } QSEMA, *PQSEMA; |
571 | |
572 | typedef struct { |
573 | ULONG rectype; |
574 | ULONG _reserved1_; |
575 | USHORT _reserved2_; |
576 | USHORT syssemidx; |
577 | ULONG index; |
578 | QSEMA sema; |
579 | } QSEMSTRUC, *PQSEMSTRUC; |
580 | |
581 | typedef struct { |
582 | USHORT pid; |
583 | USHORT opencnt; |
584 | } QSEMOWNER32, *PQSEMOWNER32; |
585 | |
586 | typedef struct { |
587 | PQSEMOWNER32 own; |
588 | PCHAR name; |
589 | PVOID semrecs; /* array of associated sema's */ |
590 | USHORT flags; |
591 | USHORT semreccnt; |
592 | USHORT waitcnt; |
593 | USHORT _reserved_; /* padding to ULONG */ |
594 | } QSEMSMUX32, *PQSEMSMUX32; |
595 | |
596 | typedef struct { |
597 | PQSEMOWNER32 own; |
598 | PCHAR name; |
599 | PQSEMSMUX32 mux; |
600 | USHORT flags; |
601 | USHORT postcnt; |
602 | } QSEMEV32, *PQSEMEV32; |
603 | |
604 | typedef struct { |
605 | PQSEMOWNER32 own; |
606 | PCHAR name; |
607 | PQSEMSMUX32 mux; |
608 | USHORT flags; |
609 | USHORT refcnt; |
610 | USHORT thrdnum; |
611 | USHORT _reserved_; /* padding to ULONG */ |
612 | } QSEMMUX32, *PQSEMMUX32; |
613 | |
614 | typedef struct semstr32 { |
615 | struct semstr *next; |
616 | QSEMEV32 evsem; |
617 | QSEMMUX32 muxsem; |
618 | QSEMSMUX32 smuxsem; |
619 | } QSEMSTRUC32, *PQSEMSTRUC32; |
620 | |
621 | typedef struct shrmem { |
622 | struct shrmem *next; |
623 | USHORT hndshr; |
624 | USHORT selshr; |
625 | USHORT refcnt; |
626 | CHAR name[1]; |
627 | } QSHRMEM, *PQSHRMEM; |
628 | |
629 | typedef struct module { |
630 | struct module *next; |
631 | USHORT hndmod; |
632 | USHORT type; |
633 | ULONG refcnt; |
634 | ULONG segcnt; |
635 | PVOID _reserved_; |
636 | PCHAR name; |
637 | USHORT modref[1]; |
638 | } QMODULE, *PQMODULE; |
639 | |
640 | typedef struct { |
641 | PQGLOBAL gbldata; |
642 | PQPROCESS procdata; |
643 | PQSEMSTRUC semadata; |
644 | PQSEMSTRUC32 sem32data; |
645 | PQSHRMEM shrmemdata; |
646 | PQMODULE moddata; |
647 | PVOID _reserved2_; |
648 | PQFILE filedata; |
649 | } QTOPLEVEL, *PQTOPLEVEL; |
650 | /* ************************************************************ */ |
651 | |
652 | PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags); |
653 | |
ed344e4f |
654 | #endif /* _OS2_H */ |
5ae7bdf7 |
655 | |