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 /**/
18 * This symbol is defined if Time_t is an unsigned type on this system.
25 #define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
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.
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.
40 #define HAS_GETGRENT /* fake */
41 #define HAS_SETGRENT /* fake */
42 #define HAS_ENDGRENT /* fake */
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.
52 #define SOCKET_OPEN_MODE "b"
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
60 #define Stat_t struct stat
63 * This symbol is defined if this system has a stat structure declaring
66 #define USE_STAT_RDEV /**/
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.
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 if 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.)
85 #define ALTERNATE_SHEBANG "extproc "
88 # define SIGABRT SIGILL
91 # define SIGILL 6 /* blech */
93 #define ABORT() kill(PerlProc_getpid(),SIGABRT);
95 #define BIT_BUCKET "/dev/nul" /* Will this work? */
97 /* Apparently TCPIPV4 defines may be included even with only IAK present */
99 #if !defined(NO_TCPIPV4) && !defined(TCPIPV4)
101 # define TCPIPV4_FORCED /* Just in case */
104 #if defined(I_SYS_UN) && !defined(TCPIPV4)
105 /* It is not working without TCPIPV4 defined. */
111 #define do_spawn(a) os2_do_spawn(aTHX_ (a))
112 #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
114 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
118 #define MUTEX_INIT(m) \
121 if ((rc = _rmutex_create(m,0))) \
122 Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \
124 #define MUTEX_LOCK(m) \
127 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
128 Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \
130 #define MUTEX_UNLOCK(m) \
133 if ((rc = _rmutex_release(m))) \
134 Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \
136 #define MUTEX_DESTROY(m) \
139 if ((rc = _rmutex_close(m))) \
140 Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \
143 #define COND_INIT(c) \
146 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
147 Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \
149 #define COND_SIGNAL(c) \
152 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
153 Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \
155 #define COND_BROADCAST(c) \
158 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
159 Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \
161 /* #define COND_WAIT(c, m) \
163 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
164 Perl_croak_nocontext("panic: COND_WAIT"); \
167 #define COND_WAIT(c, m) os2_cond_wait(c,m)
169 #define COND_WAIT_win32(c, m) \
172 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \
173 Perl_croak_nocontext("panic: COND_WAIT"); \
177 #define COND_DESTROY(c) \
180 if ((rc = DosCloseEventSem(*(c)))) \
181 Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \
183 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
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 ? Perl_croak_nocontext("LocalMemory"),1 \
198 #endif /* USE_SLOW_THREAD_SPECIFIC */
199 #define pthread_key_delete(keyp)
200 #define pthread_self() _gettid()
201 #define YIELD DosSleep(0)
203 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
204 int pthread_join(pthread_t tid, void **status);
205 int pthread_detach(pthread_t tid);
206 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
207 void *(*start_routine)(void*), void *arg);
208 #endif /* PTHREAD_INCLUDED */
210 #define THREADS_ELSEWHERE
212 #else /* USE_ITHREADS */
214 #define do_spawn(a) os2_do_spawn(a)
215 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
217 void Perl_OS2_init(char **);
218 void Perl_OS2_init3(char **envp, void **excH, int flags);
219 void Perl_OS2_term(void **excH, int exitstatus, int flags);
221 /* The code without INIT3 hideously puts env inside: */
223 /* These ones should be in the same block as PERL_SYS_TERM() */
226 # define PERL_SYS_INIT3(argcp, argvp, envp) \
228 MALLOC_CHECK_TAINT(*argcp, *argvp, *envp) \
229 _response(argcp, argvp); \
230 _wildcard(argcp, argvp); \
231 Perl_OS2_init3(*envp, xreg, 0)
233 # define PERL_SYS_INIT(argcp, argvp) { \
235 _response(argcp, argvp); \
236 _wildcard(argcp, argvp); \
237 Perl_OS2_init3(NULL, xreg, 0)
239 #else /* Compiling embedded Perl or Perl extension */
241 # define PERL_SYS_INIT3(argcp, argvp, envp) \
243 Perl_OS2_init3(*envp, xreg, 0)
244 # define PERL_SYS_INIT(argcp, argvp) { \
246 Perl_OS2_init3(NULL, xreg, 0)
249 #define FORCE_EMX_DEINIT_EXIT 1
250 #define FORCE_EMX_DEINIT_CRT_TERM 2
251 #define FORCE_EMX_DEINIT_RUN_ATEXIT 4
253 #define PERL_SYS_TERM2(xreg,flags) \
254 Perl_OS2_term(xreg, 0, flags); \
257 #define PERL_SYS_TERM1(xreg) \
258 Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT)
260 /* This one should come in pair with PERL_SYS_INIT() and in the same block */
261 #define PERL_SYS_TERM() \
262 PERL_SYS_TERM1(xreg); \
266 # define PERL_CALLCONV _System
269 /* #define PERL_SYS_TERM() STMT_START { \
270 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
272 #define dXSUB_SYS OS2_XS_init()
275 /* # define HAS_FORK */
276 /* # define HIDEMYMALLOC */
277 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
278 #else /* !PERL_IS_AOUT */
279 # ifndef PERL_FOR_X2P
281 # define USE_PERL_SBRK
286 # define SYSTEM_ALLOC(a) sys_alloc(a)
288 void *sys_alloc(int size);
290 #endif /* !PERL_IS_AOUT */
291 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
295 /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
296 * defined. Hack around this to get us to compile.
307 #define TMPPATH1 "plXXXXXX"
308 extern const char *tmppath;
309 PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
310 /* Cannot prototype with I32 at this point. */
311 int my_syspclose(PerlIO *f);
312 FILE *my_tmpfile (void);
313 char *my_tmpnam (char *);
314 int my_mkdir (__const__ char *, long);
315 int my_rmdir (__const__ char *);
316 struct passwd *my_getpwent (void);
317 void my_setpwent (void);
318 void my_endpwent (void);
319 char *gcvt_os2(double value, int digits, char *buffer);
321 #define MAX_SLEEP (((1<30) / (1000/4))-1) /* 1<32 msec */
323 static __inline__ unsigned
324 my_sleep(unsigned sec)
327 while (sec > MAX_SLEEP) {
329 remain = sleep(MAX_SLEEP);
336 #define sleep my_sleep
339 unsigned long DosSleep(unsigned long);
340 unsigned long DosAllocThreadLocalMemory (unsigned long cb, unsigned long **p);
343 struct group *getgrent (void);
344 void setgrent (void);
345 void endgrent (void);
347 struct passwd *my_getpwuid (uid_t);
348 struct passwd *my_getpwnam (__const__ char *);
351 #define L_tmpnam MAXPATHLEN
353 #define tmpfile my_tmpfile
354 #define tmpnam my_tmpnam
355 #define isatty _isterm
357 #define srand srandom
358 #define strtoll _strtoll
359 #define strtoull _strtoull
361 #define usleep(usec) ((void)_sleep2(((usec)+500)/1000))
365 * fwrite1() should be a routine with the same calling sequence as fwrite(),
366 * but which outputs all of the bytes requested as a single stream (unlike
367 * fwrite() itself, which on some systems outputs several distinct records
368 * if the number_of_items parameter is >1).
370 #define fwrite1 fwrite
372 #define my_getenv(var) getenv(var)
373 #define flock my_flock
374 #define rmdir my_rmdir
375 #define mkdir my_mkdir
376 #define setpwent my_setpwent
377 #define getpwent my_getpwent
378 #define endpwent my_endpwent
379 #define getpwuid my_getpwuid
380 #define getpwnam my_getpwnam
382 void *emx_calloc (size_t, size_t);
383 void emx_free (void *);
384 void *emx_malloc (size_t);
385 void *emx_realloc (void *, size_t);
387 /*****************************************************************************/
389 #include <stdlib.h> /* before the following definitions */
390 #include <unistd.h> /* before the following definitions */
392 #include <sys/stat.h>
394 #define chdir _chdir2
395 #define getcwd _getcwd2
397 /* This guy is needed for quick stdstd */
399 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
400 /* Perl uses ungetc only with successful return */
401 # define ungetc(c,fp) \
402 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
403 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
406 #define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
416 #include <emx/io.h> /* for _fd_flags() prototype */
419 _PERLIO_IS_BINMODE_FD(int fd)
421 int *pflags = _fd_flags(fd);
423 return pflags && (*pflags) & O_BINARY;
426 /* ctermid is missing from emx0.9d */
427 char *ctermid(char *s);
429 #define OP_BINARY O_BINARY
431 #define OS2_STAT_HACK 1
434 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
435 #define Fstat(fd,bufptr) os2_fstat((fd),(bufptr))
436 #define Fflush(fp) fflush(fp)
437 #define Mkdir(path,mode) mkdir((path),(mode))
438 #define chmod(path,mode) os2_chmod((path),(mode))
442 #define S_IFBLK 0120000 /* Hacks to make things compile... */
443 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
445 int os2_chmod(const char *name, int pmode);
446 int os2_fstat(int handle, struct stat *st);
450 #define Stat(fname,bufptr) stat((fname),(bufptr))
451 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
452 #define Fflush(fp) fflush(fp)
453 #define Mkdir(path,mode) mkdir((path),(mode))
457 /* With SD386 it is impossible to debug register variables. */
458 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
462 /* Our private OS/2 specific data. */
464 typedef struct OS2_Perl_data {
469 unsigned long severity;
470 unsigned long phmq; /* Handle to message queue */
471 unsigned long phmq_refcnt;
472 unsigned long phmq_servers;
473 unsigned long initial_mode; /* VIO etc. mode we were started in */
474 unsigned long morph_refcnt;
477 extern OS2_Perl_data_t OS2_Perl_data;
479 #define Perl_hab ((HAB)OS2_Perl_data.phab)
480 #define Perl_rc (OS2_Perl_data.rc)
481 #define Perl_severity (OS2_Perl_data.severity)
482 #define errno_isOS2 12345678
483 #define errno_isOS2_set 12345679
484 #define OS2_Perl_flags (OS2_Perl_data.flags)
485 #define Perl_HAB_set_f 1
486 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
487 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
488 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
489 #define _obtain_Perl_HAB (init_PMWIN_entries(), \
490 Perl_hab = (*PMWIN_entries.Initialize)(0), \
491 set_Perl_HAB_f, Perl_hab)
492 #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
493 #define Acquire_hab() perl_hab_GET()
494 #define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
495 #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
496 #define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
497 #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
498 #define Perl_morph_refcnt (OS2_Perl_data.morph_refcnt)
500 unsigned long Perl_hab_GET();
501 unsigned long Perl_Register_MQ(int serve);
502 void Perl_Deregister_MQ(int serve);
503 int Perl_Serve_Messages(int force);
504 /* Cannot prototype with I32 at this point. */
505 int Perl_Process_Messages(int force, long *cntp);
506 char *os2_execname(pTHX);
509 struct PMWIN_entries_t {
510 unsigned long (*Initialize)( unsigned long fsOptions );
511 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
512 int (*DestroyMsgQueue)(unsigned long hmq);
513 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
514 unsigned long hwndFilter, unsigned long msgFilterFirst,
515 unsigned long msgFilterLast, unsigned long fl);
516 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
517 unsigned long hwndFilter, unsigned long msgFilterFirst,
518 unsigned long msgFilterLast);
519 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
520 unsigned long (*GetLastError)(unsigned long hab);
521 unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways);
523 extern struct PMWIN_entries_t PMWIN_entries;
524 void init_PMWIN_entries(void);
526 #define perl_hmq_GET(serve) Perl_Register_MQ(serve)
527 #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
529 #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
531 #if _EMX_CRT_REV_ >= 60
532 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
535 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
538 /* The expressions below return true on error. */
539 /* INCL_DOSERRORS needed. rc should be declared outside. */
540 #define CheckOSError(expr) ((rc = (expr)) ? (FillOSError(rc), rc) : 0)
541 /* INCL_WINERRORS needed. */
542 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
544 /* This form propagates the return value, setting $^E if needed */
545 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
547 /* This form propagates the return value, dieing with $^E if needed */
548 #define SaveCroakWinError(expr,die,name1,name2) \
549 ((expr) ? : (CroakWinError(die,name1 name2), 0))
551 #define FillOSError(rc) (os2_setsyserrno(rc), \
552 Perl_severity = SEVERITY_ERROR)
554 #define WinError_2_Perl_rc \
555 ( init_PMWIN_entries(), \
556 Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()) )
558 /* Calling WinGetLastError() resets the error code of the current thread.
559 Since for some Win* API return value 0 is normal, one needs to call
560 this before calling them to distinguish normal and anomalous returns. */
561 /*#define ResetWinError() WinError_2_Perl_rc */
563 /* At this moment init_PMWIN_entries() should be a nop (WinInitialize should
564 be called already, right?), so we do not risk stepping over our own error */
565 #define FillWinError ( WinError_2_Perl_rc, \
566 Perl_severity = ERRORIDSEV(Perl_rc), \
567 Perl_rc = ERRORIDERROR(Perl_rc), \
568 os2_setsyserrno(Perl_rc))
570 #define STATIC_FILE_LENGTH 127
572 /* This should match loadOrdinals[] array in os2.c */
573 enum entries_ordinals {
574 ORD_DosQueryExtLibpath,
575 ORD_DosSetExtLibpath,
590 ORD_WinCreateMsgQueue,
591 ORD_WinDestroyMsgQueue,
596 ORD_WinCancelShutdown,
598 ORD_RexxVariablePool,
599 ORD_RexxRegisterFunctionExe,
600 ORD_RexxDeregisterFunction,
602 ORD_PRF32QUERYPROFILESIZE,
603 ORD_PRF32OPENPROFILE,
604 ORD_PRF32CLOSEPROFILE,
605 ORD_PRF32QUERYPROFILE,
607 ORD_PRF32QUERYPROFILEDATA,
608 ORD_PRF32WRITEPROFILEDATA,
610 ORD_WinChangeSwitchEntry,
611 ORD_WinQuerySwitchEntry,
612 ORD_WinQuerySwitchHandle,
613 ORD_WinQuerySwitchList,
614 ORD_WinSwitchToProgram,
615 ORD_WinBeginEnumWindows,
616 ORD_WinEndEnumWindows,
618 ORD_WinGetNextWindow,
620 ORD_WinQueryActiveWindow,
621 ORD_WinQueryClassName,
624 ORD_WinQueryWindowPos,
625 ORD_WinQueryWindowProcess,
626 ORD_WinQueryWindowText,
627 ORD_WinQueryWindowTextLength,
630 ORD_WinSetWindowText,
634 ORD_WinWindowFromPoint,
637 ORD_WinEnableWindowUpdate,
638 ORD_WinIsWindowEnabled,
639 ORD_WinIsWindowShowing,
640 ORD_WinIsWindowVisible,
641 ORD_WinQueryWindowPtr,
642 ORD_WinQueryWindowULong,
643 ORD_WinQueryWindowUShort,
644 ORD_WinSetWindowBits,
646 ORD_WinSetWindowULong,
647 ORD_WinSetWindowUShort,
648 ORD_WinQueryDesktopWindow,
649 ORD_WinSetActiveWindow,
650 ORD_DosQueryModFromEIP,
651 ORD_Dos32QueryHeaderInfo,
654 ORD_WinQueryActiveDesktopPathname,
655 ORD_WinInvalidateRect,
656 ORD_WinCreateFrameControls,
657 ORD_WinQueryClipbrdFmtInfo,
658 ORD_WinQueryClipbrdOwner,
659 ORD_WinQueryClipbrdViewer,
660 ORD_WinQueryClipbrdData,
663 ORD_WinSetClipbrdData,
664 ORD_WinSetClipbrdOwner,
665 ORD_WinSetClipbrdViewer,
666 ORD_WinEnumClipbrdFmts,
671 ORD_WinQueryAtomUsage,
672 ORD_WinQueryAtomName,
673 ORD_WinQueryAtomLength,
674 ORD_WinQuerySystemAtomTable,
675 ORD_WinCreateAtomTable,
676 ORD_WinDestroyAtomTable,
683 ORD_WinQuerySysValue,
688 ORD_WinQuerySysPointer,
689 ORD_DosReplaceModule,
691 ORD_RexxRegisterSubcomExe,
695 /* RET: return type, AT: argument signature in (), ARGS: should be in () */
696 #define CallORD(ret,o,at,args) (((ret (*)at) loadByOrdinal(o, 1))args)
697 #define DeclFuncByORD(ret,name,o,at,args) \
698 ret name at { return CallORD(ret,o,at,args); }
699 #define DeclVoidFuncByORD(name,o,at,args) \
700 void name at { CallORD(void,o,at,args); }
702 /* This function returns error code on error, and saves the error info in $^E and Perl_rc */
703 #define DeclOSFuncByORD_native(ret,name,o,at,args) \
704 ret name at { unsigned long rc; return CheckOSError(CallORD(ret,o,at,args)); }
706 /* These functions return false on error, and save the error info in $^E and Perl_rc */
707 #define DeclOSFuncByORD(ret,name,o,at,args) \
708 ret name at { unsigned long rc; return !CheckOSError(CallORD(ret,o,at,args)); }
709 #define DeclWinFuncByORD(ret,name,o,at,args) \
710 ret name at { return SaveWinError(CallORD(ret,o,at,args)); }
712 #define AssignFuncPByORD(p,o) (*(Perl_PFN*)&(p) = (loadByOrdinal(o, 1)))
714 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
715 #define DeclWinFuncByORD_CACHE(ret,name,o,at,args) \
716 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,1)
718 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
719 #define DeclWinFuncByORD_CACHE_resetError(ret,name,o,at,args) \
720 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,1)
722 /* Two flavors below do the same as above, but do not auto-croak */
723 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
724 #define DeclWinFuncByORD_CACHE_survive(ret,name,o,at,args) \
725 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,0)
727 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
728 #define DeclWinFuncByORD_CACHE_resetError_survive(ret,name,o,at,args) \
729 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,0)
731 #define DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,r,die) \
732 static ret (*CAT2(p__Win,name)) at; \
733 static ret name at { \
734 if (!CAT2(p__Win,name)) \
735 AssignFuncPByORD(CAT2(p__Win,name), o); \
736 if (r) ResetWinError(); \
737 return SaveCroakWinError(CAT2(p__Win,name) args, die, "[Win]", STRINGIFY(name)); }
739 /* These flavors additionally assume ORD is name with prepended ORD_Win */
740 #define DeclWinFunc_CACHE(ret,name,at,args) \
741 DeclWinFuncByORD_CACHE(ret,name,CAT2(ORD_Win,name),at,args)
742 #define DeclWinFunc_CACHE_resetError(ret,name,at,args) \
743 DeclWinFuncByORD_CACHE_resetError(ret,name,CAT2(ORD_Win,name),at,args)
744 #define DeclWinFunc_CACHE_survive(ret,name,at,args) \
745 DeclWinFuncByORD_CACHE_survive(ret,name,CAT2(ORD_Win,name),at,args)
746 #define DeclWinFunc_CACHE_resetError_survive(ret,name,at,args) \
747 DeclWinFuncByORD_CACHE_resetError_survive(ret,name,CAT2(ORD_Win,name),at,args)
749 void ResetWinError(void);
750 void CroakWinError(int die, char *name);
752 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
753 char *perllib_mangle(char *, unsigned int);
755 #define fork fork_with_resources
757 #ifdef EINTR /* x2p do not include perl.h!!! */
758 static __inline__ int
759 my_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
761 if (nfds == 0 && timeout && (_emx_env & 0x200)) {
762 if (DosSleep(1000 * timeout->tv_sec + (timeout->tv_usec + 500)/1000) == 0)
767 return select(nfds, readfds, writefds, exceptfds, timeout);
770 #define select my_select
774 typedef int (*Perl_PFN)();
775 Perl_PFN loadByOrdinal(enum entries_ordinals ord, int fail);
776 extern const Perl_PFN * const pExtFCN;
777 char *os2error(int rc);
778 int os2_stat(const char *name, struct stat *st);
779 int fork_with_resources();
780 int setpriority(int which, int pid, int val);
781 int getpriority(int which /* ignored */, int pid);
783 void croak_with_os2error(char *s) __attribute__((noreturn));
786 int os2_do_spawn(pTHX_ char *cmd);
787 int os2_do_aspawn(pTHX_ SV *really, SV **vmark, SV **vsp);
792 /* Replacement for syslog.h */
793 # define LOG_EMERG 0 /* system is unusable */
794 # define LOG_ALERT 1 /* action must be taken immediately */
795 # define LOG_CRIT 2 /* critical conditions */
796 # define LOG_ERR 3 /* error conditions */
797 # define LOG_WARNING 4 /* warning conditions */
798 # define LOG_NOTICE 5 /* normal but significant condition */
799 # define LOG_INFO 6 /* informational */
800 # define LOG_DEBUG 7 /* debug-level messages */
802 # define LOG_PRIMASK 0x007 /* mask to extract priority part (internal) */
803 /* extract priority */
804 # define LOG_PRI(p) ((p) & LOG_PRIMASK)
805 # define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
808 # define LOG_KERN (0<<3) /* kernel messages */
809 # define LOG_USER (1<<3) /* random user-level messages */
810 # define LOG_MAIL (2<<3) /* mail system */
811 # define LOG_DAEMON (3<<3) /* system daemons */
812 # define LOG_AUTH (4<<3) /* security/authorization messages */
813 # define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
814 # define LOG_LPR (6<<3) /* line printer subsystem */
815 # define LOG_NEWS (7<<3) /* network news subsystem */
816 # define LOG_UUCP (8<<3) /* UUCP subsystem */
817 # define LOG_CRON (15<<3) /* clock daemon */
818 /* other codes through 15 reserved for system use */
819 # define LOG_LOCAL0 (16<<3) /* reserved for local use */
820 # define LOG_LOCAL1 (17<<3) /* reserved for local use */
821 # define LOG_LOCAL2 (18<<3) /* reserved for local use */
822 # define LOG_LOCAL3 (19<<3) /* reserved for local use */
823 # define LOG_LOCAL4 (20<<3) /* reserved for local use */
824 # define LOG_LOCAL5 (21<<3) /* reserved for local use */
825 # define LOG_LOCAL6 (22<<3) /* reserved for local use */
826 # define LOG_LOCAL7 (23<<3) /* reserved for local use */
828 # define LOG_NFACILITIES 24 /* current number of facilities */
829 # define LOG_FACMASK 0x03f8 /* mask to extract facility part */
830 /* facility of pri */
831 # define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
834 * arguments to setlogmask.
836 # define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
837 # define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
840 * Option flags for openlog.
842 * LOG_ODELAY no longer does anything.
843 * LOG_NDELAY is the inverse of what it used to be.
845 # define LOG_PID 0x01 /* log the pid with each message */
846 # define LOG_CONS 0x02 /* log on the console if errors in sending */
847 # define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
848 # define LOG_NDELAY 0x08 /* don't delay open */
849 # define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
850 # define LOG_PERROR 0x20 /* log to stderr as well */
854 /* ************************************************************ */
855 #define Dos32QuerySysState DosQuerySysState
856 #define QuerySysState(flags, pid, buf, bufsz) \
857 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
859 #define QSS_PROCESS 1
861 #define QSS_SEMAPHORES 2
862 #define QSS_FILE 8 /* Buggy until fixpack18 */
863 #define QSS_SHARED 16
867 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
868 ULONG _res_,PVOID buf,ULONG bufsz);
873 } QGLOBAL, *PQGLOBAL;
884 UCHAR _reserved1_; /* padding to ULONG */
885 USHORT _reserved2_; /* padding to ULONG */
886 } QTHREAD, *PQTHREAD;
901 typedef struct qfile {
929 } QPROCESS, *PQPROCESS;
931 typedef struct sema {
948 } QSEMSTRUC, *PQSEMSTRUC;
953 } QSEMOWNER32, *PQSEMOWNER32;
958 PVOID semrecs; /* array of associated sema's */
962 USHORT _reserved_; /* padding to ULONG */
963 } QSEMSMUX32, *PQSEMSMUX32;
971 } QSEMEV32, *PQSEMEV32;
980 USHORT _reserved_; /* padding to ULONG */
981 } QSEMMUX32, *PQSEMMUX32;
983 typedef struct semstr32 {
988 } QSEMSTRUC32, *PQSEMSTRUC32;
990 typedef struct shrmem {
996 } QSHRMEM, *PQSHRMEM;
998 typedef struct module {
1007 } QMODULE, *PQMODULE;
1012 PQSEMSTRUC semadata;
1013 PQSEMSTRUC32 sem32data;
1014 PQSHRMEM shrmemdata;
1018 } QTOPLEVEL, *PQTOPLEVEL;
1019 /* ************************************************************ */
1021 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);