This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Document the _exit() issue with threads in Linux [perl #17057].
[perl5.git] / os2 / os2ish.h
... / ...
CommitLineData
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#define HAS_KILL
18#define HAS_WAIT
19#define HAS_DLERROR
20#define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
21
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
39/* USEMYBINMODE
40 * This symbol, if defined, indicates that the program should
41 * use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
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
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
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 /**/
67
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 */
78#define ALTERNATE_SHEBANG "extproc "
79
80#ifndef SIGABRT
81# define SIGABRT SIGILL
82#endif
83#ifndef SIGILL
84# define SIGILL 6 /* blech */
85#endif
86#define ABORT() kill(PerlProc_getpid(),SIGABRT);
87
88#define BIT_BUCKET "/dev/nul" /* Will this work? */
89
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
97#if defined(I_SYS_UN) && !defined(TCPIPV4)
98/* It is not working without TCPIPV4 defined. */
99# undef I_SYS_UN
100#endif
101
102#define do_spawn(a) os2_do_spawn(a)
103#define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
104
105void Perl_OS2_init(char **);
106void Perl_OS2_init3(char **envp, void **excH, int flags);
107void Perl_OS2_term(void **excH, int exitstatus, int flags);
108
109/* The code without INIT3 hideously puts env inside: */
110
111/* These ones should be in the same block as PERL_SYS_TERM() */
112#ifdef PERL_CORE
113
114# define PERL_SYS_INIT3(argcp, argvp, envp) \
115 { void *xreg[2]; \
116 _response(argcp, argvp); \
117 _wildcard(argcp, argvp); \
118 Perl_OS2_init3(*envp, xreg, 0)
119
120# define PERL_SYS_INIT(argcp, argvp) { \
121 { void *xreg[2]; \
122 _response(argcp, argvp); \
123 _wildcard(argcp, argvp); \
124 Perl_OS2_init3(NULL, xreg, 0)
125
126#else /* Compiling embedded Perl or Perl extension */
127
128# define PERL_SYS_INIT3(argcp, argvp, envp) \
129 { void *xreg[2]; \
130 Perl_OS2_init3(*envp, xreg, 0)
131# define PERL_SYS_INIT(argcp, argvp) { \
132 { void *xreg[2]; \
133 Perl_OS2_init3(NULL, xreg, 0)
134#endif
135
136#define FORCE_EMX_DEINIT_EXIT 1
137#define FORCE_EMX_DEINIT_CRT_TERM 2
138#define FORCE_EMX_DEINIT_RUN_ATEXIT 4
139
140#define PERL_SYS_TERM2(xreg,flags) \
141 Perl_OS2_term(xreg, 0, flags); \
142 MALLOC_TERM
143
144#define PERL_SYS_TERM1(xreg) \
145 Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT)
146
147/* This one should come in pair with PERL_SYS_INIT() and in the same block */
148#define PERL_SYS_TERM() \
149 PERL_SYS_TERM1(xreg); \
150 }
151
152#ifndef __EMX__
153# define PERL_CALLCONV _System
154#endif
155
156/* #define PERL_SYS_TERM() STMT_START { \
157 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
158
159#define dXSUB_SYS OS2_XS_init()
160
161#ifdef PERL_IS_AOUT
162/* # define HAS_FORK */
163/* # define HIDEMYMALLOC */
164/* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
165#else /* !PERL_IS_AOUT */
166# ifndef PERL_FOR_X2P
167# ifdef EMX_BAD_SBRK
168# define USE_PERL_SBRK
169# endif
170# else
171# define PerlIO FILE
172# endif
173# define SYSTEM_ALLOC(a) sys_alloc(a)
174
175void *sys_alloc(int size);
176
177#endif /* !PERL_IS_AOUT */
178#if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
179# define PerlIO FILE
180#endif
181
182/* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
183 * defined. Hack around this to get us to compile.
184*/
185#ifdef PTHX_UNUSED
186# ifndef pTHX
187# define pTHX
188# endif
189# ifndef pTHX_
190# define pTHX_
191# endif
192#endif
193
194#define TMPPATH1 "plXXXXXX"
195extern char *tmppath;
196PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
197/* Cannot prototype with I32 at this point. */
198int my_syspclose(PerlIO *f);
199FILE *my_tmpfile (void);
200char *my_tmpnam (char *);
201int my_mkdir (__const__ char *, long);
202int my_rmdir (__const__ char *);
203struct passwd *my_getpwent (void);
204void my_setpwent (void);
205void my_endpwent (void);
206char *gcvt_os2(double value, int digits, char *buffer);
207
208struct group *getgrent (void);
209void setgrent (void);
210void endgrent (void);
211
212struct passwd *my_getpwuid (uid_t);
213struct passwd *my_getpwnam (__const__ char *);
214
215#undef L_tmpnam
216#define L_tmpnam MAXPATHLEN
217
218#define tmpfile my_tmpfile
219#define tmpnam my_tmpnam
220#define isatty _isterm
221#define rand random
222#define srand srandom
223#define strtoll _strtoll
224#define strtoull _strtoull
225
226/*
227 * fwrite1() should be a routine with the same calling sequence as fwrite(),
228 * but which outputs all of the bytes requested as a single stream (unlike
229 * fwrite() itself, which on some systems outputs several distinct records
230 * if the number_of_items parameter is >1).
231 */
232#define fwrite1 fwrite
233
234#define my_getenv(var) getenv(var)
235#define flock my_flock
236#define rmdir my_rmdir
237#define mkdir my_mkdir
238#define setpwent my_setpwent
239#define getpwent my_getpwent
240#define endpwent my_endpwent
241#define getpwuid my_getpwuid
242#define getpwnam my_getpwnam
243
244void *emx_calloc (size_t, size_t);
245void emx_free (void *);
246void *emx_malloc (size_t);
247void *emx_realloc (void *, size_t);
248
249/*****************************************************************************/
250
251#include <stdlib.h> /* before the following definitions */
252#include <unistd.h> /* before the following definitions */
253#include <fcntl.h>
254#include <sys/stat.h>
255
256#define chdir _chdir2
257#define getcwd _getcwd2
258
259/* This guy is needed for quick stdstd */
260
261#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
262 /* Perl uses ungetc only with successful return */
263# define ungetc(c,fp) \
264 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
265 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
266#endif
267
268#define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
269
270#ifdef __GNUG__
271# define HAS_BOOL
272#endif
273#ifndef HAS_BOOL
274# define bool char
275# define HAS_BOOL 1
276#endif
277
278#include <emx/io.h> /* for _fd_flags() prototype */
279
280static inline bool
281_PERLIO_IS_BINMODE_FD(int fd)
282{
283 int *pflags = _fd_flags(fd);
284
285 return pflags && (*pflags) & O_BINARY;
286}
287
288/* ctermid is missing from emx0.9d */
289char *ctermid(char *s);
290
291#define OP_BINARY O_BINARY
292
293#define OS2_STAT_HACK 1
294#if OS2_STAT_HACK
295
296#define Stat(fname,bufptr) os2_stat((fname),(bufptr))
297#define Fstat(fd,bufptr) fstat((fd),(bufptr))
298#define Fflush(fp) fflush(fp)
299#define Mkdir(path,mode) mkdir((path),(mode))
300
301#undef S_IFBLK
302#undef S_ISBLK
303#define S_IFBLK 0120000
304#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
305
306#else
307
308#define Stat(fname,bufptr) stat((fname),(bufptr))
309#define Fstat(fd,bufptr) fstat((fd),(bufptr))
310#define Fflush(fp) fflush(fp)
311#define Mkdir(path,mode) mkdir((path),(mode))
312
313#endif
314
315/* With SD386 it is impossible to debug register variables. */
316#if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
317# define register
318#endif
319
320/* Our private OS/2 specific data. */
321
322typedef struct OS2_Perl_data {
323 unsigned long flags;
324 unsigned long phab;
325 int (*xs_init)();
326 unsigned long rc;
327 unsigned long severity;
328 unsigned long phmq; /* Handle to message queue */
329 unsigned long phmq_refcnt;
330 unsigned long phmq_servers;
331 unsigned long initial_mode; /* VIO etc. mode we were started in */
332} OS2_Perl_data_t;
333
334extern OS2_Perl_data_t OS2_Perl_data;
335
336#define Perl_hab ((HAB)OS2_Perl_data.phab)
337#define Perl_rc (OS2_Perl_data.rc)
338#define Perl_severity (OS2_Perl_data.severity)
339#define errno_isOS2 12345678
340#define errno_isOS2_set 12345679
341#define OS2_Perl_flags (OS2_Perl_data.flags)
342#define Perl_HAB_set_f 1
343#define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
344#define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
345#define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
346#define _obtain_Perl_HAB (init_PMWIN_entries(), \
347 Perl_hab = (*PMWIN_entries.Initialize)(0), \
348 set_Perl_HAB_f, Perl_hab)
349#define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
350#define Acquire_hab() perl_hab_GET()
351#define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
352#define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
353#define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
354#define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
355
356unsigned long Perl_hab_GET();
357unsigned long Perl_Register_MQ(int serve);
358void Perl_Deregister_MQ(int serve);
359int Perl_Serve_Messages(int force);
360/* Cannot prototype with I32 at this point. */
361int Perl_Process_Messages(int force, long *cntp);
362char *os2_execname(pTHX);
363
364struct _QMSG;
365struct PMWIN_entries_t {
366 unsigned long (*Initialize)( unsigned long fsOptions );
367 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
368 int (*DestroyMsgQueue)(unsigned long hmq);
369 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
370 unsigned long hwndFilter, unsigned long msgFilterFirst,
371 unsigned long msgFilterLast, unsigned long fl);
372 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
373 unsigned long hwndFilter, unsigned long msgFilterFirst,
374 unsigned long msgFilterLast);
375 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
376 unsigned long (*GetLastError)(unsigned long hab);
377 unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways);
378};
379extern struct PMWIN_entries_t PMWIN_entries;
380void init_PMWIN_entries(void);
381
382#define perl_hmq_GET(serve) Perl_Register_MQ(serve)
383#define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
384
385#define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
386
387#if _EMX_CRT_REV_ >= 60
388# define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
389 _setsyserrno(rc))
390#else
391# define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
392#endif
393
394/* The expressions below return true on error. */
395/* INCL_DOSERRORS needed. rc should be declared outside. */
396#define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
397/* INCL_WINERRORS needed. */
398#define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
399
400/* This form propagates the return value, setting $^E if needed */
401#define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
402
403/* This form propagates the return value, dieing with $^E if needed */
404#define SaveCroakWinError(expr,die,name1,name2) \
405 ((expr) ? : (CroakWinError(die,name1 name2), 0))
406
407#define FillOSError(rc) (os2_setsyserrno(rc), \
408 Perl_severity = SEVERITY_ERROR)
409
410#define WinError_2_Perl_rc \
411 ( init_PMWIN_entries(), \
412 Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()) )
413
414/* Calling WinGetLastError() resets the error code of the current thread.
415 Since for some Win* API return value 0 is normal, one needs to call
416 this before calling them to distinguish normal and anomalous returns. */
417/*#define ResetWinError() WinError_2_Perl_rc */
418
419/* At this moment init_PMWIN_entries() should be a nop (WinInitialize should
420 be called already, right?), so we do not risk stepping over our own error */
421#define FillWinError ( WinError_2_Perl_rc, \
422 Perl_severity = ERRORIDSEV(Perl_rc), \
423 Perl_rc = ERRORIDERROR(Perl_rc), \
424 os2_setsyserrno(Perl_rc))
425
426#define STATIC_FILE_LENGTH 127
427
428 /* This should match loadOrdinals[] array in os2.c */
429enum entries_ordinals {
430 ORD_DosQueryExtLibpath,
431 ORD_DosSetExtLibpath,
432 ORD_DosVerifyPidTid,
433 ORD_SETHOSTENT,
434 ORD_SETNETENT,
435 ORD_SETPROTOENT,
436 ORD_SETSERVENT,
437 ORD_GETHOSTENT,
438 ORD_GETNETENT,
439 ORD_GETPROTOENT,
440 ORD_GETSERVENT,
441 ORD_ENDHOSTENT,
442 ORD_ENDNETENT,
443 ORD_ENDPROTOENT,
444 ORD_ENDSERVENT,
445 ORD_WinInitialize,
446 ORD_WinCreateMsgQueue,
447 ORD_WinDestroyMsgQueue,
448 ORD_WinPeekMsg,
449 ORD_WinGetMsg,
450 ORD_WinDispatchMsg,
451 ORD_WinGetLastError,
452 ORD_WinCancelShutdown,
453 ORD_RexxStart,
454 ORD_RexxVariablePool,
455 ORD_RexxRegisterFunctionExe,
456 ORD_RexxDeregisterFunction,
457 ORD_DOSSMSETTITLE,
458 ORD_PRF32QUERYPROFILESIZE,
459 ORD_PRF32OPENPROFILE,
460 ORD_PRF32CLOSEPROFILE,
461 ORD_PRF32QUERYPROFILE,
462 ORD_PRF32RESET,
463 ORD_PRF32QUERYPROFILEDATA,
464 ORD_PRF32WRITEPROFILEDATA,
465
466 ORD_WinChangeSwitchEntry,
467 ORD_WinQuerySwitchEntry,
468 ORD_WinQuerySwitchHandle,
469 ORD_WinQuerySwitchList,
470 ORD_WinSwitchToProgram,
471 ORD_WinBeginEnumWindows,
472 ORD_WinEndEnumWindows,
473 ORD_WinEnumDlgItem,
474 ORD_WinGetNextWindow,
475 ORD_WinIsChild,
476 ORD_WinQueryActiveWindow,
477 ORD_WinQueryClassName,
478 ORD_WinQueryFocus,
479 ORD_WinQueryWindow,
480 ORD_WinQueryWindowPos,
481 ORD_WinQueryWindowProcess,
482 ORD_WinQueryWindowText,
483 ORD_WinQueryWindowTextLength,
484 ORD_WinSetFocus,
485 ORD_WinSetWindowPos,
486 ORD_WinSetWindowText,
487 ORD_WinShowWindow,
488 ORD_WinIsWindow,
489 ORD_WinWindowFromId,
490 ORD_WinWindowFromPoint,
491 ORD_WinPostMsg,
492 ORD_WinEnableWindow,
493 ORD_WinEnableWindowUpdate,
494 ORD_WinIsWindowEnabled,
495 ORD_WinIsWindowShowing,
496 ORD_WinIsWindowVisible,
497 ORD_WinQueryWindowPtr,
498 ORD_WinQueryWindowULong,
499 ORD_WinQueryWindowUShort,
500 ORD_WinSetWindowBits,
501 ORD_WinSetWindowPtr,
502 ORD_WinSetWindowULong,
503 ORD_WinSetWindowUShort,
504 ORD_WinQueryDesktopWindow,
505 ORD_WinSetActiveWindow,
506 ORD_DosQueryModFromEIP,
507 ORD_NENTRIES
508};
509
510/* RET: return type, AT: argument signature in (), ARGS: should be in () */
511#define CallORD(ret,o,at,args) (((ret (*)at) loadByOrdinal(o, 1))args)
512#define DeclFuncByORD(ret,name,o,at,args) \
513 ret name at { return CallORD(ret,o,at,args); }
514#define DeclVoidFuncByORD(name,o,at,args) \
515 void name at { CallORD(void,o,at,args); }
516
517/* These functions return false on error, and save the error info in $^E */
518#define DeclOSFuncByORD(ret,name,o,at,args) \
519 ret name at { unsigned long rc; return !CheckOSError(CallORD(ret,o,at,args)); }
520#define DeclWinFuncByORD(ret,name,o,at,args) \
521 ret name at { return SaveWinError(CallORD(ret,o,at,args)); }
522
523#define AssignFuncPByORD(p,o) (*(Perl_PFN*)&(p) = (loadByOrdinal(o, 1)))
524
525/* This flavor caches the procedure pointer (named as p__Win#name) locally */
526#define DeclWinFuncByORD_CACHE(ret,name,o,at,args) \
527 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,1)
528
529/* This flavor may reset the last error before the call (if ret=0 may be OK) */
530#define DeclWinFuncByORD_CACHE_resetError(ret,name,o,at,args) \
531 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,1)
532
533/* Two flavors below do the same as above, but do not auto-croak */
534/* This flavor caches the procedure pointer (named as p__Win#name) locally */
535#define DeclWinFuncByORD_CACHE_survive(ret,name,o,at,args) \
536 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,0)
537
538/* This flavor may reset the last error before the call (if ret=0 may be OK) */
539#define DeclWinFuncByORD_CACHE_resetError_survive(ret,name,o,at,args) \
540 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,0)
541
542#define DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,r,die) \
543 static ret (*CAT2(p__Win,name)) at; \
544 static ret name at { \
545 if (!CAT2(p__Win,name)) \
546 AssignFuncPByORD(CAT2(p__Win,name), o); \
547 if (r) ResetWinError(); \
548 return SaveCroakWinError(CAT2(p__Win,name) args, die, "[Win]", STRINGIFY(name)); }
549
550/* These flavors additionally assume ORD is name with prepended ORD_Win */
551#define DeclWinFunc_CACHE(ret,name,at,args) \
552 DeclWinFuncByORD_CACHE(ret,name,CAT2(ORD_Win,name),at,args)
553#define DeclWinFunc_CACHE_resetError(ret,name,at,args) \
554 DeclWinFuncByORD_CACHE_resetError(ret,name,CAT2(ORD_Win,name),at,args)
555#define DeclWinFunc_CACHE_survive(ret,name,at,args) \
556 DeclWinFuncByORD_CACHE_survive(ret,name,CAT2(ORD_Win,name),at,args)
557#define DeclWinFunc_CACHE_resetError_survive(ret,name,at,args) \
558 DeclWinFuncByORD_CACHE_resetError_survive(ret,name,CAT2(ORD_Win,name),at,args)
559
560void ResetWinError(void);
561void CroakWinError(int die, char *name);
562
563#define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
564char *perllib_mangle(char *, unsigned int);
565
566typedef int (*Perl_PFN)();
567Perl_PFN loadByOrdinal(enum entries_ordinals ord, int fail);
568extern const Perl_PFN * const pExtFCN;
569char *os2error(int rc);
570int os2_stat(const char *name, struct stat *st);
571int setpriority(int which, int pid, int val);
572int getpriority(int which /* ignored */, int pid);
573
574#ifdef PERL_CORE
575int os2_do_spawn(pTHX_ char *cmd);
576int os2_do_aspawn(pTHX_ SV *really, void **vmark, void **vsp);
577#endif
578
579#ifndef LOG_DAEMON
580
581/* Replacement for syslog.h */
582# define LOG_EMERG 0 /* system is unusable */
583# define LOG_ALERT 1 /* action must be taken immediately */
584# define LOG_CRIT 2 /* critical conditions */
585# define LOG_ERR 3 /* error conditions */
586# define LOG_WARNING 4 /* warning conditions */
587# define LOG_NOTICE 5 /* normal but significant condition */
588# define LOG_INFO 6 /* informational */
589# define LOG_DEBUG 7 /* debug-level messages */
590
591# define LOG_PRIMASK 0x007 /* mask to extract priority part (internal) */
592 /* extract priority */
593# define LOG_PRI(p) ((p) & LOG_PRIMASK)
594# define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
595
596/* facility codes */
597# define LOG_KERN (0<<3) /* kernel messages */
598# define LOG_USER (1<<3) /* random user-level messages */
599# define LOG_MAIL (2<<3) /* mail system */
600# define LOG_DAEMON (3<<3) /* system daemons */
601# define LOG_AUTH (4<<3) /* security/authorization messages */
602# define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
603# define LOG_LPR (6<<3) /* line printer subsystem */
604# define LOG_NEWS (7<<3) /* network news subsystem */
605# define LOG_UUCP (8<<3) /* UUCP subsystem */
606# define LOG_CRON (15<<3) /* clock daemon */
607 /* other codes through 15 reserved for system use */
608# define LOG_LOCAL0 (16<<3) /* reserved for local use */
609# define LOG_LOCAL1 (17<<3) /* reserved for local use */
610# define LOG_LOCAL2 (18<<3) /* reserved for local use */
611# define LOG_LOCAL3 (19<<3) /* reserved for local use */
612# define LOG_LOCAL4 (20<<3) /* reserved for local use */
613# define LOG_LOCAL5 (21<<3) /* reserved for local use */
614# define LOG_LOCAL6 (22<<3) /* reserved for local use */
615# define LOG_LOCAL7 (23<<3) /* reserved for local use */
616
617# define LOG_NFACILITIES 24 /* current number of facilities */
618# define LOG_FACMASK 0x03f8 /* mask to extract facility part */
619 /* facility of pri */
620# define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
621
622/*
623 * arguments to setlogmask.
624 */
625# define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
626# define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
627
628/*
629 * Option flags for openlog.
630 *
631 * LOG_ODELAY no longer does anything.
632 * LOG_NDELAY is the inverse of what it used to be.
633 */
634# define LOG_PID 0x01 /* log the pid with each message */
635# define LOG_CONS 0x02 /* log on the console if errors in sending */
636# define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
637# define LOG_NDELAY 0x08 /* don't delay open */
638# define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
639# define LOG_PERROR 0x20 /* log to stderr as well */
640
641#endif
642
643/* ************************************************************ */
644#define Dos32QuerySysState DosQuerySysState
645#define QuerySysState(flags, pid, buf, bufsz) \
646 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
647
648#define QSS_PROCESS 1
649#define QSS_MODULE 4
650#define QSS_SEMAPHORES 2
651#define QSS_FILE 8 /* Buggy until fixpack18 */
652#define QSS_SHARED 16
653
654#ifdef _OS2_H
655
656APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
657 ULONG _res_,PVOID buf,ULONG bufsz);
658typedef struct {
659 ULONG threadcnt;
660 ULONG proccnt;
661 ULONG modulecnt;
662} QGLOBAL, *PQGLOBAL;
663
664typedef struct {
665 ULONG rectype;
666 USHORT threadid;
667 USHORT slotid;
668 ULONG sleepid;
669 ULONG priority;
670 ULONG systime;
671 ULONG usertime;
672 UCHAR state;
673 UCHAR _reserved1_; /* padding to ULONG */
674 USHORT _reserved2_; /* padding to ULONG */
675} QTHREAD, *PQTHREAD;
676
677typedef struct {
678 USHORT sfn;
679 USHORT refcnt;
680 USHORT flags1;
681 USHORT flags2;
682 USHORT accmode1;
683 USHORT accmode2;
684 ULONG filesize;
685 USHORT volhnd;
686 USHORT attrib;
687 USHORT _reserved_;
688} QFDS, *PQFDS;
689
690typedef struct qfile {
691 ULONG rectype;
692 struct qfile *next;
693 ULONG opencnt;
694 PQFDS filedata;
695 char name[1];
696} QFILE, *PQFILE;
697
698typedef struct {
699 ULONG rectype;
700 PQTHREAD threads;
701 USHORT pid;
702 USHORT ppid;
703 ULONG type;
704 ULONG state;
705 ULONG sessid;
706 USHORT hndmod;
707 USHORT threadcnt;
708 ULONG privsem32cnt;
709 ULONG _reserved2_;
710 USHORT sem16cnt;
711 USHORT dllcnt;
712 USHORT shrmemcnt;
713 USHORT fdscnt;
714 PUSHORT sem16s;
715 PUSHORT dlls;
716 PUSHORT shrmems;
717 PUSHORT fds;
718} QPROCESS, *PQPROCESS;
719
720typedef struct sema {
721 struct sema *next;
722 USHORT refcnt;
723 UCHAR sysflags;
724 UCHAR sysproccnt;
725 ULONG _reserved1_;
726 USHORT index;
727 CHAR name[1];
728} QSEMA, *PQSEMA;
729
730typedef struct {
731 ULONG rectype;
732 ULONG _reserved1_;
733 USHORT _reserved2_;
734 USHORT syssemidx;
735 ULONG index;
736 QSEMA sema;
737} QSEMSTRUC, *PQSEMSTRUC;
738
739typedef struct {
740 USHORT pid;
741 USHORT opencnt;
742} QSEMOWNER32, *PQSEMOWNER32;
743
744typedef struct {
745 PQSEMOWNER32 own;
746 PCHAR name;
747 PVOID semrecs; /* array of associated sema's */
748 USHORT flags;
749 USHORT semreccnt;
750 USHORT waitcnt;
751 USHORT _reserved_; /* padding to ULONG */
752} QSEMSMUX32, *PQSEMSMUX32;
753
754typedef struct {
755 PQSEMOWNER32 own;
756 PCHAR name;
757 PQSEMSMUX32 mux;
758 USHORT flags;
759 USHORT postcnt;
760} QSEMEV32, *PQSEMEV32;
761
762typedef struct {
763 PQSEMOWNER32 own;
764 PCHAR name;
765 PQSEMSMUX32 mux;
766 USHORT flags;
767 USHORT refcnt;
768 USHORT thrdnum;
769 USHORT _reserved_; /* padding to ULONG */
770} QSEMMUX32, *PQSEMMUX32;
771
772typedef struct semstr32 {
773 struct semstr *next;
774 QSEMEV32 evsem;
775 QSEMMUX32 muxsem;
776 QSEMSMUX32 smuxsem;
777} QSEMSTRUC32, *PQSEMSTRUC32;
778
779typedef struct shrmem {
780 struct shrmem *next;
781 USHORT hndshr;
782 USHORT selshr;
783 USHORT refcnt;
784 CHAR name[1];
785} QSHRMEM, *PQSHRMEM;
786
787typedef struct module {
788 struct module *next;
789 USHORT hndmod;
790 USHORT type;
791 ULONG refcnt;
792 ULONG segcnt;
793 PVOID _reserved_;
794 PCHAR name;
795 USHORT modref[1];
796} QMODULE, *PQMODULE;
797
798typedef struct {
799 PQGLOBAL gbldata;
800 PQPROCESS procdata;
801 PQSEMSTRUC semadata;
802 PQSEMSTRUC32 sem32data;
803 PQSHRMEM shrmemdata;
804 PQMODULE moddata;
805 PVOID _reserved2_;
806 PQFILE filedata;
807} QTOPLEVEL, *PQTOPLEVEL;
808/* ************************************************************ */
809
810PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
811
812#endif /* _OS2_H */
813