1 #include <signal.h>
2 #include <io.h>
3 /* #include <sys/select.h> */
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 /* BIG_TIME:
18 * This symbol is defined if Time_t is an unsigned type on this system.
19 */
20 #define BIG_TIME
21
22 #define HAS_KILL
23 #define HAS_WAIT
24 #define HAS_DLERROR
25 #define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
26
27 /* HAS_PASSWD
28 * This symbol, if defined, indicates that the getpwnam() and
29 * getpwuid() routines are available to get password entries.
30 * The getpwent() has a separate definition, HAS_GETPWENT.
31 */
32 #define HAS_PASSWD
33
34 /* HAS_GROUP
35 * This symbol, if defined, indicates that the getgrnam() and
36 * getgrgid() routines are available to get group entries.
37 * The getgrent() has a separate definition, HAS_GETGRENT.
38 */
39 #define HAS_GROUP
40 #define HAS_GETGRENT /* fake */
41 #define HAS_SETGRENT /* fake */
42 #define HAS_ENDGRENT /* fake */
43
44 /* USEMYBINMODE
45 * This symbol, if defined, indicates that the program should
46 * use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
47 * that a file is in "binary" mode -- that is, that no translation
48 * of bytes occurs on read or write operations.
49 */
50 #undef USEMYBINMODE
51
52 #define SOCKET_OPEN_MODE "b"
53
54 /* Stat_t:
55 * This symbol holds the type used to declare buffers for information
56 * returned by stat(). It's usually just struct stat. It may be necessary
57 * to include <sys/stat.h> and <sys/types.h> to get any typedef'ed
58 * information.
59 */
60 #define Stat_t struct stat
61
62 /* USE_STAT_RDEV:
63 * This symbol is defined if this system has a stat structure declaring
64 * st_rdev
65 */
66 #define USE_STAT_RDEV /**/
67
68 /* ACME_MESS:
69 * This symbol, if defined, indicates that error messages should be
70 * should be generated in a format that allows the use of the Acme
71 * GUI/editor's autofind feature.
72 */
73 #undef ACME_MESS /**/
74
75 /* ALTERNATE_SHEBANG:
76 * This symbol, if defined, contains a "magic" string which may be used
77 * as the first line of a Perl program designed to be executed directly
78 * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
79 * begins with a character other then #, then Perl will only treat
80 * it as a command line if it finds the string "perl" in the first
81 * word; otherwise it's treated as the first line of code in the script.
82 * (IOW, Perl won't hand off to another interpreter via an alternate
83 * shebang sequence that might be legal Perl code.)
84 */
85 #define ALTERNATE_SHEBANG "extproc "
86
87 #ifndef SIGABRT
88 # define SIGABRT SIGILL
89 #endif
90 #ifndef SIGILL
91 # define SIGILL 6 /* blech */
92 #endif
93 #define ABORT() kill(PerlProc_getpid(),SIGABRT);
94
95 #define BIT_BUCKET "/dev/nul" /* Will this work? */
96
97 /* Apparently TCPIPV4 defines may be included even with only IAK present */
98
99 #if !defined(NO_TCPIPV4) && !defined(TCPIPV4)
100 # define TCPIPV4
101 # define TCPIPV4_FORCED /* Just in case */
102 #endif
103
104 #if defined(I_SYS_UN) && !defined(TCPIPV4)
105 /* It is not working without TCPIPV4 defined. */
106 # undef I_SYS_UN
107 #endif
108
109 #ifdef USE_ITHREADS
110
111 #define do_spawn(a) os2_do_spawn(aTHX_ (a))
112 #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
113
114 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
115
116 extern int rc;
117
118 #define MUTEX_INIT(m) \
119 STMT_START { \
120 int rc; \
121 if ((rc = _rmutex_create(m,0))) \
122 Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \
123 } STMT_END
124 #define MUTEX_LOCK(m) \
125 STMT_START { \
126 int rc; \
127 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
128 Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \
129 } STMT_END
130 #define MUTEX_UNLOCK(m) \
131 STMT_START { \
132 int rc; \
133 if ((rc = _rmutex_release(m))) \
134 Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \
135 } STMT_END
136 #define MUTEX_DESTROY(m) \
137 STMT_START { \
138 int rc; \
139 if ((rc = _rmutex_close(m))) \
140 Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \
141 } STMT_END
142
143 #define COND_INIT(c) \
144 STMT_START { \
145 int rc; \
146 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
147 Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \
148 } STMT_END
149 #define COND_SIGNAL(c) \
150 STMT_START { \
151 int rc; \
152 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
153 Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \
154 } STMT_END
155 #define COND_BROADCAST(c) \
156 STMT_START { \
157 int rc; \
158 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
159 Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \
160 } STMT_END
161 /* #define COND_WAIT(c, m) \
162 STMT_START { \
163 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
164 Perl_croak_nocontext("panic: COND_WAIT"); \
165 } STMT_END
166 */
167 #define COND_WAIT(c, m) os2_cond_wait(c,m)
168
169 #define COND_WAIT_win32(c, m) \
170 STMT_START { \
171 int rc; \
172 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \
173 Perl_croak_nocontext("panic: COND_WAIT"); \
174 else \
175 MUTEX_LOCK(m); \
176 } STMT_END
177 #define COND_DESTROY(c) \
178 STMT_START { \
179 int rc; \
180 if ((rc = DosCloseEventSem(*(c)))) \
181 Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \
182 } STMT_END
183 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
184 */
185
186 #ifdef USE_SLOW_THREAD_SPECIFIC
187 # define pthread_getspecific(k) (*_threadstore())
188 # define pthread_setspecific(k,v) (*_threadstore()=v,0)
189 # define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
190 #else /* USE_SLOW_THREAD_SPECIFIC */
191 # define pthread_getspecific(k) (*(k))
192 # define pthread_setspecific(k,v) (*(k)=(v),0)
193 # define pthread_key_create(keyp,flag) \
194 ( DosAllocThreadLocalMemory(1,(unsigned long**)keyp) \
195 /* diag_listed_as: Out of memory in perl:%s */ \
196 ? Perl_croak_nocontext("Out of memory in perl:os2:pthread_key_create"), 1 \
197 : 0 \
198 )
199 #endif /* USE_SLOW_THREAD_SPECIFIC */
200 #define pthread_key_delete(keyp)
201 #define pthread_self() _gettid()
202 #define YIELD DosSleep(0)
203
204 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
205 int pthread_join(pthread_t tid, void **status);
206 int pthread_detach(pthread_t tid);
207 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
208 void *(*start_routine)(void*), void *arg);
209 #endif /* PTHREAD_INCLUDED */
210
211 #define THREADS_ELSEWHERE
212
213 #else /* USE_ITHREADS */
214
215 #define do_spawn(a) os2_do_spawn(a)
216 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
217
218 void Perl_OS2_init(char **);
219 void Perl_OS2_init3(char **envp, void **excH, int flags);
220 void Perl_OS2_term(void **excH, int exitstatus, int flags);
221
222 /* The code without INIT3 hideously puts env inside: */
223
224 /* These ones should be in the same block as PERL_SYS_TERM() */
225 #ifdef PERL_CORE
226
227 # define PERL_SYS_INIT3_BODY(argcp, argvp, envp) \
228 { void *xreg[2]; \
229 MALLOC_CHECK_TAINT(*argcp, *argvp, *envp) \
230 _response(argcp, argvp); \
231 _wildcard(argcp, argvp); \
232 Perl_OS2_init3(*envp, xreg, 0); \
233 PERLIO_INIT
234
235 # define PERL_SYS_INIT_BODY(argcp, argvp) { \
236 { void *xreg[2]; \
237 _response(argcp, argvp); \
238 _wildcard(argcp, argvp); \
239 Perl_OS2_init3(NULL, xreg, 0); \
240 PERLIO_INIT
241
242 #else /* Compiling embedded Perl or Perl extension */
243
244 # define PERL_SYS_INIT3_BODY(argcp, argvp, envp) \
245 { void *xreg[2]; \
246 Perl_OS2_init3(*envp, xreg, 0); \
247 PERLIO_INIT
248 # define PERL_SYS_INIT_BODY(argcp, argvp) { \
249 { void *xreg[2]; \
250 Perl_OS2_init3(NULL, xreg, 0); \
251 PERLIO_INIT
252 #endif
253
254 #define FORCE_EMX_DEINIT_EXIT 1
255 #define FORCE_EMX_DEINIT_CRT_TERM 2
256 #define FORCE_EMX_DEINIT_RUN_ATEXIT 4
257
258 #define PERL_SYS_TERM2(xreg,flags) \
259 Perl_OS2_term(xreg, 0, flags); \
260 PERLIO_TERM; \
261 MALLOC_TERM
262
263 #define PERL_SYS_TERM1(xreg) \
264 Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT)
265
266 /* This one should come in pair with PERL_SYS_INIT_BODY() and in the same block */
267 #define PERL_SYS_TERM_BODY() \
268 PERL_SYS_TERM1(xreg); \
269 }
270
271 #ifndef __EMX__
272 # define PERL_CALLCONV _System
273 #endif
274
275 /* #define PERL_SYS_TERM_BODY() STMT_START { \
276 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
277
278 #define dXSUB_SYS int fake = OS2_XS_init() PERL_UNUSED_DECL
279
280 #ifdef PERL_IS_AOUT
281 /* # define HAS_FORK */
282 /* # define HIDEMYMALLOC */
283 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
284 #else /* !PERL_IS_AOUT */
285 # ifndef PERL_FOR_X2P
286 # ifdef EMX_BAD_SBRK
287 # define USE_PERL_SBRK
288 # endif
289 # else
290 # define PerlIO FILE
291 # endif
292 # define SYSTEM_ALLOC(a) sys_alloc(a)
293
294 void *sys_alloc(int size);
295
296 #endif /* !PERL_IS_AOUT */
297 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
298 # define PerlIO FILE
299 #endif
300
301 /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
302 * defined. Hack around this to get us to compile.
303 */
304 #ifdef PTHX_UNUSED
305 # ifndef pTHX
306 # define pTHX
307 # endif
308 # ifndef pTHX_
309 # define pTHX_
310 # endif
311 #endif
312
313 #define TMPPATH1 "plXXXXXX"
314 extern const char *tmppath;
315 PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
316 #ifdef PERL_CORE
317 /* Cannot prototype with I32, SV at this point (used in x2p too). */
318 PerlIO *my_syspopen4(pTHX_ char *cmd, char *mode, I32 cnt, SV** args);
319 #endif
320 int my_syspclose(PerlIO *f);
321 FILE *my_tmpfile (void);
322 char *my_tmpnam (char *);
323 int my_mkdir (__const__ char *, long);
324 int my_rmdir (__const__ char *);
325 struct passwd *my_getpwent (void);
326 void my_setpwent (void);
327 void my_endpwent (void);
328 char *gcvt_os2(double value, int digits, char *buffer);
329
330 extern int async_mssleep(unsigned long ms, int switch_priority);
331 extern unsigned long msCounter(void);
332 extern unsigned long InfoTable(int local);
333 extern unsigned long find_myself(void);
334
335 #define MAX_SLEEP (((1<30) / (1000/4))-1) /* 1<32 msec */
336
337 static __inline__ unsigned
my_sleep(unsigned sec)338 my_sleep(unsigned sec)
339 {
340 int remain;
341 while (sec > MAX_SLEEP) {
342 sec -= MAX_SLEEP;
343 remain = sleep(MAX_SLEEP);
344 if (remain)
345 return remain + sec;
346 }
347 return sleep(sec);
348 }
349
350 #define sleep my_sleep
351
352 #ifndef INCL_DOS
353 unsigned long DosSleep(unsigned long);
354 unsigned long DosAllocThreadLocalMemory (unsigned long cb, unsigned long **p);
355 #endif
356
357 struct group *getgrent (void);
358 void setgrent (void);
359 void endgrent (void);
360
361 struct passwd *my_getpwuid (uid_t);
362 struct passwd *my_getpwnam (__const__ char *);
363
364 #undef L_tmpnam
365 #define L_tmpnam MAXPATHLEN
366
367 #define tmpfile my_tmpfile
368 #define tmpnam my_tmpnam
369 #define isatty _isterm
370 #define rand random
371 #define srand srandom
372 #define strtoll _strtoll
373 #define strtoull _strtoull
374
375 #define usleep(usec) ((void)async_mssleep(((usec)+500)/1000, 500))
376
377
378 /*
379 * fwrite1() should be a routine with the same calling sequence as fwrite(),
380 * but which outputs all of the bytes requested as a single stream (unlike
381 * fwrite() itself, which on some systems outputs several distinct records
382 * if the number_of_items parameter is >1).
383 */
384 #define fwrite1 fwrite
385
386 #define my_getenv(var) getenv(var)
387 #define flock my_flock
388 #define rmdir my_rmdir
389 #define mkdir my_mkdir
390 #define setpwent my_setpwent
391 #define getpwent my_getpwent
392 #define endpwent my_endpwent
393 #define getpwuid my_getpwuid
394 #define getpwnam my_getpwnam
395
396 void *emx_calloc (size_t, size_t);
397 void emx_free (void *);
398 void *emx_malloc (size_t);
399 void *emx_realloc (void *, size_t);
400
401 /*****************************************************************************/
402
403 #include <stdlib.h> /* before the following definitions */
404 #include <unistd.h> /* before the following definitions */
405 #include <fcntl.h>
406 #include <sys/stat.h>
407
408 #define chdir _chdir2
409 #define getcwd _getcwd2
410
411 /* This guy is needed for quick stdstd */
412
413 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
414 /* Perl uses ungetc only with successful return */
415 # define ungetc(c,fp) \
416 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
417 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
418 #endif
419
420 #define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
421
422 #include <emx/io.h> /* for _fd_flags() prototype */
423
424 static inline bool
_PERLIO_IS_BINMODE_FD(int fd)425 _PERLIO_IS_BINMODE_FD(int fd)
426 {
427 int *pflags = _fd_flags(fd);
428
429 return pflags && (*pflags) & O_BINARY;
430 }
431
432 /* ctermid is missing from emx0.9d */
433 char *ctermid(char *s);
434
435 #define OP_BINARY O_BINARY
436
437 #define OS2_STAT_HACK 1
438 #if OS2_STAT_HACK
439
440 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
441 #define Fstat(fd,bufptr) os2_fstat((fd),(bufptr))
442 #define Fflush(fp) fflush(fp)
443 #define Mkdir(path,mode) mkdir((path),(mode))
444 #define chmod(path,mode) os2_chmod((path),(mode))
445
446 #undef S_IFBLK
447 #undef S_ISBLK
448 #define S_IFBLK 0120000 /* Hacks to make things compile... */
449 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
450
451 int os2_chmod(const char *name, int pmode);
452 int os2_fstat(int handle, struct stat *st);
453
454 #else
455
456 #define Stat(fname,bufptr) stat((fname),(bufptr))
457 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
458 #define Fflush(fp) fflush(fp)
459 #define Mkdir(path,mode) mkdir((path),(mode))
460
461 #endif
462
463 /* With SD386 it is impossible to debug register variables. */
464 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
465 # define register
466 #endif
467
468 /* Our private OS/2 specific data. */
469
470 typedef struct OS2_Perl_data {
471 unsigned long flags;
472 unsigned long phab;
473 int (*xs_init)();
474 unsigned long rc;
475 unsigned long severity;
476 unsigned long phmq; /* Handle to message queue */
477 unsigned long phmq_refcnt;
478 unsigned long phmq_servers;
479 unsigned long initial_mode; /* VIO etc. mode we were started in */
480 unsigned long morph_refcnt;
481 } OS2_Perl_data_t;
482
483 extern OS2_Perl_data_t OS2_Perl_data;
484
485 #define Perl_hab ((HAB)OS2_Perl_data.phab)
486 #define Perl_rc (OS2_Perl_data.rc)
487 #define Perl_severity (OS2_Perl_data.severity)
488 #define errno_isOS2 12345678
489 #define errno_isOS2_set 12345679
490 #define OS2_Perl_flags (OS2_Perl_data.flags)
491 #define Perl_HAB_set_f 1
492 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
493 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
494 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
495 #define _obtain_Perl_HAB (init_PMWIN_entries(), \
496 Perl_hab = (*PMWIN_entries.Initialize)(0), \
497 set_Perl_HAB_f, Perl_hab)
498 #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
499 #define Acquire_hab() perl_hab_GET()
500 #define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
501 #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
502 #define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
503 #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
504 #define Perl_morph_refcnt (OS2_Perl_data.morph_refcnt)
505
506 unsigned long Perl_hab_GET();
507 unsigned long Perl_Register_MQ(int serve);
508 void Perl_Deregister_MQ(int serve);
509 int Perl_Serve_Messages(int force);
510 /* Cannot prototype with I32 at this point. */
511 int Perl_Process_Messages(int force, long *cntp);
512 char *os2_execname(pTHX);
513
514 struct _QMSG;
515 struct PMWIN_entries_t {
516 unsigned long (*Initialize)( unsigned long fsOptions );
517 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
518 int (*DestroyMsgQueue)(unsigned long hmq);
519 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
520 unsigned long hwndFilter, unsigned long msgFilterFirst,
521 unsigned long msgFilterLast, unsigned long fl);
522 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
523 unsigned long hwndFilter, unsigned long msgFilterFirst,
524 unsigned long msgFilterLast);
525 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
526 unsigned long (*GetLastError)(unsigned long hab);
527 unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways);
528 };
529 extern struct PMWIN_entries_t PMWIN_entries;
530 void init_PMWIN_entries(void);
531
532 #define perl_hmq_GET(serve) Perl_Register_MQ(serve)
533 #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
534
535 #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
536
537 #if _EMX_CRT_REV_ >= 60
538 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
539 _setsyserrno(rc))
540 #else
541 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
542 #endif
543
544 /* The expressions below return true on error. */
545 /* INCL_DOSERRORS needed. rc should be declared outside. */
546 #define CheckOSError(expr) ((rc = (expr)) ? (FillOSError(rc), rc) : 0)
547 /* INCL_WINERRORS needed. */
548 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
549
550 /* This form propagates the return value, setting $^E if needed */
551 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
552
553 /* This form propagates the return value, dieing with $^E if needed */
554 #define SaveCroakWinError(expr,die,name1,name2) \
555 ((expr) ? : (CroakWinError(die,name1 name2), 0))
556
557 #define FillOSError(rc) (os2_setsyserrno(rc), \
558 Perl_severity = SEVERITY_ERROR)
559
560 #define WinError_2_Perl_rc \
561 ( init_PMWIN_entries(), \
562 Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()) )
563
564 /* Calling WinGetLastError() resets the error code of the current thread.
565 Since for some Win* API return value 0 is normal, one needs to call
566 this before calling them to distinguish normal and anomalous returns. */
567 /*#define ResetWinError() WinError_2_Perl_rc */
568
569 /* At this moment init_PMWIN_entries() should be a nop (WinInitialize should
570 be called already, right?), so we do not risk stepping over our own error */
571 #define FillWinError ( WinError_2_Perl_rc, \
572 Perl_severity = ERRORIDSEV(Perl_rc), \
573 Perl_rc = ERRORIDERROR(Perl_rc), \
574 os2_setsyserrno(Perl_rc))
575
576 #define STATIC_FILE_LENGTH 127
577
578 /* This should match loadOrdinals[] array in os2.c */
579 enum entries_ordinals {
580 ORD_DosQueryExtLibpath,
581 ORD_DosSetExtLibpath,
582 ORD_DosVerifyPidTid,
583 ORD_SETHOSTENT,
584 ORD_SETNETENT,
585 ORD_SETPROTOENT,
586 ORD_SETSERVENT,
587 ORD_GETHOSTENT,
588 ORD_GETNETENT,
589 ORD_GETPROTOENT,
590 ORD_GETSERVENT,
591 ORD_ENDHOSTENT,
592 ORD_ENDNETENT,
593 ORD_ENDPROTOENT,
594 ORD_ENDSERVENT,
595 ORD_WinInitialize,
596 ORD_WinCreateMsgQueue,
597 ORD_WinDestroyMsgQueue,
598 ORD_WinPeekMsg,
599 ORD_WinGetMsg,
600 ORD_WinDispatchMsg,
601 ORD_WinGetLastError,
602 ORD_WinCancelShutdown,
603 ORD_RexxStart,
604 ORD_RexxVariablePool,
605 ORD_RexxRegisterFunctionExe,
606 ORD_RexxDeregisterFunction,
607 ORD_DOSSMSETTITLE,
608 ORD_PRF32QUERYPROFILESIZE,
609 ORD_PRF32OPENPROFILE,
610 ORD_PRF32CLOSEPROFILE,
611 ORD_PRF32QUERYPROFILE,
612 ORD_PRF32RESET,
613 ORD_PRF32QUERYPROFILEDATA,
614 ORD_PRF32WRITEPROFILEDATA,
615
616 ORD_WinChangeSwitchEntry,
617 ORD_WinQuerySwitchEntry,
618 ORD_WinQuerySwitchHandle,
619 ORD_WinQuerySwitchList,
620 ORD_WinSwitchToProgram,
621 ORD_WinBeginEnumWindows,
622 ORD_WinEndEnumWindows,
623 ORD_WinEnumDlgItem,
624 ORD_WinGetNextWindow,
625 ORD_WinIsChild,
626 ORD_WinQueryActiveWindow,
627 ORD_WinQueryClassName,
628 ORD_WinQueryFocus,
629 ORD_WinQueryWindow,
630 ORD_WinQueryWindowPos,
631 ORD_WinQueryWindowProcess,
632 ORD_WinQueryWindowText,
633 ORD_WinQueryWindowTextLength,
634 ORD_WinSetFocus,
635 ORD_WinSetWindowPos,
636 ORD_WinSetWindowText,
637 ORD_WinShowWindow,
638 ORD_WinIsWindow,
639 ORD_WinWindowFromId,
640 ORD_WinWindowFromPoint,
641 ORD_WinPostMsg,
642 ORD_WinEnableWindow,
643 ORD_WinEnableWindowUpdate,
644 ORD_WinIsWindowEnabled,
645 ORD_WinIsWindowShowing,
646 ORD_WinIsWindowVisible,
647 ORD_WinQueryWindowPtr,
648 ORD_WinQueryWindowULong,
649 ORD_WinQueryWindowUShort,
650 ORD_WinSetWindowBits,
651 ORD_WinSetWindowPtr,
652 ORD_WinSetWindowULong,
653 ORD_WinSetWindowUShort,
654 ORD_WinQueryDesktopWindow,
655 ORD_WinSetActiveWindow,
656 ORD_DosQueryModFromEIP,
657 ORD_Dos32QueryHeaderInfo,
658 ORD_DosTmrQueryFreq,
659 ORD_DosTmrQueryTime,
660 ORD_WinQueryActiveDesktopPathname,
661 ORD_WinInvalidateRect,
662 ORD_WinCreateFrameControls,
663 ORD_WinQueryClipbrdFmtInfo,
664 ORD_WinQueryClipbrdOwner,
665 ORD_WinQueryClipbrdViewer,
666 ORD_WinQueryClipbrdData,
667 ORD_WinOpenClipbrd,
668 ORD_WinCloseClipbrd,
669 ORD_WinSetClipbrdData,
670 ORD_WinSetClipbrdOwner,
671 ORD_WinSetClipbrdViewer,
672 ORD_WinEnumClipbrdFmts,
673 ORD_WinEmptyClipbrd,
674 ORD_WinAddAtom,
675 ORD_WinFindAtom,
676 ORD_WinDeleteAtom,
677 ORD_WinQueryAtomUsage,
678 ORD_WinQueryAtomName,
679 ORD_WinQueryAtomLength,
680 ORD_WinQuerySystemAtomTable,
681 ORD_WinCreateAtomTable,
682 ORD_WinDestroyAtomTable,
683 ORD_WinOpenWindowDC,
684 ORD_DevOpenDC,
685 ORD_DevQueryCaps,
686 ORD_DevCloseDC,
687 ORD_WinMessageBox,
688 ORD_WinMessageBox2,
689 ORD_WinQuerySysValue,
690 ORD_WinSetSysValue,
691 ORD_WinAlarm,
692 ORD_WinFlashWindow,
693 ORD_WinLoadPointer,
694 ORD_WinQuerySysPointer,
695 ORD_DosReplaceModule,
696 ORD_DosPerfSysCall,
697 ORD_RexxRegisterSubcomExe,
698 ORD_NENTRIES
699 };
700
701 /* RET: return type, AT: argument signature in (), ARGS: should be in () */
702 #define CallORD(ret,o,at,args) (((ret (*)at) loadByOrdinal(o, 1))args)
703 #define DeclFuncByORD(ret,name,o,at,args) \
704 ret name at { return CallORD(ret,o,at,args); }
705 #define DeclVoidFuncByORD(name,o,at,args) \
706 void name at { CallORD(void,o,at,args); }
707
708 /* This function returns error code on error, and saves the error info in $^E and Perl_rc */
709 #define DeclOSFuncByORD_native(ret,name,o,at,args) \
710 ret name at { unsigned long rc; return CheckOSError(CallORD(ret,o,at,args)); }
711
712 /* These functions return false on error, and save the error info in $^E and Perl_rc */
713 #define DeclOSFuncByORD(ret,name,o,at,args) \
714 ret name at { unsigned long rc; return !CheckOSError(CallORD(ret,o,at,args)); }
715 #define DeclWinFuncByORD(ret,name,o,at,args) \
716 ret name at { return SaveWinError(CallORD(ret,o,at,args)); }
717
718 #define AssignFuncPByORD(p,o) (*(Perl_PFN*)&(p) = (loadByOrdinal(o, 1)))
719
720 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
721 #define DeclWinFuncByORD_CACHE(ret,name,o,at,args) \
722 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,1)
723
724 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
725 #define DeclWinFuncByORD_CACHE_resetError(ret,name,o,at,args) \
726 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,1)
727
728 /* Two flavors below do the same as above, but do not auto-croak */
729 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
730 #define DeclWinFuncByORD_CACHE_survive(ret,name,o,at,args) \
731 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,0)
732
733 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
734 #define DeclWinFuncByORD_CACHE_resetError_survive(ret,name,o,at,args) \
735 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,0)
736
737 #define DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,r,die) \
738 static ret (*CAT2(p__Win,name)) at; \
739 static ret name at { \
740 if (!CAT2(p__Win,name)) \
741 AssignFuncPByORD(CAT2(p__Win,name), o); \
742 if (r) ResetWinError(); \
743 return SaveCroakWinError(CAT2(p__Win,name) args, die, "[Win]", STRINGIFY(name)); }
744
745 /* These flavors additionally assume ORD is name with prepended ORD_Win */
746 #define DeclWinFunc_CACHE(ret,name,at,args) \
747 DeclWinFuncByORD_CACHE(ret,name,CAT2(ORD_Win,name),at,args)
748 #define DeclWinFunc_CACHE_resetError(ret,name,at,args) \
749 DeclWinFuncByORD_CACHE_resetError(ret,name,CAT2(ORD_Win,name),at,args)
750 #define DeclWinFunc_CACHE_survive(ret,name,at,args) \
751 DeclWinFuncByORD_CACHE_survive(ret,name,CAT2(ORD_Win,name),at,args)
752 #define DeclWinFunc_CACHE_resetError_survive(ret,name,at,args) \
753 DeclWinFuncByORD_CACHE_resetError_survive(ret,name,CAT2(ORD_Win,name),at,args)
754
755 void ResetWinError(void);
756 void CroakWinError(int die, char *name);
757
758 enum Perlos2_handler {
759 Perlos2_handler_mangle = 1,
760 Perlos2_handler_perl_sh,
761 Perlos2_handler_perllib_from,
762 Perlos2_handler_perllib_to,
763 };
764 enum dir_subst_e {
765 dir_subst_fatal = 1,
766 dir_subst_pathlike = 2
767 };
768
769 extern int Perl_OS2_handler_install(void *handler, enum Perlos2_handler how);
770 extern char *dir_subst(char *s, unsigned int l, char *b, unsigned int bl, enum dir_subst_e flags, char *msg);
771 extern unsigned long fill_extLibpath(int type, char *pre, char *post, int replace, char *msg);
772
773 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
774 char *perllib_mangle(char *, unsigned int);
775
776 #define fork fork_with_resources
777
778 #ifdef EINTR /* x2p do not include perl.h!!! */
779 static __inline__ int
my_select(int nfds,fd_set * readfds,fd_set * writefds,fd_set * exceptfds,struct timeval * timeout)780 my_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
781 {
782 if (nfds == 0 && timeout && (_emx_env & 0x200)) {
783 if (async_mssleep(1000 * timeout->tv_sec + (timeout->tv_usec + 500)/1000, 500))
784 return 0;
785 errno = EINTR;
786 return -1;
787 }
788 return select(nfds, readfds, writefds, exceptfds, timeout);
789 }
790
791 #define select my_select
792 #endif
793
794
795 typedef int (*Perl_PFN)();
796 Perl_PFN loadByOrdinal(enum entries_ordinals ord, int fail);
797 extern const Perl_PFN * const pExtFCN;
798 char *os2error(int rc);
799 int os2_stat(const char *name, struct stat *st);
800 int fork_with_resources();
801 int setpriority(int which, int pid, int val);
802 int getpriority(int which /* ignored */, int pid);
803
804 void croak_with_os2error(char *s) __attribute__((noreturn));
805
806 /* void return value */
807 #define os2cp_croak(rc,msg) (CheckOSError(rc) && (croak_with_os2error(msg),0))
808
809 /* propagates rc */
810 #define os2win_croak(rc,msg) \
811 SaveCroakWinError((expr), 1 /* die */, /* no prefix */, (msg))
812
813 /* propagates rc; use with functions which may return 0 on success */
814 #define os2win_croak_0OK(rc,msg) \
815 SaveCroakWinError((ResetWinError, (expr)), \
816 1 /* die */, /* no prefix */, (msg))
817
818 #ifdef PERL_CORE
819 int os2_do_spawn(pTHX_ char *cmd);
820 int os2_do_aspawn(pTHX_ SV *really, SV **vmark, SV **vsp);
821 #endif
822
823 #ifndef LOG_DAEMON
824
825 /* Replacement for syslog.h */
826 # define LOG_EMERG 0 /* system is unusable */
827 # define LOG_ALERT 1 /* action must be taken immediately */
828 # define LOG_CRIT 2 /* critical conditions */
829 # define LOG_ERR 3 /* error conditions */
830 # define LOG_WARNING 4 /* warning conditions */
831 # define LOG_NOTICE 5 /* normal but significant condition */
832 # define LOG_INFO 6 /* informational */
833 # define LOG_DEBUG 7 /* debug-level messages */
834
835 # define LOG_PRIMASK 0x007 /* mask to extract priority part (internal) */
836 /* extract priority */
837 # define LOG_PRI(p) ((p) & LOG_PRIMASK)
838 # define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
839
840 /* facility codes */
841 # define LOG_KERN (0<<3) /* kernel messages */
842 # define LOG_USER (1<<3) /* random user-level messages */
843 # define LOG_MAIL (2<<3) /* mail system */
844 # define LOG_DAEMON (3<<3) /* system daemons */
845 # define LOG_AUTH (4<<3) /* security/authorization messages */
846 # define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
847 # define LOG_LPR (6<<3) /* line printer subsystem */
848 # define LOG_NEWS (7<<3) /* network news subsystem */
849 # define LOG_UUCP (8<<3) /* UUCP subsystem */
850 # define LOG_CRON (15<<3) /* clock daemon */
851 /* other codes through 15 reserved for system use */
852 # define LOG_LOCAL0 (16<<3) /* reserved for local use */
853 # define LOG_LOCAL1 (17<<3) /* reserved for local use */
854 # define LOG_LOCAL2 (18<<3) /* reserved for local use */
855 # define LOG_LOCAL3 (19<<3) /* reserved for local use */
856 # define LOG_LOCAL4 (20<<3) /* reserved for local use */
857 # define LOG_LOCAL5 (21<<3) /* reserved for local use */
858 # define LOG_LOCAL6 (22<<3) /* reserved for local use */
859 # define LOG_LOCAL7 (23<<3) /* reserved for local use */
860
861 # define LOG_NFACILITIES 24 /* current number of facilities */
862 # define LOG_FACMASK 0x03f8 /* mask to extract facility part */
863 /* facility of pri */
864 # define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
865
866 /*
867 * arguments to setlogmask.
868 */
869 # define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
870 # define LOG_UPTO(pri) nBIT_MASK((pri)+1) /* all priorities through pri */
871
872 /*
873 * Option flags for openlog.
874 *
875 * LOG_ODELAY no longer does anything.
876 * LOG_NDELAY is the inverse of what it used to be.
877 */
878 # define LOG_PID 0x01 /* log the pid with each message */
879 # define LOG_CONS 0x02 /* log on the console if errors in sending */
880 # define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
881 # define LOG_NDELAY 0x08 /* don't delay open */
882 # define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
883 # define LOG_PERROR 0x20 /* log to stderr as well */
884
885 #endif
886
887 /* ************************************************* */
888 #ifndef MAKEPLINFOSEG
889
890 /* From $DDK\base32\rel\os2c\include\base\os2\16bit\infoseg.h + typedefs */
891
892 /*
893 * The structure below defines the content and organization of the system
894 * information segment (InfoSeg). The actual table is statically defined in
895 * SDATA.ASM. Ring 0, read/write access is obtained by the clock device
896 * driver using the DevHlp GetDOSVar function. (GetDOSVar returns a ring 0,
897 * read-only selector to all other requestors.)
898 *
899 * In order to prevent an errant process from destroying the infoseg, two
900 * identical global infosegs are maintained. One is in the tiled shared
901 * arena and is accessible in user mode (and therefore can potentially be
902 * overwritten from ring 2), and the other is in the system arena and is
903 * accessible only in kernel mode. All kernel code (except the clock driver)
904 * is responsible for updating BOTH copies of the infoseg. The copy kept
905 * in the system arena is addressable as DOSGROUP:SISData, and the copy
906 * in the shared arena is addressable via a system arena alias. 16:16 and
907 * 0:32 pointers to the alias are stored in _Sis2.
908 */
909
910 typedef struct InfoSegGDT {
911
912 /* Time (offset 0x00) */
913
914 unsigned long SIS_BigTime; /* Time from 1-1-1970 in seconds */
915 unsigned long SIS_MsCount; /* Freerunning milliseconds counter */
916 unsigned char SIS_HrsTime; /* Hours */
917 unsigned char SIS_MinTime; /* Minutes */
918 unsigned char SIS_SecTime; /* Seconds */
919 unsigned char SIS_HunTime; /* Hundredths of seconds */
920 unsigned short SIS_TimeZone; /* Timezone in min from GMT (Set to EST) */
921 unsigned short SIS_ClkIntrvl; /* Timer interval (units=0.0001 secs) */
922
923 /* Date (offset 0x10) */
924
925 unsigned char SIS_DayDate; /* Day-of-month (1-31) */
926 unsigned char SIS_MonDate; /* Month (1-12) */
927 unsigned short SIS_YrsDate; /* Year (>= 1980) */
928 unsigned char SIS_DOWDate; /* Day-of-week (1-1-80 = Tues = 3) */
929
930 /* Version (offset 0x15) */
931
932 unsigned char SIS_VerMajor; /* Major version number */
933 unsigned char SIS_VerMinor; /* Minor version number */
934 unsigned char SIS_RevLettr; /* Revision letter */
935
936 /* System Status (offset 0x18) */
937
938 unsigned char SIS_CurScrnGrp; /* Fgnd screen group # */
939 unsigned char SIS_MaxScrnGrp; /* Maximum number of screen groups */
940 unsigned char SIS_HugeShfCnt; /* Shift count for huge segments */
941 unsigned char SIS_ProtMdOnly; /* Protect-mode-only indicator */
942 unsigned short SIS_FgndPID; /* Foreground process ID */
943
944 /* Scheduler Parms (offset 0x1E) */
945
946 unsigned char SIS_Dynamic; /* Dynamic variation flag (1=enabled) */
947 unsigned char SIS_MaxWait; /* Maxwait (seconds) */
948 unsigned short SIS_MinSlice; /* Minimum timeslice (milliseconds) */
949 unsigned short SIS_MaxSlice; /* Maximum timeslice (milliseconds) */
950
951 /* Boot Drive (offset 0x24) */
952
953 unsigned short SIS_BootDrv; /* Drive from which system was booted */
954
955 /* RAS Major Event Code Table (offset 0x26) */
956
957 unsigned char SIS_mec_table[32]; /* Table of RAS Major Event Codes (MECs) */
958
959 /* Additional Session Data (offset 0x46) */
960
961 unsigned char SIS_MaxVioWinSG; /* Max. no. of VIO windowable SG's */
962 unsigned char SIS_MaxPresMgrSG; /* Max. no. of Presentation Manager SG's */
963
964 /* Error logging Information (offset 0x48) */
965
966 unsigned short SIS_SysLog; /* Error Logging Status */
967
968 /* Additional RAS Information (offset 0x4A) */
969
970 unsigned short SIS_MMIOBase; /* Memory mapped I/O selector */
971 unsigned long SIS_MMIOAddr; /* Memory mapped I/O address */
972
973 /* Additional 2.0 Data (offset 0x50) */
974
975 unsigned char SIS_MaxVDMs; /* Max. no. of Virtual DOS machines */
976 unsigned char SIS_Reserved;
977
978 unsigned char SIS_perf_mec_table[32]; /* varga 6/5/97 Table of Performance Major Event Codes (MECS) varga*/
979 } GINFOSEG, *PGINFOSEG;
980
981 #define SIS_LEN sizeof(struct InfoSegGDT)
982
983 /*
984 * InfoSeg LDT Data Segment Structure
985 *
986 * The structure below defines the content and organization of the system
987 * information in a special per-process segment to be accessible by the
988 * process through the LDT (read-only).
989 *
990 * As in the global infoseg, two copies of the current processes local
991 * infoseg exist, one accessible in both user and kernel mode, the other
992 * only in kernel mode. Kernel code is responsible for updating BOTH copies.
993 * Pointers to the local infoseg copy are stored in _Lis2.
994 *
995 * Note that only the currently running process has an extra copy of the
996 * local infoseg. The copy is done at context switch time.
997 */
998
999 typedef struct InfoSegLDT {
1000 unsigned short LIS_CurProcID; /* Current process ID */
1001 unsigned short LIS_ParProcID; /* Process ID of parent */
1002 unsigned short LIS_CurThrdPri; /* Current thread priority */
1003 unsigned short LIS_CurThrdID; /* Current thread ID */
1004 unsigned short LIS_CurScrnGrp; /* Screengroup */
1005 unsigned char LIS_ProcStatus; /* Process status bits */
1006 unsigned char LIS_fillbyte1; /* filler byte */
1007 unsigned short LIS_Fgnd; /* Current process is in foreground */
1008 unsigned char LIS_ProcType; /* Current process type */
1009 unsigned char LIS_fillbyte2; /* filler byte */
1010
1011 unsigned short LIS_AX; /* @@V1 Environment selector */
1012 unsigned short LIS_BX; /* @@V1 Offset of command line start */
1013 unsigned short LIS_CX; /* @@V1 Length of Data Segment */
1014 unsigned short LIS_DX; /* @@V1 STACKSIZE from the .EXE file */
1015 unsigned short LIS_SI; /* @@V1 HEAPSIZE from the .EXE file */
1016 unsigned short LIS_DI; /* @@V1 Module handle of the application */
1017 unsigned short LIS_DS; /* @@V1 Data Segment Handle of application */
1018
1019 unsigned short LIS_PackSel; /* First tiled selector in this EXE */
1020 unsigned short LIS_PackShrSel; /* First selector above shared arena */
1021 unsigned short LIS_PackPckSel; /* First selector above packed arena */
1022 /* #ifdef SMP */
1023 unsigned long LIS_pTIB; /* Pointer to TIB */
1024 unsigned long LIS_pPIB; /* Pointer to PIB */
1025 /* #endif */
1026 } LINFOSEG, *PLINFOSEG;
1027
1028 #define LIS_LEN sizeof(struct InfoSegLDT)
1029
1030
1031 /*
1032 * Process Type codes
1033 *
1034 * These are the definitions for the codes stored
1035 * in the LIS_ProcType field in the local infoseg.
1036 */
1037
1038 #define LIS_PT_FULLSCRN 0 /* Full screen app. */
1039 #define LIS_PT_REALMODE 1 /* Real mode process */
1040 #define LIS_PT_VIOWIN 2 /* VIO windowable app. */
1041 #define LIS_PT_PRESMGR 3 /* Presentation Manager app. */
1042 #define LIS_PT_DETACHED 4 /* Detached app. */
1043
1044
1045 /*
1046 *
1047 * Process Status Bit Definitions
1048 *
1049 */
1050
1051 #define LIS_PS_EXITLIST 0x01 /* In exitlist handler */
1052
1053
1054 /*
1055 * Flags equates for the Global Info Segment
1056 * SIS_SysLog WORD in Global Info Segment
1057 *
1058 * xxxx xxxx xxxx xxx0 Error Logging Disabled
1059 * xxxx xxxx xxxx xxx1 Error Logging Enabled
1060 *
1061 * xxxx xxxx xxxx xx0x Error Logging not available
1062 * xxxx xxxx xxxx xx1x Error Logging available
1063 */
1064
1065 #define LF_LOGENABLE 0x0001 /* Logging enabled */
1066 #define LF_LOGAVAILABLE 0x0002 /* Logging available */
1067
1068 #define MAKEPGINFOSEG(sel) ((PGINFOSEG)MAKEP(sel, 0))
1069 #define MAKEPLINFOSEG(sel) ((PLINFOSEG)MAKEP(sel, 0))
1070
1071 #endif /* ndef(MAKEPLINFOSEG) */
1072
1073 /* ************************************************************ */
1074 #define Dos32QuerySysState DosQuerySysState
1075 #define QuerySysState(flags, pid, buf, bufsz) \
1076 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
1077
1078 #define QSS_PROCESS 1
1079 #define QSS_MODULE 4
1080 #define QSS_SEMAPHORES 2
1081 #define QSS_FILE 8 /* Buggy until fixpack18 */
1082 #define QSS_SHARED 16
1083
1084 #ifdef _OS2_H
1085
1086 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
1087 ULONG _res_,PVOID buf,ULONG bufsz);
1088 typedef struct {
1089 ULONG threadcnt;
1090 ULONG proccnt;
1091 ULONG modulecnt;
1092 } QGLOBAL, *PQGLOBAL;
1093
1094 typedef struct {
1095 ULONG rectype;
1096 USHORT threadid;
1097 USHORT slotid;
1098 ULONG sleepid;
1099 ULONG priority;
1100 ULONG systime;
1101 ULONG usertime;
1102 UCHAR state;
1103 UCHAR _reserved1_; /* padding to ULONG */
1104 USHORT _reserved2_; /* padding to ULONG */
1105 } QTHREAD, *PQTHREAD;
1106
1107 typedef struct {
1108 USHORT sfn;
1109 USHORT refcnt;
1110 USHORT flags1;
1111 USHORT flags2;
1112 USHORT accmode1;
1113 USHORT accmode2;
1114 ULONG filesize;
1115 USHORT volhnd;
1116 USHORT attrib;
1117 USHORT _reserved_;
1118 } QFDS, *PQFDS;
1119
1120 typedef struct qfile {
1121 ULONG rectype;
1122 struct qfile *next;
1123 ULONG opencnt;
1124 PQFDS filedata;
1125 char name[1];
1126 } QFILE, *PQFILE;
1127
1128 typedef struct {
1129 ULONG rectype;
1130 PQTHREAD threads;
1131 USHORT pid;
1132 USHORT ppid;
1133 ULONG type;
1134 ULONG state;
1135 ULONG sessid;
1136 USHORT hndmod;
1137 USHORT threadcnt;
1138 ULONG privsem32cnt;
1139 ULONG _reserved2_;
1140 USHORT sem16cnt;
1141 USHORT dllcnt;
1142 USHORT shrmemcnt;
1143 USHORT fdscnt;
1144 PUSHORT sem16s;
1145 PUSHORT dlls;
1146 PUSHORT shrmems;
1147 PUSHORT fds;
1148 } QPROCESS, *PQPROCESS;
1149
1150 typedef struct sema {
1151 struct sema *next;
1152 USHORT refcnt;
1153 UCHAR sysflags;
1154 UCHAR sysproccnt;
1155 ULONG _reserved1_;
1156 USHORT index;
1157 CHAR name[1];
1158 } QSEMA, *PQSEMA;
1159
1160 typedef struct {
1161 ULONG rectype;
1162 ULONG _reserved1_;
1163 USHORT _reserved2_;
1164 USHORT syssemidx;
1165 ULONG index;
1166 QSEMA sema;
1167 } QSEMSTRUC, *PQSEMSTRUC;
1168
1169 typedef struct {
1170 USHORT pid;
1171 USHORT opencnt;
1172 } QSEMOWNER32, *PQSEMOWNER32;
1173
1174 typedef struct {
1175 PQSEMOWNER32 own;
1176 PCHAR name;
1177 PVOID semrecs; /* array of associated sema's */
1178 USHORT flags;
1179 USHORT semreccnt;
1180 USHORT waitcnt;
1181 USHORT _reserved_; /* padding to ULONG */
1182 } QSEMSMUX32, *PQSEMSMUX32;
1183
1184 typedef struct {
1185 PQSEMOWNER32 own;
1186 PCHAR name;
1187 PQSEMSMUX32 mux;
1188 USHORT flags;
1189 USHORT postcnt;
1190 } QSEMEV32, *PQSEMEV32;
1191
1192 typedef struct {
1193 PQSEMOWNER32 own;
1194 PCHAR name;
1195 PQSEMSMUX32 mux;
1196 USHORT flags;
1197 USHORT refcnt;
1198 USHORT thrdnum;
1199 USHORT _reserved_; /* padding to ULONG */
1200 } QSEMMUX32, *PQSEMMUX32;
1201
1202 typedef struct semstr32 {
1203 struct semstr *next;
1204 QSEMEV32 evsem;
1205 QSEMMUX32 muxsem;
1206 QSEMSMUX32 smuxsem;
1207 } QSEMSTRUC32, *PQSEMSTRUC32;
1208
1209 typedef struct shrmem {
1210 struct shrmem *next;
1211 USHORT hndshr;
1212 USHORT selshr;
1213 USHORT refcnt;
1214 CHAR name[1];
1215 } QSHRMEM, *PQSHRMEM;
1216
1217 typedef struct module {
1218 struct module *next;
1219 USHORT hndmod;
1220 USHORT type;
1221 ULONG refcnt;
1222 ULONG segcnt;
1223 PVOID _reserved_;
1224 PCHAR name;
1225 USHORT modref[1];
1226 } QMODULE, *PQMODULE;
1227
1228 typedef struct {
1229 PQGLOBAL gbldata;
1230 PQPROCESS procdata;
1231 PQSEMSTRUC semadata;
1232 PQSEMSTRUC32 sem32data;
1233 PQSHRMEM shrmemdata;
1234 PQMODULE moddata;
1235 PVOID _reserved2_;
1236 PQFILE filedata;
1237 } QTOPLEVEL, *PQTOPLEVEL;
1238 /* ************************************************************ */
1239
1240 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
1241
1242 #endif /* _OS2_H */
1243