source: trunk/essentials/dev-lang/perl/os2/os2ish.h

Last change on this file was 3188, checked in by bird, 18 years ago

Applied patch from Paul (aka Creeping).

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