3 /* #include <sys/select.h> */
6 * This symbol, if defined, indicates that the ioctl() routine is
7 * available to set I/O characteristics
12 * This symbol, if defined, indicates that the routine utime() is
13 * available to update the access and modification times of files.
15 #define HAS_UTIME /**/
20 #define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
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.
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.
35 #define HAS_GETGRENT /* fake */
36 #define HAS_SETGRENT /* fake */
37 #define HAS_ENDGRENT /* fake */
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.
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
53 #define Stat_t struct stat
56 * This symbol is defined if this system has a stat structure declaring
59 #define USE_STAT_RDEV /**/
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.
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.)
78 #define ALTERNATE_SHEBANG "extproc "
81 # define SIGABRT SIGILL
84 # define SIGILL 6 /* blech */
86 #define ABORT() kill(PerlProc_getpid(),SIGABRT);
88 #define BIT_BUCKET "/dev/nul" /* Will this work? */
90 /* Apparently TCPIPV4 defines may be included even with only IAK present */
92 #if !defined(NO_TCPIPV4) && !defined(TCPIPV4)
94 # define TCPIPV4_FORCED /* Just in case */
97 #if defined(I_SYS_UN) && !defined(TCPIPV4)
98 /* It is not working without TCPIPV4 defined. */
104 #define do_spawn(a) os2_do_spawn(aTHX_ (a))
105 #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
107 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
111 #define MUTEX_INIT(m) \
114 if ((rc = _rmutex_create(m,0))) \
115 Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \
117 #define MUTEX_LOCK(m) \
120 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
121 Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \
123 #define MUTEX_UNLOCK(m) \
126 if ((rc = _rmutex_release(m))) \
127 Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \
129 #define MUTEX_DESTROY(m) \
132 if ((rc = _rmutex_close(m))) \
133 Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \
136 #define COND_INIT(c) \
139 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
140 Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \
142 #define COND_SIGNAL(c) \
145 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
146 Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \
148 #define COND_BROADCAST(c) \
151 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
152 Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \
154 /* #define COND_WAIT(c, m) \
156 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
157 Perl_croak_nocontext("panic: COND_WAIT"); \
160 #define COND_WAIT(c, m) os2_cond_wait(c,m)
162 #define COND_WAIT_win32(c, m) \
165 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \
166 Perl_croak_nocontext("panic: COND_WAIT"); \
170 #define COND_DESTROY(c) \
173 if ((rc = DosCloseEventSem(*(c)))) \
174 Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \
176 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
179 #ifdef USE_SLOW_THREAD_SPECIFIC
180 # define pthread_getspecific(k) (*_threadstore())
181 # define pthread_setspecific(k,v) (*_threadstore()=v,0)
182 # define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
183 #else /* USE_SLOW_THREAD_SPECIFIC */
184 # define pthread_getspecific(k) (*(k))
185 # define pthread_setspecific(k,v) (*(k)=(v),0)
186 # define pthread_key_create(keyp,flag) \
187 ( DosAllocThreadLocalMemory(1,(unsigned long**)keyp) \
188 ? Perl_croak_nocontext("LocalMemory"),1 \
191 #endif /* USE_SLOW_THREAD_SPECIFIC */
192 #define pthread_key_delete(keyp)
193 #define pthread_self() _gettid()
194 #define YIELD DosSleep(0)
196 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
197 int pthread_join(pthread_t tid, void **status);
198 int pthread_detach(pthread_t tid);
199 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
200 void *(*start_routine)(void*), void *arg);
201 #endif /* PTHREAD_INCLUDED */
203 #define THREADS_ELSEWHERE
205 #else /* USE_ITHREADS */
207 #define do_spawn(a) os2_do_spawn(a)
208 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
210 void Perl_OS2_init(char **);
211 void Perl_OS2_init3(char **envp, void **excH, int flags);
212 void Perl_OS2_term(void **excH, int exitstatus, int flags);
214 /* The code without INIT3 hideously puts env inside: */
216 /* These ones should be in the same block as PERL_SYS_TERM() */
219 # define PERL_SYS_INIT3(argcp, argvp, envp) \
221 _response(argcp, argvp); \
222 _wildcard(argcp, argvp); \
223 Perl_OS2_init3(*envp, xreg, 0)
225 # define PERL_SYS_INIT(argcp, argvp) { \
227 _response(argcp, argvp); \
228 _wildcard(argcp, argvp); \
229 Perl_OS2_init3(NULL, xreg, 0)
231 #else /* Compiling embedded Perl or Perl extension */
233 # define PERL_SYS_INIT3(argcp, argvp, envp) \
235 Perl_OS2_init3(*envp, xreg, 0)
236 # define PERL_SYS_INIT(argcp, argvp) { \
238 Perl_OS2_init3(NULL, xreg, 0)
241 #define FORCE_EMX_DEINIT_EXIT 1
242 #define FORCE_EMX_DEINIT_CRT_TERM 2
243 #define FORCE_EMX_DEINIT_RUN_ATEXIT 4
245 #define PERL_SYS_TERM2(xreg,flags) \
246 Perl_OS2_term(xreg, 0, flags); \
249 #define PERL_SYS_TERM1(xreg) \
250 Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT)
252 /* This one should come in pair with PERL_SYS_INIT() and in the same block */
253 #define PERL_SYS_TERM() \
254 PERL_SYS_TERM1(xreg); \
258 # define PERL_CALLCONV _System
261 /* #define PERL_SYS_TERM() STMT_START { \
262 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
264 #define dXSUB_SYS OS2_XS_init()
267 /* # define HAS_FORK */
268 /* # define HIDEMYMALLOC */
269 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
270 #else /* !PERL_IS_AOUT */
271 # ifndef PERL_FOR_X2P
273 # define USE_PERL_SBRK
278 # define SYSTEM_ALLOC(a) sys_alloc(a)
280 void *sys_alloc(int size);
282 #endif /* !PERL_IS_AOUT */
283 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
287 /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
288 * defined. Hack around this to get us to compile.
299 #define TMPPATH1 "plXXXXXX"
300 extern const char *tmppath;
301 PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
302 /* Cannot prototype with I32 at this point. */
303 int my_syspclose(PerlIO *f);
304 FILE *my_tmpfile (void);
305 char *my_tmpnam (char *);
306 int my_mkdir (__const__ char *, long);
307 int my_rmdir (__const__ char *);
308 struct passwd *my_getpwent (void);
309 void my_setpwent (void);
310 void my_endpwent (void);
311 char *gcvt_os2(double value, int digits, char *buffer);
313 #define MAX_SLEEP (((1<30) / (1000/4))-1) /* 1<32 msec */
315 static __inline__ unsigned
316 my_sleep(unsigned sec)
319 while (sec > MAX_SLEEP) {
321 remain = sleep(MAX_SLEEP);
328 #define sleep my_sleep
331 unsigned long DosSleep(unsigned long);
332 unsigned long DosAllocThreadLocalMemory (unsigned long cb, unsigned long **p);
335 struct group *getgrent (void);
336 void setgrent (void);
337 void endgrent (void);
339 struct passwd *my_getpwuid (uid_t);
340 struct passwd *my_getpwnam (__const__ char *);
343 #define L_tmpnam MAXPATHLEN
345 #define tmpfile my_tmpfile
346 #define tmpnam my_tmpnam
347 #define isatty _isterm
349 #define srand srandom
350 #define strtoll _strtoll
351 #define strtoull _strtoull
353 #define usleep(usec) ((void)_sleep2(((usec)+500)/1000))
357 * fwrite1() should be a routine with the same calling sequence as fwrite(),
358 * but which outputs all of the bytes requested as a single stream (unlike
359 * fwrite() itself, which on some systems outputs several distinct records
360 * if the number_of_items parameter is >1).
362 #define fwrite1 fwrite
364 #define my_getenv(var) getenv(var)
365 #define flock my_flock
366 #define rmdir my_rmdir
367 #define mkdir my_mkdir
368 #define setpwent my_setpwent
369 #define getpwent my_getpwent
370 #define endpwent my_endpwent
371 #define getpwuid my_getpwuid
372 #define getpwnam my_getpwnam
374 void *emx_calloc (size_t, size_t);
375 void emx_free (void *);
376 void *emx_malloc (size_t);
377 void *emx_realloc (void *, size_t);
379 /*****************************************************************************/
381 #include <stdlib.h> /* before the following definitions */
382 #include <unistd.h> /* before the following definitions */
384 #include <sys/stat.h>
386 #define chdir _chdir2
387 #define getcwd _getcwd2
389 /* This guy is needed for quick stdstd */
391 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
392 /* Perl uses ungetc only with successful return */
393 # define ungetc(c,fp) \
394 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
395 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
398 #define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
408 #include <emx/io.h> /* for _fd_flags() prototype */
411 _PERLIO_IS_BINMODE_FD(int fd)
413 int *pflags = _fd_flags(fd);
415 return pflags && (*pflags) & O_BINARY;
418 /* ctermid is missing from emx0.9d */
419 char *ctermid(char *s);
421 #define OP_BINARY O_BINARY
423 #define OS2_STAT_HACK 1
426 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
427 #define Fstat(fd,bufptr) os2_fstat((fd),(bufptr))
428 #define Fflush(fp) fflush(fp)
429 #define Mkdir(path,mode) mkdir((path),(mode))
430 #define chmod(path,mode) os2_chmod((path),(mode))
434 #define S_IFBLK 0120000 /* Hacks to make things compile... */
435 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
437 int os2_chmod(const char *name, int pmode);
438 int os2_fstat(int handle, struct stat *st);
442 #define Stat(fname,bufptr) stat((fname),(bufptr))
443 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
444 #define Fflush(fp) fflush(fp)
445 #define Mkdir(path,mode) mkdir((path),(mode))
449 /* With SD386 it is impossible to debug register variables. */
450 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
454 /* Our private OS/2 specific data. */
456 typedef struct OS2_Perl_data {
461 unsigned long severity;
462 unsigned long phmq; /* Handle to message queue */
463 unsigned long phmq_refcnt;
464 unsigned long phmq_servers;
465 unsigned long initial_mode; /* VIO etc. mode we were started in */
466 unsigned long morph_refcnt;
469 extern OS2_Perl_data_t OS2_Perl_data;
471 #define Perl_hab ((HAB)OS2_Perl_data.phab)
472 #define Perl_rc (OS2_Perl_data.rc)
473 #define Perl_severity (OS2_Perl_data.severity)
474 #define errno_isOS2 12345678
475 #define errno_isOS2_set 12345679
476 #define OS2_Perl_flags (OS2_Perl_data.flags)
477 #define Perl_HAB_set_f 1
478 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
479 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
480 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
481 #define _obtain_Perl_HAB (init_PMWIN_entries(), \
482 Perl_hab = (*PMWIN_entries.Initialize)(0), \
483 set_Perl_HAB_f, Perl_hab)
484 #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
485 #define Acquire_hab() perl_hab_GET()
486 #define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
487 #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
488 #define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
489 #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
490 #define Perl_morph_refcnt (OS2_Perl_data.morph_refcnt)
492 unsigned long Perl_hab_GET();
493 unsigned long Perl_Register_MQ(int serve);
494 void Perl_Deregister_MQ(int serve);
495 int Perl_Serve_Messages(int force);
496 /* Cannot prototype with I32 at this point. */
497 int Perl_Process_Messages(int force, long *cntp);
498 char *os2_execname(pTHX);
501 struct PMWIN_entries_t {
502 unsigned long (*Initialize)( unsigned long fsOptions );
503 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
504 int (*DestroyMsgQueue)(unsigned long hmq);
505 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
506 unsigned long hwndFilter, unsigned long msgFilterFirst,
507 unsigned long msgFilterLast, unsigned long fl);
508 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
509 unsigned long hwndFilter, unsigned long msgFilterFirst,
510 unsigned long msgFilterLast);
511 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
512 unsigned long (*GetLastError)(unsigned long hab);
513 unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways);
515 extern struct PMWIN_entries_t PMWIN_entries;
516 void init_PMWIN_entries(void);
518 #define perl_hmq_GET(serve) Perl_Register_MQ(serve)
519 #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
521 #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
523 #if _EMX_CRT_REV_ >= 60
524 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
527 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
530 /* The expressions below return true on error. */
531 /* INCL_DOSERRORS needed. rc should be declared outside. */
532 #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
533 /* INCL_WINERRORS needed. */
534 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
536 /* This form propagates the return value, setting $^E if needed */
537 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
539 /* This form propagates the return value, dieing with $^E if needed */
540 #define SaveCroakWinError(expr,die,name1,name2) \
541 ((expr) ? : (CroakWinError(die,name1 name2), 0))
543 #define FillOSError(rc) (os2_setsyserrno(rc), \
544 Perl_severity = SEVERITY_ERROR)
546 #define WinError_2_Perl_rc \
547 ( init_PMWIN_entries(), \
548 Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()) )
550 /* Calling WinGetLastError() resets the error code of the current thread.
551 Since for some Win* API return value 0 is normal, one needs to call
552 this before calling them to distinguish normal and anomalous returns. */
553 /*#define ResetWinError() WinError_2_Perl_rc */
555 /* At this moment init_PMWIN_entries() should be a nop (WinInitialize should
556 be called already, right?), so we do not risk stepping over our own error */
557 #define FillWinError ( WinError_2_Perl_rc, \
558 Perl_severity = ERRORIDSEV(Perl_rc), \
559 Perl_rc = ERRORIDERROR(Perl_rc), \
560 os2_setsyserrno(Perl_rc))
562 #define STATIC_FILE_LENGTH 127
564 /* This should match loadOrdinals[] array in os2.c */
565 enum entries_ordinals {
566 ORD_DosQueryExtLibpath,
567 ORD_DosSetExtLibpath,
582 ORD_WinCreateMsgQueue,
583 ORD_WinDestroyMsgQueue,
588 ORD_WinCancelShutdown,
590 ORD_RexxVariablePool,
591 ORD_RexxRegisterFunctionExe,
592 ORD_RexxDeregisterFunction,
594 ORD_PRF32QUERYPROFILESIZE,
595 ORD_PRF32OPENPROFILE,
596 ORD_PRF32CLOSEPROFILE,
597 ORD_PRF32QUERYPROFILE,
599 ORD_PRF32QUERYPROFILEDATA,
600 ORD_PRF32WRITEPROFILEDATA,
602 ORD_WinChangeSwitchEntry,
603 ORD_WinQuerySwitchEntry,
604 ORD_WinQuerySwitchHandle,
605 ORD_WinQuerySwitchList,
606 ORD_WinSwitchToProgram,
607 ORD_WinBeginEnumWindows,
608 ORD_WinEndEnumWindows,
610 ORD_WinGetNextWindow,
612 ORD_WinQueryActiveWindow,
613 ORD_WinQueryClassName,
616 ORD_WinQueryWindowPos,
617 ORD_WinQueryWindowProcess,
618 ORD_WinQueryWindowText,
619 ORD_WinQueryWindowTextLength,
622 ORD_WinSetWindowText,
626 ORD_WinWindowFromPoint,
629 ORD_WinEnableWindowUpdate,
630 ORD_WinIsWindowEnabled,
631 ORD_WinIsWindowShowing,
632 ORD_WinIsWindowVisible,
633 ORD_WinQueryWindowPtr,
634 ORD_WinQueryWindowULong,
635 ORD_WinQueryWindowUShort,
636 ORD_WinSetWindowBits,
638 ORD_WinSetWindowULong,
639 ORD_WinSetWindowUShort,
640 ORD_WinQueryDesktopWindow,
641 ORD_WinSetActiveWindow,
642 ORD_DosQueryModFromEIP,
643 ORD_Dos32QueryHeaderInfo,
646 ORD_WinQueryActiveDesktopPathname,
647 ORD_WinInvalidateRect,
648 ORD_WinCreateFrameControls,
649 ORD_WinQueryClipbrdFmtInfo,
650 ORD_WinQueryClipbrdOwner,
651 ORD_WinQueryClipbrdViewer,
652 ORD_WinQueryClipbrdData,
655 ORD_WinSetClipbrdData,
656 ORD_WinSetClipbrdOwner,
657 ORD_WinSetClipbrdViewer,
658 ORD_WinEnumClipbrdFmts,
663 ORD_WinQueryAtomUsage,
664 ORD_WinQueryAtomName,
665 ORD_WinQueryAtomLength,
666 ORD_WinQuerySystemAtomTable,
667 ORD_WinCreateAtomTable,
668 ORD_WinDestroyAtomTable,
675 ORD_WinQuerySysValue,
680 ORD_WinQuerySysPointer,
684 /* RET: return type, AT: argument signature in (), ARGS: should be in () */
685 #define CallORD(ret,o,at,args) (((ret (*)at) loadByOrdinal(o, 1))args)
686 #define DeclFuncByORD(ret,name,o,at,args) \
687 ret name at { return CallORD(ret,o,at,args); }
688 #define DeclVoidFuncByORD(name,o,at,args) \
689 void name at { CallORD(void,o,at,args); }
691 /* These functions return false on error, and save the error info in $^E */
692 #define DeclOSFuncByORD(ret,name,o,at,args) \
693 ret name at { unsigned long rc; return !CheckOSError(CallORD(ret,o,at,args)); }
694 #define DeclWinFuncByORD(ret,name,o,at,args) \
695 ret name at { return SaveWinError(CallORD(ret,o,at,args)); }
697 #define AssignFuncPByORD(p,o) (*(Perl_PFN*)&(p) = (loadByOrdinal(o, 1)))
699 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
700 #define DeclWinFuncByORD_CACHE(ret,name,o,at,args) \
701 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,1)
703 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
704 #define DeclWinFuncByORD_CACHE_resetError(ret,name,o,at,args) \
705 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,1)
707 /* Two flavors below do the same as above, but do not auto-croak */
708 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
709 #define DeclWinFuncByORD_CACHE_survive(ret,name,o,at,args) \
710 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,0)
712 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
713 #define DeclWinFuncByORD_CACHE_resetError_survive(ret,name,o,at,args) \
714 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,0)
716 #define DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,r,die) \
717 static ret (*CAT2(p__Win,name)) at; \
718 static ret name at { \
719 if (!CAT2(p__Win,name)) \
720 AssignFuncPByORD(CAT2(p__Win,name), o); \
721 if (r) ResetWinError(); \
722 return SaveCroakWinError(CAT2(p__Win,name) args, die, "[Win]", STRINGIFY(name)); }
724 /* These flavors additionally assume ORD is name with prepended ORD_Win */
725 #define DeclWinFunc_CACHE(ret,name,at,args) \
726 DeclWinFuncByORD_CACHE(ret,name,CAT2(ORD_Win,name),at,args)
727 #define DeclWinFunc_CACHE_resetError(ret,name,at,args) \
728 DeclWinFuncByORD_CACHE_resetError(ret,name,CAT2(ORD_Win,name),at,args)
729 #define DeclWinFunc_CACHE_survive(ret,name,at,args) \
730 DeclWinFuncByORD_CACHE_survive(ret,name,CAT2(ORD_Win,name),at,args)
731 #define DeclWinFunc_CACHE_resetError_survive(ret,name,at,args) \
732 DeclWinFuncByORD_CACHE_resetError_survive(ret,name,CAT2(ORD_Win,name),at,args)
734 void ResetWinError(void);
735 void CroakWinError(int die, char *name);
737 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
738 char *perllib_mangle(char *, unsigned int);
740 #define fork fork_with_resources
742 static __inline__ int
743 my_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
745 if (nfds == 0 && timeout && (_emx_env & 0x200)) {
746 if (DosSleep(1000 * timeout->tv_sec + (timeout->tv_usec + 500)/1000) == 0)
751 return select(nfds, readfds, writefds, exceptfds, timeout);
754 #define select my_select
757 typedef int (*Perl_PFN)();
758 Perl_PFN loadByOrdinal(enum entries_ordinals ord, int fail);
759 extern const Perl_PFN * const pExtFCN;
760 char *os2error(int rc);
761 int os2_stat(const char *name, struct stat *st);
762 int fork_with_resources();
763 int setpriority(int which, int pid, int val);
764 int getpriority(int which /* ignored */, int pid);
766 void croak_with_os2error(char *s) __attribute__((noreturn));
769 int os2_do_spawn(pTHX_ char *cmd);
770 int os2_do_aspawn(pTHX_ SV *really, SV **vmark, SV **vsp);
775 /* Replacement for syslog.h */
776 # define LOG_EMERG 0 /* system is unusable */
777 # define LOG_ALERT 1 /* action must be taken immediately */
778 # define LOG_CRIT 2 /* critical conditions */
779 # define LOG_ERR 3 /* error conditions */
780 # define LOG_WARNING 4 /* warning conditions */
781 # define LOG_NOTICE 5 /* normal but significant condition */
782 # define LOG_INFO 6 /* informational */
783 # define LOG_DEBUG 7 /* debug-level messages */
785 # define LOG_PRIMASK 0x007 /* mask to extract priority part (internal) */
786 /* extract priority */
787 # define LOG_PRI(p) ((p) & LOG_PRIMASK)
788 # define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
791 # define LOG_KERN (0<<3) /* kernel messages */
792 # define LOG_USER (1<<3) /* random user-level messages */
793 # define LOG_MAIL (2<<3) /* mail system */
794 # define LOG_DAEMON (3<<3) /* system daemons */
795 # define LOG_AUTH (4<<3) /* security/authorization messages */
796 # define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
797 # define LOG_LPR (6<<3) /* line printer subsystem */
798 # define LOG_NEWS (7<<3) /* network news subsystem */
799 # define LOG_UUCP (8<<3) /* UUCP subsystem */
800 # define LOG_CRON (15<<3) /* clock daemon */
801 /* other codes through 15 reserved for system use */
802 # define LOG_LOCAL0 (16<<3) /* reserved for local use */
803 # define LOG_LOCAL1 (17<<3) /* reserved for local use */
804 # define LOG_LOCAL2 (18<<3) /* reserved for local use */
805 # define LOG_LOCAL3 (19<<3) /* reserved for local use */
806 # define LOG_LOCAL4 (20<<3) /* reserved for local use */
807 # define LOG_LOCAL5 (21<<3) /* reserved for local use */
808 # define LOG_LOCAL6 (22<<3) /* reserved for local use */
809 # define LOG_LOCAL7 (23<<3) /* reserved for local use */
811 # define LOG_NFACILITIES 24 /* current number of facilities */
812 # define LOG_FACMASK 0x03f8 /* mask to extract facility part */
813 /* facility of pri */
814 # define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
817 * arguments to setlogmask.
819 # define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
820 # define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
823 * Option flags for openlog.
825 * LOG_ODELAY no longer does anything.
826 * LOG_NDELAY is the inverse of what it used to be.
828 # define LOG_PID 0x01 /* log the pid with each message */
829 # define LOG_CONS 0x02 /* log on the console if errors in sending */
830 # define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
831 # define LOG_NDELAY 0x08 /* don't delay open */
832 # define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
833 # define LOG_PERROR 0x20 /* log to stderr as well */
837 /* ************************************************************ */
838 #define Dos32QuerySysState DosQuerySysState
839 #define QuerySysState(flags, pid, buf, bufsz) \
840 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
842 #define QSS_PROCESS 1
844 #define QSS_SEMAPHORES 2
845 #define QSS_FILE 8 /* Buggy until fixpack18 */
846 #define QSS_SHARED 16
850 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
851 ULONG _res_,PVOID buf,ULONG bufsz);
856 } QGLOBAL, *PQGLOBAL;
867 UCHAR _reserved1_; /* padding to ULONG */
868 USHORT _reserved2_; /* padding to ULONG */
869 } QTHREAD, *PQTHREAD;
884 typedef struct qfile {
912 } QPROCESS, *PQPROCESS;
914 typedef struct sema {
931 } QSEMSTRUC, *PQSEMSTRUC;
936 } QSEMOWNER32, *PQSEMOWNER32;
941 PVOID semrecs; /* array of associated sema's */
945 USHORT _reserved_; /* padding to ULONG */
946 } QSEMSMUX32, *PQSEMSMUX32;
954 } QSEMEV32, *PQSEMEV32;
963 USHORT _reserved_; /* padding to ULONG */
964 } QSEMMUX32, *PQSEMMUX32;
966 typedef struct semstr32 {
971 } QSEMSTRUC32, *PQSEMSTRUC32;
973 typedef struct shrmem {
979 } QSHRMEM, *PQSHRMEM;
981 typedef struct module {
990 } QMODULE, *PQMODULE;
996 PQSEMSTRUC32 sem32data;
1001 } QTOPLEVEL, *PQTOPLEVEL;
1002 /* ************************************************************ */
1004 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);