4 * This symbol, if defined, indicates that the ioctl() routine is
5 * available to set I/O characteristics
10 * This symbol, if defined, indicates that the routine utime() is
11 * available to update the access and modification times of files.
13 #define HAS_UTIME /**/
18 #define HAS_WAITPID_RUNTIME (_emx_env & 0x200)
21 * This symbol, if defined, indicates that the program should
22 * use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
23 * that a file is in "binary" mode -- that is, that no translation
24 * of bytes occurs on read or write operations.
29 * This symbol holds the type used to declare buffers for information
30 * returned by stat(). It's usually just struct stat. It may be necessary
31 * to include <sys/stat.h> and <sys/types.h> to get any typedef'ed
34 #define Stat_t struct stat
37 * This symbol is defined if this system has a stat structure declaring
40 #define USE_STAT_RDEV /**/
43 * This symbol, if defined, indicates that error messages should be
44 * should be generated in a format that allows the use of the Acme
45 * GUI/editor's autofind feature.
50 * This symbol, if defined, contains a "magic" string which may be used
51 * as the first line of a Perl program designed to be executed directly
52 * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
53 * begins with a character other then #, then Perl will only treat
54 * it as a command line if if finds the string "perl" in the first
55 * word; otherwise it's treated as the first line of code in the script.
56 * (IOW, Perl won't hand off to another interpreter via an alternate
57 * shebang sequence that might be legal Perl code.)
59 #define ALTERNATE_SHEBANG "extproc "
62 # define SIGABRT SIGILL
65 # define SIGILL 6 /* blech */
67 #define ABORT() kill(PerlProc_getpid(),SIGABRT);
69 #define BIT_BUCKET "/dev/nul" /* Will this work? */
71 /* Apparently TCPIPV4 defines may be included even with only IAK present */
73 #if !defined(NO_TCPIPV4) && !defined(TCPIPV4)
75 # define TCPIPV4_FORCED /* Just in case */
78 #if defined(I_SYS_UN) && !defined(TCPIPV4)
79 /* It is not working without TCPIPV4 defined. */
85 #define do_spawn(a) os2_do_spawn(aTHX_ (a))
86 #define do_aspawn(a,b,c) os2_do_aspawn(aTHX_ (a),(b),(c))
88 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
92 #define MUTEX_INIT(m) \
95 if ((rc = _rmutex_create(m,0))) \
96 Perl_croak_nocontext("panic: MUTEX_INIT: rc=%i", rc); \
98 #define MUTEX_LOCK(m) \
101 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
102 Perl_croak_nocontext("panic: MUTEX_LOCK: rc=%i", rc); \
104 #define MUTEX_UNLOCK(m) \
107 if ((rc = _rmutex_release(m))) \
108 Perl_croak_nocontext("panic: MUTEX_UNLOCK: rc=%i", rc); \
110 #define MUTEX_DESTROY(m) \
113 if ((rc = _rmutex_close(m))) \
114 Perl_croak_nocontext("panic: MUTEX_DESTROY: rc=%i", rc); \
117 #define COND_INIT(c) \
120 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
121 Perl_croak_nocontext("panic: COND_INIT: rc=%i", rc); \
123 #define COND_SIGNAL(c) \
126 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
127 Perl_croak_nocontext("panic: COND_SIGNAL, rc=%ld", rc); \
129 #define COND_BROADCAST(c) \
132 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
133 Perl_croak_nocontext("panic: COND_BROADCAST, rc=%i", rc); \
135 /* #define COND_WAIT(c, m) \
137 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
138 Perl_croak_nocontext("panic: COND_WAIT"); \
141 #define COND_WAIT(c, m) os2_cond_wait(c,m)
143 #define COND_WAIT_win32(c, m) \
146 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE))) \
147 Perl_croak_nocontext("panic: COND_WAIT"); \
151 #define COND_DESTROY(c) \
154 if ((rc = DosCloseEventSem(*(c)))) \
155 Perl_croak_nocontext("panic: COND_DESTROY, rc=%i", rc); \
157 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
158 #define dTHR struct thread *thr = THR
161 #ifdef USE_SLOW_THREAD_SPECIFIC
162 # define pthread_getspecific(k) (*_threadstore())
163 # define pthread_setspecific(k,v) (*_threadstore()=v,0)
164 # define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
165 #else /* USE_SLOW_THREAD_SPECIFIC */
166 # define pthread_getspecific(k) (*(k))
167 # define pthread_setspecific(k,v) (*(k)=(v),0)
168 # define pthread_key_create(keyp,flag) \
169 ( DosAllocThreadLocalMemory(1,(U32*)keyp) \
170 ? Perl_croak_nocontext("LocalMemory"),1 \
173 #endif /* USE_SLOW_THREAD_SPECIFIC */
174 #define pthread_key_delete(keyp)
175 #define pthread_self() _gettid()
176 #define YIELD DosSleep(0)
178 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
179 int pthread_join(pthread_t tid, void **status);
180 int pthread_detach(pthread_t tid);
181 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
182 void *(*start_routine)(void*), void *arg);
183 #endif /* PTHREAD_INCLUDED */
185 #define THREADS_ELSEWHERE
187 #else /* USE_THREADS */
189 #define do_spawn(a) os2_do_spawn(a)
190 #define do_aspawn(a,b,c) os2_do_aspawn((a),(b),(c))
192 #endif /* USE_THREADS */
194 void Perl_OS2_init(char **);
196 /* XXX This code hideously puts env inside: */
199 # define PERL_SYS_INIT3(argcp, argvp, envp) STMT_START { \
200 _response(argcp, argvp); \
201 _wildcard(argcp, argvp); \
202 Perl_OS2_init(*envp); } STMT_END
203 # define PERL_SYS_INIT(argcp, argvp) STMT_START { \
204 _response(argcp, argvp); \
205 _wildcard(argcp, argvp); \
206 Perl_OS2_init(NULL); } STMT_END
207 #else /* Compiling embedded Perl or Perl extension */
208 # define PERL_SYS_INIT3(argcp, argvp, envp) STMT_START { \
209 Perl_OS2_init(*envp); } STMT_END
210 # define PERL_SYS_INIT(argcp, argvp) STMT_START { \
211 Perl_OS2_init(NULL); } STMT_END
215 # define PERL_CALLCONV _System
218 #define PERL_SYS_TERM() MALLOC_TERM
220 /* #define PERL_SYS_TERM() STMT_START { \
221 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
223 #define dXSUB_SYS OS2_XS_init()
226 /* # define HAS_FORK */
227 /* # define HIDEMYMALLOC */
228 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
229 #else /* !PERL_IS_AOUT */
230 # ifndef PERL_FOR_X2P
232 # define USE_PERL_SBRK
237 # define SYSTEM_ALLOC(a) sys_alloc(a)
239 void *sys_alloc(int size);
241 #endif /* !PERL_IS_AOUT */
242 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
246 /* os2ish is used from a2p/a2p.h without pTHX/pTHX_ first being
247 * defined. Hack around this to get us to compile.
258 #define TMPPATH1 "plXXXXXX"
259 extern char *tmppath;
260 PerlIO *my_syspopen(pTHX_ char *cmd, char *mode);
261 /* Cannot prototype with I32 at this point. */
262 int my_syspclose(PerlIO *f);
263 FILE *my_tmpfile (void);
264 char *my_tmpnam (char *);
267 #define L_tmpnam MAXPATHLEN
269 #define tmpfile my_tmpfile
270 #define tmpnam my_tmpnam
271 #define isatty _isterm
273 #define srand srandom
274 #define strtoll _strtoll
275 #define strtoull _strtoull
278 * fwrite1() should be a routine with the same calling sequence as fwrite(),
279 * but which outputs all of the bytes requested as a single stream (unlike
280 * fwrite() itself, which on some systems outputs several distinct records
281 * if the number_of_items parameter is >1).
283 #define fwrite1 fwrite
285 #define my_getenv(var) getenv(var)
286 #define flock my_flock
288 void *emx_calloc (size_t, size_t);
289 void emx_free (void *);
290 void *emx_malloc (size_t);
291 void *emx_realloc (void *, size_t);
293 /*****************************************************************************/
295 #include <stdlib.h> /* before the following definitions */
296 #include <unistd.h> /* before the following definitions */
298 #define chdir _chdir2
299 #define getcwd _getcwd2
301 /* This guy is needed for quick stdstd */
303 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
304 /* Perl uses ungetc only with successful return */
305 # define ungetc(c,fp) \
306 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
307 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
310 /* ctermid is missing from emx0.9d */
311 char *ctermid(char *s);
313 #define OP_BINARY O_BINARY
315 #define OS2_STAT_HACK 1
318 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
319 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
320 #define Fflush(fp) fflush(fp)
321 #define Mkdir(path,mode) mkdir((path),(mode))
325 #define S_IFBLK 0120000
326 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
330 #define Stat(fname,bufptr) stat((fname),(bufptr))
331 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
332 #define Fflush(fp) fflush(fp)
333 #define Mkdir(path,mode) mkdir((path),(mode))
337 /* With SD386 it is impossible to debug register variables. */
338 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
342 /* Our private OS/2 specific data. */
344 typedef struct OS2_Perl_data {
349 unsigned long severity;
350 unsigned long phmq; /* Handle to message queue */
351 unsigned long phmq_refcnt;
352 unsigned long phmq_servers;
353 unsigned long initial_mode; /* VIO etc. mode we were started in */
356 extern OS2_Perl_data_t OS2_Perl_data;
358 #define Perl_hab ((HAB)OS2_Perl_data.phab)
359 #define Perl_rc (OS2_Perl_data.rc)
360 #define Perl_severity (OS2_Perl_data.severity)
361 #define errno_isOS2 12345678
362 #define errno_isOS2_set 12345679
363 #define OS2_Perl_flags (OS2_Perl_data.flags)
364 #define Perl_HAB_set_f 1
365 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
366 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
367 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
368 #define _obtain_Perl_HAB (init_PMWIN_entries(), \
369 Perl_hab = (*PMWIN_entries.Initialize)(0), \
370 set_Perl_HAB_f, Perl_hab)
371 #define perl_hab_GET() (Perl_HAB_set ? Perl_hab : _obtain_Perl_HAB)
372 #define Acquire_hab() perl_hab_GET()
373 #define Perl_hmq ((HMQ)OS2_Perl_data.phmq)
374 #define Perl_hmq_refcnt (OS2_Perl_data.phmq_refcnt)
375 #define Perl_hmq_servers (OS2_Perl_data.phmq_servers)
376 #define Perl_os2_initial_mode (OS2_Perl_data.initial_mode)
378 unsigned long Perl_hab_GET();
379 unsigned long Perl_Register_MQ(int serve);
380 void Perl_Deregister_MQ(int serve);
381 int Perl_Serve_Messages(int force);
382 /* Cannot prototype with I32 at this point. */
383 int Perl_Process_Messages(int force, long *cntp);
384 char *os2_execname(pTHX);
387 struct PMWIN_entries_t {
388 unsigned long (*Initialize)( unsigned long fsOptions );
389 unsigned long (*CreateMsgQueue)(unsigned long hab, long cmsg);
390 int (*DestroyMsgQueue)(unsigned long hmq);
391 int (*PeekMsg)(unsigned long hab, struct _QMSG *pqmsg,
392 unsigned long hwndFilter, unsigned long msgFilterFirst,
393 unsigned long msgFilterLast, unsigned long fl);
394 int (*GetMsg)(unsigned long hab, struct _QMSG *pqmsg,
395 unsigned long hwndFilter, unsigned long msgFilterFirst,
396 unsigned long msgFilterLast);
397 void * (*DispatchMsg)(unsigned long hab, struct _QMSG *pqmsg);
399 extern struct PMWIN_entries_t PMWIN_entries;
400 void init_PMWIN_entries(void);
402 #define perl_hmq_GET(serve) Perl_Register_MQ(serve)
403 #define perl_hmq_UNSET(serve) Perl_Deregister_MQ(serve)
405 #define OS2_XS_init() (*OS2_Perl_data.xs_init)(aTHX)
407 #if _EMX_CRT_REV_ >= 60
408 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2_set, \
411 # define os2_setsyserrno(rc) (Perl_rc = rc, errno = errno_isOS2)
414 /* The expressions below return true on error. */
415 /* INCL_DOSERRORS needed. rc should be declared outside. */
416 #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
417 /* INCL_WINERRORS needed. */
418 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
419 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
420 #define FillOSError(rc) (os2_setsyserrno(rc), \
421 Perl_severity = SEVERITY_ERROR)
422 #define FillWinError (Perl_severity = ERRORIDSEV(Perl_rc), \
423 Perl_rc = ERRORIDERROR(Perl_rc)), \
424 os2_setsyserrno(Perl_rc)
426 #define STATIC_FILE_LENGTH 127
428 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
429 char *perllib_mangle(char *, unsigned int);
431 char *os2error(int rc);
433 /* ************************************************************ */
434 #define Dos32QuerySysState DosQuerySysState
435 #define QuerySysState(flags, pid, buf, bufsz) \
436 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
438 #define QSS_PROCESS 1
440 #define QSS_SEMAPHORES 2
441 #define QSS_FILE 8 /* Buggy until fixpack18 */
442 #define QSS_SHARED 16
446 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
447 ULONG _res_,PVOID buf,ULONG bufsz);
452 } QGLOBAL, *PQGLOBAL;
463 UCHAR _reserved1_; /* padding to ULONG */
464 USHORT _reserved2_; /* padding to ULONG */
465 } QTHREAD, *PQTHREAD;
480 typedef struct qfile {
508 } QPROCESS, *PQPROCESS;
510 typedef struct sema {
527 } QSEMSTRUC, *PQSEMSTRUC;
532 } QSEMOWNER32, *PQSEMOWNER32;
537 PVOID semrecs; /* array of associated sema's */
541 USHORT _reserved_; /* padding to ULONG */
542 } QSEMSMUX32, *PQSEMSMUX32;
550 } QSEMEV32, *PQSEMEV32;
559 USHORT _reserved_; /* padding to ULONG */
560 } QSEMMUX32, *PQSEMMUX32;
562 typedef struct semstr32 {
567 } QSEMSTRUC32, *PQSEMSTRUC32;
569 typedef struct shrmem {
575 } QSHRMEM, *PQSHRMEM;
577 typedef struct module {
586 } QMODULE, *PQMODULE;
592 PQSEMSTRUC32 sem32data;
597 } QTOPLEVEL, *PQTOPLEVEL;
598 /* ************************************************************ */
600 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);