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.
53 * This symbol holds the type used to declare buffers for information
54 * returned by stat(). It's usually just struct stat. It may be necessary
55 * to include <sys/stat.h> and <sys/types.h> to get any typedef'ed
58 #define Stat_t struct stat
61 * This symbol is defined if this system has a stat structure declaring
64 #define USE_STAT_RDEV /**/
67 * This symbol, if defined, indicates that error messages should be
68 * should be generated in a format that allows the use of the Acme
69 * GUI/editor's autofind feature.
74 * This symbol, if defined, contains a "magic" string which may be used
75 * as the first line of a Perl program designed to be executed directly
76 * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
77 * begins with a character other then #, then Perl will only treat
78 * it as a command line if if finds the string "perl" in the first
79 * word; otherwise it's treated as the first line of code in the script.
80 * (IOW, Perl won't hand off to another interpreter via an alternate
81 * shebang sequence that might be legal Perl code.)
83 #define ALTERNATE_SHEBANG "extproc "
86 # define SIGABRT SIGILL
89 # define SIGILL 6 /* blech */
91 #define ABORT() kill(PerlProc_getpid(),SIGABRT);
93 #define BIT_BUCKET "/dev/nul" /* Will this work? */
95 /* Apparently TCPIPV4 defines may be included even with only IAK present */
97 #if !defined(NO_TCPIPV4) && !defined(TCPIPV4)
99 # define TCPIPV4_FORCED /* Just in case */
102 #if defined(I_SYS_UN) && !defined(TCPIPV4)
103 /* It is not working without TCPIPV4 defined. */
109 #define do_spawn(a) os2_do_spawn(aTHX_ (a))
110 #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
112 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
116 #define MUTEX_INIT(m) \
119 if ((rc = _rmutex_create(m,0))) \
120 Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \
122 #define MUTEX_LOCK(m) \
125 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
126 Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \
128 #define MUTEX_UNLOCK(m) \
131 if ((rc = _rmutex_release(m))) \
132 Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \
134 #define MUTEX_DESTROY(m) \
137 if ((rc = _rmutex_close(m))) \
138 Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \
141 #define COND_INIT(c) \
144 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
145 Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \
147 #define COND_SIGNAL(c) \
150 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
151 Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \
153 #define COND_BROADCAST(c) \
156 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
157 Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \
159 /* #define COND_WAIT(c, m) \
161 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
162 Perl_croak_nocontext("panic: COND_WAIT"); \
165 #define COND_WAIT(c, m) os2_cond_wait(c,m)
167 #define COND_WAIT_win32(c, m) \
170 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \
171 Perl_croak_nocontext("panic: COND_WAIT"); \
175 #define COND_DESTROY(c) \
178 if ((rc = DosCloseEventSem(*(c)))) \
179 Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \
181 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
184 #ifdef USE_SLOW_THREAD_SPECIFIC
185 # define pthread_getspecific(k) (*_threadstore())
186 # define pthread_setspecific(k,v) (*_threadstore()=v,0)
187 # define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
188 #else /* USE_SLOW_THREAD_SPECIFIC */
189 # define pthread_getspecific(k) (*(k))
190 # define pthread_setspecific(k,v) (*(k)=(v),0)
191 # define pthread_key_create(keyp,flag) \
192 ( DosAllocThreadLocalMemory(1,(unsigned long**)keyp) \
193 ? Perl_croak_nocontext("LocalMemory"),1 \
196 #endif /* USE_SLOW_THREAD_SPECIFIC */
197 #define pthread_key_delete(keyp)
198 #define pthread_self() _gettid()
199 #define YIELD DosSleep(0)
201 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
202 int pthread_join(pthread_t tid, void **status);
203 int pthread_detach(pthread_t tid);
204 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
205 void *(*start_routine)(void*), void *arg);
206 #endif /* PTHREAD_INCLUDED */
208 #define THREADS_ELSEWHERE
210 #else /* USE_ITHREADS */
212 #define do_spawn(a) os2_do_spawn(a)
213 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
215 void Perl_OS2_init(char **);
216 void Perl_OS2_init3(char **envp, void **excH, int flags);
217 void Perl_OS2_term(void **excH, int exitstatus, int flags);
219 /* The code without INIT3 hideously puts env inside: */
221 /* These ones should be in the same block as PERL_SYS_TERM() */
224 # define PERL_SYS_INIT3(argcp, argvp, envp) \
226 MALLOC_CHECK_TAINT(*argcp, *argvp, *envp) \
227 _response(argcp, argvp); \
228 _wildcard(argcp, argvp); \
229 Perl_OS2_init3(*envp, xreg, 0)
231 # define PERL_SYS_INIT(argcp, argvp) { \
233 _response(argcp, argvp); \
234 _wildcard(argcp, argvp); \
235 Perl_OS2_init3(NULL, xreg, 0)
237 #else /* Compiling embedded Perl or Perl extension */
239 # define PERL_SYS_INIT3(argcp, argvp, envp) \
241 Perl_OS2_init3(*envp, xreg, 0)
242 # define PERL_SYS_INIT(argcp, argvp) { \
244 Perl_OS2_init3(NULL, xreg, 0)
247 #define FORCE_EMX_DEINIT_EXIT 1
248 #define FORCE_EMX_DEINIT_CRT_TERM 2
249 #define FORCE_EMX_DEINIT_RUN_ATEXIT 4
251 #define PERL_SYS_TERM2(xreg,flags) \
252 Perl_OS2_term(xreg, 0, flags); \
255 #define PERL_SYS_TERM1(xreg) \
256 Perl_OS2_term(xreg, 0, FORCE_EMX_DEINIT_RUN_ATEXIT)
258 /* This one should come in pair with PERL_SYS_INIT() and in the same block */
259 #define PERL_SYS_TERM() \
260 PERL_SYS_TERM1(xreg); \
264 # define PERL_CALLCONV _System
267 /* #define PERL_SYS_TERM() STMT_START { \
268 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
270 #define dXSUB_SYS OS2_XS_init()
273 /* # define HAS_FORK */
274 /* # define HIDEMYMALLOC */
275 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
276 #else /* !PERL_IS_AOUT */
277 # ifndef PERL_FOR_X2P
279 # define USE_PERL_SBRK
284 # define SYSTEM_ALLOC(a) sys_alloc(a)
286 void *sys_alloc(int size);
288 #endif /* !PERL_IS_AOUT */
289 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
293 /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
294 * defined. Hack around this to get us to compile.
305 #define TMPPATH1 "plXXXXXX"
306 extern const char *tmppath;
307 PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
308 /* Cannot prototype with I32 at this point. */
309 int my_syspclose(PerlIO *f);
310 FILE *my_tmpfile (void);
311 char *my_tmpnam (char *);
312 int my_mkdir (__const__ char *, long);
313 int my_rmdir (__const__ char *);
314 struct passwd *my_getpwent (void);
315 void my_setpwent (void);
316 void my_endpwent (void);
317 char *gcvt_os2(double value, int digits, char *buffer);
319 #define MAX_SLEEP (((1<30) / (1000/4))-1) /* 1<32 msec */
321 static __inline__ unsigned
322 my_sleep(unsigned sec)
325 while (sec > MAX_SLEEP) {
327 remain = sleep(MAX_SLEEP);
334 #define sleep my_sleep
337 unsigned long DosSleep(unsigned long);
338 unsigned long DosAllocThreadLocalMemory (unsigned long cb, unsigned long **p);
341 struct group *getgrent (void);
342 void setgrent (void);
343 void endgrent (void);
345 struct passwd *my_getpwuid (uid_t);
346 struct passwd *my_getpwnam (__const__ char *);
349 #define L_tmpnam MAXPATHLEN
351 #define tmpfile my_tmpfile
352 #define tmpnam my_tmpnam
353 #define isatty _isterm
355 #define srand srandom
356 #define strtoll _strtoll
357 #define strtoull _strtoull
359 #define usleep(usec) ((void)_sleep2(((usec)+500)/1000))
363 * fwrite1() should be a routine with the same calling sequence as fwrite(),
364 * but which outputs all of the bytes requested as a single stream (unlike
365 * fwrite() itself, which on some systems outputs several distinct records
366 * if the number_of_items parameter is >1).
368 #define fwrite1 fwrite
370 #define my_getenv(var) getenv(var)
371 #define flock my_flock
372 #define rmdir my_rmdir
373 #define mkdir my_mkdir
374 #define setpwent my_setpwent
375 #define getpwent my_getpwent
376 #define endpwent my_endpwent
377 #define getpwuid my_getpwuid
378 #define getpwnam my_getpwnam
380 void *emx_calloc (size_t, size_t);
381 void emx_free (void *);
382 void *emx_malloc (size_t);
383 void *emx_realloc (void *, size_t);
385 /*****************************************************************************/
387 #include <stdlib.h> /* before the following definitions */
388 #include <unistd.h> /* before the following definitions */
390 #include <sys/stat.h>
392 #define chdir _chdir2
393 #define getcwd _getcwd2
395 /* This guy is needed for quick stdstd */
397 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
398 /* Perl uses ungetc only with successful return */
399 # define ungetc(c,fp) \
400 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
401 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
404 #define PERLIO_IS_BINMODE_FD(fd) _PERLIO_IS_BINMODE_FD(fd)
414 #include <emx/io.h> /* for _fd_flags() prototype */
417 _PERLIO_IS_BINMODE_FD(int fd)
419 int *pflags = _fd_flags(fd);
421 return pflags && (*pflags) & O_BINARY;
424 /* ctermid is missing from emx0.9d */
425 char *ctermid(char *s);
427 #define OP_BINARY O_BINARY
429 #define OS2_STAT_HACK 1
432 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
433 #define Fstat(fd,bufptr) os2_fstat((fd),(bufptr))
434 #define Fflush(fp) fflush(fp)
435 #define Mkdir(path,mode) mkdir((path),(mode))
436 #define chmod(path,mode) os2_chmod((path),(mode))
440 #define S_IFBLK 0120000 /* Hacks to make things compile... */
441 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
443 int os2_chmod(const char *name, int pmode);
444 int os2_fstat(int handle, struct stat *st);
448 #define Stat(fname,bufptr) stat((fname),(bufptr))
449 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
450 #define Fflush(fp) fflush(fp)
451 #define Mkdir(path,mode) mkdir((path),(mode))
455 /* With SD386 it is impossible to debug register variables. */
456 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
460 /* Our private OS/2 specific data. */
462 typedef struct OS2_Perl_data {
467 unsigned long severity;
468 unsigned long phmq; /* Handle to message queue */
469 unsigned long phmq_refcnt;
470 unsigned long phmq_servers;
471 unsigned long initial_mode; /* VIO etc. mode we were started in */
472 unsigned long morph_refcnt;
475 extern OS2_Perl_data_t OS2_Perl_data;
477 #define Perl_hab ((HAB)OS2_Perl_data.phab)
478 #define Perl_rc (OS2_Perl_data.rc)
479 #define Perl_severity (OS2_Perl_data.severity)
480 #define errno_isOS2 12345678
481 #define errno_isOS2_set 12345679
482 #define OS2_Perl_flags (OS2_Perl_data.flags)
483 #define Perl_HAB_set_f 1
484 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
485 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
486 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
487 #define _obtain_Perl_HAB (init_PMWIN_entries(), \
488 Perl_hab = (*PMWIN_entries.Initialize)(0), \
489 set_Perl_HAB_f, Perl_hab)
490 #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
491 #define Acquire_hab() perl_hab_GET()
492 #define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
493 #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
494 #define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
495 #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
496 #define Perl_morph_refcnt (OS2_Perl_data.morph_refcnt)
498 unsigned long Perl_hab_GET();
499 unsigned long Perl_Register_MQ(int serve);
500 void Perl_Deregister_MQ(int serve);
501 int Perl_Serve_Messages(int force);
502 /* Cannot prototype with I32 at this point. */
503 int Perl_Process_Messages(int force, long *cntp);
504 char *os2_execname(pTHX);
507 struct PMWIN_entries_t {
508 unsigned long (*Initialize)( unsigned long fsOptions );
509 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
510 int (*DestroyMsgQueue)(unsigned long hmq);
511 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
512 unsigned long hwndFilter, unsigned long msgFilterFirst,
513 unsigned long msgFilterLast, unsigned long fl);
514 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
515 unsigned long hwndFilter, unsigned long msgFilterFirst,
516 unsigned long msgFilterLast);
517 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
518 unsigned long (*GetLastError)(unsigned long hab);
519 unsigned long (*CancelShutdown)(unsigned long hmq, unsigned long fCancelAlways);
521 extern struct PMWIN_entries_t PMWIN_entries;
522 void init_PMWIN_entries(void);
524 #define perl_hmq_GET(serve) Perl_Register_MQ(serve)
525 #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
527 #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
529 #if _EMX_CRT_REV_ >= 60
530 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
533 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
536 /* The expressions below return true on error. */
537 /* INCL_DOSERRORS needed. rc should be declared outside. */
538 #define CheckOSError(expr) ((rc = (expr)) ? (FillOSError(rc), rc) : 0)
539 /* INCL_WINERRORS needed. */
540 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
542 /* This form propagates the return value, setting $^E if needed */
543 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
545 /* This form propagates the return value, dieing with $^E if needed */
546 #define SaveCroakWinError(expr,die,name1,name2) \
547 ((expr) ? : (CroakWinError(die,name1 name2), 0))
549 #define FillOSError(rc) (os2_setsyserrno(rc), \
550 Perl_severity = SEVERITY_ERROR)
552 #define WinError_2_Perl_rc \
553 ( init_PMWIN_entries(), \
554 Perl_rc=(*PMWIN_entries.GetLastError)(perl_hab_GET()) )
556 /* Calling WinGetLastError() resets the error code of the current thread.
557 Since for some Win* API return value 0 is normal, one needs to call
558 this before calling them to distinguish normal and anomalous returns. */
559 /*#define ResetWinError() WinError_2_Perl_rc */
561 /* At this moment init_PMWIN_entries() should be a nop (WinInitialize should
562 be called already, right?), so we do not risk stepping over our own error */
563 #define FillWinError ( WinError_2_Perl_rc, \
564 Perl_severity = ERRORIDSEV(Perl_rc), \
565 Perl_rc = ERRORIDERROR(Perl_rc), \
566 os2_setsyserrno(Perl_rc))
568 #define STATIC_FILE_LENGTH 127
570 /* This should match loadOrdinals[] array in os2.c */
571 enum entries_ordinals {
572 ORD_DosQueryExtLibpath,
573 ORD_DosSetExtLibpath,
588 ORD_WinCreateMsgQueue,
589 ORD_WinDestroyMsgQueue,
594 ORD_WinCancelShutdown,
596 ORD_RexxVariablePool,
597 ORD_RexxRegisterFunctionExe,
598 ORD_RexxDeregisterFunction,
600 ORD_PRF32QUERYPROFILESIZE,
601 ORD_PRF32OPENPROFILE,
602 ORD_PRF32CLOSEPROFILE,
603 ORD_PRF32QUERYPROFILE,
605 ORD_PRF32QUERYPROFILEDATA,
606 ORD_PRF32WRITEPROFILEDATA,
608 ORD_WinChangeSwitchEntry,
609 ORD_WinQuerySwitchEntry,
610 ORD_WinQuerySwitchHandle,
611 ORD_WinQuerySwitchList,
612 ORD_WinSwitchToProgram,
613 ORD_WinBeginEnumWindows,
614 ORD_WinEndEnumWindows,
616 ORD_WinGetNextWindow,
618 ORD_WinQueryActiveWindow,
619 ORD_WinQueryClassName,
622 ORD_WinQueryWindowPos,
623 ORD_WinQueryWindowProcess,
624 ORD_WinQueryWindowText,
625 ORD_WinQueryWindowTextLength,
628 ORD_WinSetWindowText,
632 ORD_WinWindowFromPoint,
635 ORD_WinEnableWindowUpdate,
636 ORD_WinIsWindowEnabled,
637 ORD_WinIsWindowShowing,
638 ORD_WinIsWindowVisible,
639 ORD_WinQueryWindowPtr,
640 ORD_WinQueryWindowULong,
641 ORD_WinQueryWindowUShort,
642 ORD_WinSetWindowBits,
644 ORD_WinSetWindowULong,
645 ORD_WinSetWindowUShort,
646 ORD_WinQueryDesktopWindow,
647 ORD_WinSetActiveWindow,
648 ORD_DosQueryModFromEIP,
649 ORD_Dos32QueryHeaderInfo,
652 ORD_WinQueryActiveDesktopPathname,
653 ORD_WinInvalidateRect,
654 ORD_WinCreateFrameControls,
655 ORD_WinQueryClipbrdFmtInfo,
656 ORD_WinQueryClipbrdOwner,
657 ORD_WinQueryClipbrdViewer,
658 ORD_WinQueryClipbrdData,
661 ORD_WinSetClipbrdData,
662 ORD_WinSetClipbrdOwner,
663 ORD_WinSetClipbrdViewer,
664 ORD_WinEnumClipbrdFmts,
669 ORD_WinQueryAtomUsage,
670 ORD_WinQueryAtomName,
671 ORD_WinQueryAtomLength,
672 ORD_WinQuerySystemAtomTable,
673 ORD_WinCreateAtomTable,
674 ORD_WinDestroyAtomTable,
681 ORD_WinQuerySysValue,
686 ORD_WinQuerySysPointer,
687 ORD_DosReplaceModule,
691 /* RET: return type, AT: argument signature in (), ARGS: should be in () */
692 #define CallORD(ret,o,at,args) (((ret (*)at) loadByOrdinal(o, 1))args)
693 #define DeclFuncByORD(ret,name,o,at,args) \
694 ret name at { return CallORD(ret,o,at,args); }
695 #define DeclVoidFuncByORD(name,o,at,args) \
696 void name at { CallORD(void,o,at,args); }
698 /* This function returns error code on error, and saves the error info in $^E and Perl_rc */
699 #define DeclOSFuncByORD_native(ret,name,o,at,args) \
700 ret name at { unsigned long rc; return CheckOSError(CallORD(ret,o,at,args)); }
702 /* These functions return false on error, and save the error info in $^E and Perl_rc */
703 #define DeclOSFuncByORD(ret,name,o,at,args) \
704 ret name at { unsigned long rc; return !CheckOSError(CallORD(ret,o,at,args)); }
705 #define DeclWinFuncByORD(ret,name,o,at,args) \
706 ret name at { return SaveWinError(CallORD(ret,o,at,args)); }
708 #define AssignFuncPByORD(p,o) (*(Perl_PFN*)&(p) = (loadByOrdinal(o, 1)))
710 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
711 #define DeclWinFuncByORD_CACHE(ret,name,o,at,args) \
712 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,1)
714 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
715 #define DeclWinFuncByORD_CACHE_resetError(ret,name,o,at,args) \
716 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,1)
718 /* Two flavors below do the same as above, but do not auto-croak */
719 /* This flavor caches the procedure pointer (named as p__Win#name) locally */
720 #define DeclWinFuncByORD_CACHE_survive(ret,name,o,at,args) \
721 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,0,0)
723 /* This flavor may reset the last error before the call (if ret=0 may be OK) */
724 #define DeclWinFuncByORD_CACHE_resetError_survive(ret,name,o,at,args) \
725 DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,1,0)
727 #define DeclWinFuncByORD_CACHE_r(ret,name,o,at,args,r,die) \
728 static ret (*CAT2(p__Win,name)) at; \
729 static ret name at { \
730 if (!CAT2(p__Win,name)) \
731 AssignFuncPByORD(CAT2(p__Win,name), o); \
732 if (r) ResetWinError(); \
733 return SaveCroakWinError(CAT2(p__Win,name) args, die, "[Win]", STRINGIFY(name)); }
735 /* These flavors additionally assume ORD is name with prepended ORD_Win */
736 #define DeclWinFunc_CACHE(ret,name,at,args) \
737 DeclWinFuncByORD_CACHE(ret,name,CAT2(ORD_Win,name),at,args)
738 #define DeclWinFunc_CACHE_resetError(ret,name,at,args) \
739 DeclWinFuncByORD_CACHE_resetError(ret,name,CAT2(ORD_Win,name),at,args)
740 #define DeclWinFunc_CACHE_survive(ret,name,at,args) \
741 DeclWinFuncByORD_CACHE_survive(ret,name,CAT2(ORD_Win,name),at,args)
742 #define DeclWinFunc_CACHE_resetError_survive(ret,name,at,args) \
743 DeclWinFuncByORD_CACHE_resetError_survive(ret,name,CAT2(ORD_Win,name),at,args)
745 void ResetWinError(void);
746 void CroakWinError(int die, char *name);
748 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
749 char *perllib_mangle(char *, unsigned int);
751 #define fork fork_with_resources
753 #ifdef EINTR /* x2p do not include perl.h!!! */
754 static __inline__ int
755 my_select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout)
757 if (nfds == 0 && timeout && (_emx_env & 0x200)) {
758 if (DosSleep(1000 * timeout->tv_sec + (timeout->tv_usec + 500)/1000) == 0)
763 return select(nfds, readfds, writefds, exceptfds, timeout);
766 #define select my_select
770 typedef int (*Perl_PFN)();
771 Perl_PFN loadByOrdinal(enum entries_ordinals ord, int fail);
772 extern const Perl_PFN * const pExtFCN;
773 char *os2error(int rc);
774 int os2_stat(const char *name, struct stat *st);
775 int fork_with_resources();
776 int setpriority(int which, int pid, int val);
777 int getpriority(int which /* ignored */, int pid);
779 void croak_with_os2error(char *s) __attribute__((noreturn));
782 int os2_do_spawn(pTHX_ char *cmd);
783 int os2_do_aspawn(pTHX_ SV *really, SV **vmark, SV **vsp);
788 /* Replacement for syslog.h */
789 # define LOG_EMERG 0 /* system is unusable */
790 # define LOG_ALERT 1 /* action must be taken immediately */
791 # define LOG_CRIT 2 /* critical conditions */
792 # define LOG_ERR 3 /* error conditions */
793 # define LOG_WARNING 4 /* warning conditions */
794 # define LOG_NOTICE 5 /* normal but significant condition */
795 # define LOG_INFO 6 /* informational */
796 # define LOG_DEBUG 7 /* debug-level messages */
798 # define LOG_PRIMASK 0x007 /* mask to extract priority part (internal) */
799 /* extract priority */
800 # define LOG_PRI(p) ((p) & LOG_PRIMASK)
801 # define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
804 # define LOG_KERN (0<<3) /* kernel messages */
805 # define LOG_USER (1<<3) /* random user-level messages */
806 # define LOG_MAIL (2<<3) /* mail system */
807 # define LOG_DAEMON (3<<3) /* system daemons */
808 # define LOG_AUTH (4<<3) /* security/authorization messages */
809 # define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
810 # define LOG_LPR (6<<3) /* line printer subsystem */
811 # define LOG_NEWS (7<<3) /* network news subsystem */
812 # define LOG_UUCP (8<<3) /* UUCP subsystem */
813 # define LOG_CRON (15<<3) /* clock daemon */
814 /* other codes through 15 reserved for system use */
815 # define LOG_LOCAL0 (16<<3) /* reserved for local use */
816 # define LOG_LOCAL1 (17<<3) /* reserved for local use */
817 # define LOG_LOCAL2 (18<<3) /* reserved for local use */
818 # define LOG_LOCAL3 (19<<3) /* reserved for local use */
819 # define LOG_LOCAL4 (20<<3) /* reserved for local use */
820 # define LOG_LOCAL5 (21<<3) /* reserved for local use */
821 # define LOG_LOCAL6 (22<<3) /* reserved for local use */
822 # define LOG_LOCAL7 (23<<3) /* reserved for local use */
824 # define LOG_NFACILITIES 24 /* current number of facilities */
825 # define LOG_FACMASK 0x03f8 /* mask to extract facility part */
826 /* facility of pri */
827 # define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
830 * arguments to setlogmask.
832 # define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
833 # define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
836 * Option flags for openlog.
838 * LOG_ODELAY no longer does anything.
839 * LOG_NDELAY is the inverse of what it used to be.
841 # define LOG_PID 0x01 /* log the pid with each message */
842 # define LOG_CONS 0x02 /* log on the console if errors in sending */
843 # define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
844 # define LOG_NDELAY 0x08 /* don't delay open */
845 # define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
846 # define LOG_PERROR 0x20 /* log to stderr as well */
850 /* ************************************************************ */
851 #define Dos32QuerySysState DosQuerySysState
852 #define QuerySysState(flags, pid, buf, bufsz) \
853 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
855 #define QSS_PROCESS 1
857 #define QSS_SEMAPHORES 2
858 #define QSS_FILE 8 /* Buggy until fixpack18 */
859 #define QSS_SHARED 16
863 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
864 ULONG _res_,PVOID buf,ULONG bufsz);
869 } QGLOBAL, *PQGLOBAL;
880 UCHAR _reserved1_; /* padding to ULONG */
881 USHORT _reserved2_; /* padding to ULONG */
882 } QTHREAD, *PQTHREAD;
897 typedef struct qfile {
925 } QPROCESS, *PQPROCESS;
927 typedef struct sema {
944 } QSEMSTRUC, *PQSEMSTRUC;
949 } QSEMOWNER32, *PQSEMOWNER32;
954 PVOID semrecs; /* array of associated sema's */
958 USHORT _reserved_; /* padding to ULONG */
959 } QSEMSMUX32, *PQSEMSMUX32;
967 } QSEMEV32, *PQSEMEV32;
976 USHORT _reserved_; /* padding to ULONG */
977 } QSEMMUX32, *PQSEMMUX32;
979 typedef struct semstr32 {
984 } QSEMSTRUC32, *PQSEMSTRUC32;
986 typedef struct shrmem {
992 } QSHRMEM, *PQSHRMEM;
994 typedef struct module {
1003 } QMODULE, *PQMODULE;
1008 PQSEMSTRUC semadata;
1009 PQSEMSTRUC32 sem32data;
1010 PQSHRMEM shrmemdata;
1014 } QTOPLEVEL, *PQTOPLEVEL;
1015 /* ************************************************************ */
1017 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);