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) 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 is defined if this system has a stat structure declaring
32 #define USE_STAT_RDEV /**/
35 * This symbol, if defined, indicates that error messages should be
36 * should be generated in a format that allows the use of the Acme
37 * GUI/editor's autofind feature.
42 * This symbol, if defined, contains a "magic" string which may be used
43 * as the first line of a Perl program designed to be executed directly
44 * by name, instead of the standard Unix #!. If ALTERNATE_SHEBANG
45 * begins with a character other then #, then Perl will only treat
46 * it as a command line if if finds the string "perl" in the first
47 * word; otherwise it's treated as the first line of code in the script.
48 * (IOW, Perl won't hand off to another interpreter via an alternate
49 * shebang sequence that might be legal Perl code.)
51 #define ALTERNATE_SHEBANG "extproc "
54 # define SIGABRT SIGILL
57 # define SIGILL 6 /* blech */
59 #define ABORT() kill(getpid(),SIGABRT);
61 #define BIT_BUCKET "/dev/nul" /* Will this work? */
63 #if defined(I_SYS_UN) && !defined(TCPIPV4)
64 /* It is not working without TCPIPV4 defined. */
70 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
74 #define MUTEX_INIT(m) \
77 if ((rc = _rmutex_create(m,0))) \
78 croak("panic: MUTEX_INIT: rc=%i", rc); \
80 #define MUTEX_LOCK(m) \
83 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
84 croak("panic: MUTEX_LOCK: rc=%i", rc); \
86 #define MUTEX_UNLOCK(m) \
89 if ((rc = _rmutex_release(m))) \
90 croak("panic: MUTEX_UNLOCK: rc=%i", rc); \
92 #define MUTEX_DESTROY(m) \
95 if ((rc = _rmutex_close(m))) \
96 croak("panic: MUTEX_DESTROY: rc=%i", rc); \
99 #define COND_INIT(c) \
102 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
103 croak("panic: COND_INIT: rc=%i", rc); \
105 #define COND_SIGNAL(c) \
108 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED) \
109 croak("panic: COND_SIGNAL, rc=%ld", rc); \
111 #define COND_BROADCAST(c) \
114 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
115 croak("panic: COND_BROADCAST, rc=%i", rc); \
117 /* #define COND_WAIT(c, m) \
119 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
120 croak("panic: COND_WAIT"); \
123 #define COND_WAIT(c, m) os2_cond_wait(c,m)
125 #define COND_WAIT_win32(c, m) \
128 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE)))\
129 croak("panic: COND_WAIT"); \
133 #define COND_DESTROY(c) \
136 if ((rc = DosCloseEventSem(*(c)))) \
137 croak("panic: COND_DESTROY, rc=%i", rc); \
139 /*#define THR ((struct thread *) TlsGetValue(thr_key))
140 #define dTHR struct thread *thr = THR
143 #define pthread_getspecific(k) (*_threadstore())
144 #define pthread_setspecific(k,v) (*_threadstore()=v,0)
145 #define pthread_self() _gettid()
146 #define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
147 #define sched_yield() DosSleep(0)
149 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
150 int pthread_join(pthread_t tid, void **status);
151 int pthread_detach(pthread_t tid);
152 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
153 void *(*start_routine)(void*), void *arg);
156 #define THREADS_ELSEWHERE
160 void Perl_OS2_init(char **);
162 /* XXX This code hideously puts env inside: */
164 #define PERL_SYS_INIT(argcp, argvp) STMT_START { \
165 _response(argcp, argvp); \
166 _wildcard(argcp, argvp); \
167 Perl_OS2_init(env); } STMT_END
169 #define PERL_SYS_TERM() MALLOC_TERM
171 /* #define PERL_SYS_TERM() STMT_START { \
172 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
174 #define dXSUB_SYS OS2_XS_init()
177 /* # define HAS_FORK */
178 /* # define HIDEMYMALLOC */
179 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
180 #else /* !PERL_IS_AOUT */
181 # ifndef PERL_FOR_X2P
183 # define USE_PERL_SBRK
188 # define SYSTEM_ALLOC(a) sys_alloc(a)
190 void *sys_alloc(int size);
192 #endif /* !PERL_IS_AOUT */
193 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
197 #define TMPPATH tmppath
198 #define TMPPATH1 "plXXXXXX"
199 extern char *tmppath;
200 PerlIO *my_syspopen(char *cmd, char *mode);
201 /* Cannot prototype with I32 at this point. */
202 int my_syspclose(PerlIO *f);
203 FILE *my_tmpfile (void);
204 char *my_tmpnam (char *);
206 #define tmpfile my_tmpfile
207 #define tmpnam my_tmpnam
208 #define isatty _isterm
210 #define srand srandom
213 * fwrite1() should be a routine with the same calling sequence as fwrite(),
214 * but which outputs all of the bytes requested as a single stream (unlike
215 * fwrite() itself, which on some systems outputs several distinct records
216 * if the number_of_items parameter is >1).
218 #define fwrite1 fwrite
220 #define my_getenv(var) getenv(var)
221 #define flock my_flock
223 void *emx_calloc (size_t, size_t);
224 void emx_free (void *);
225 void *emx_malloc (size_t);
226 void *emx_realloc (void *, size_t);
228 /*****************************************************************************/
230 #include <stdlib.h> /* before the following definitions */
231 #include <unistd.h> /* before the following definitions */
233 #define chdir _chdir2
234 #define getcwd _getcwd2
236 /* This guy is needed for quick stdstd */
238 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
239 /* Perl uses ungetc only with successful return */
240 # define ungetc(c,fp) \
241 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
242 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
245 #define OP_BINARY O_BINARY
247 #define OS2_STAT_HACK 1
250 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
251 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
252 #define Fflush(fp) fflush(fp)
253 #define Mkdir(path,mode) mkdir((path),(mode))
257 #define S_IFBLK 0120000
258 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
262 #define Stat(fname,bufptr) stat((fname),(bufptr))
263 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
264 #define Fflush(fp) fflush(fp)
265 #define Mkdir(path,mode) mkdir((path),(mode))
269 /* With SD386 it is impossible to debug register variables. */
270 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
274 /* Our private OS/2 specific data. */
276 typedef struct OS2_Perl_data {
281 unsigned long severity;
284 extern OS2_Perl_data_t OS2_Perl_data;
286 #define Perl_hab ((HAB)OS2_Perl_data.phab)
287 #define Perl_rc (OS2_Perl_data.rc)
288 #define Perl_severity (OS2_Perl_data.severity)
289 #define errno_isOS2 12345678
290 #define OS2_Perl_flags (OS2_Perl_data.flags)
291 #define Perl_HAB_set_f 1
292 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
293 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
294 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
295 #define OS2_XS_init() (*OS2_Perl_data.xs_init)()
296 /* The expressions below return true on error. */
297 /* INCL_DOSERRORS needed. rc should be declared outside. */
298 #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
299 /* INCL_WINERRORS needed. */
300 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
301 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
302 #define FillOSError(rc) (Perl_rc = rc, \
303 errno = errno_isOS2, \
304 Perl_severity = SEVERITY_ERROR)
305 #define FillWinError (Perl_rc = WinGetLastError(Perl_hab), \
306 errno = errno_isOS2, \
307 Perl_severity = ERRORIDSEV(Perl_rc), \
308 Perl_rc = ERRORIDERROR(Perl_rc))
309 #define Acquire_hab() if (!Perl_HAB_set) { \
310 Perl_hab = WinInitialize(0); \
311 if (!Perl_hab) die("WinInitialize failed"); \
315 #define STATIC_FILE_LENGTH 127
317 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
318 char *perllib_mangle(char *, unsigned int);
320 char *os2error(int rc);
322 /* ************************************************************ */
323 #define Dos32QuerySysState DosQuerySysState
324 #define QuerySysState(flags, pid, buf, bufsz) \
325 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
327 #define QSS_PROCESS 1
329 #define QSS_SEMAPHORES 2
330 #define QSS_FILE 8 /* Buggy until fixpack18 */
331 #define QSS_SHARED 16
335 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
336 ULONG _res_,PVOID buf,ULONG bufsz);
341 } QGLOBAL, *PQGLOBAL;
352 UCHAR _reserved1_; /* padding to ULONG */
353 USHORT _reserved2_; /* padding to ULONG */
354 } QTHREAD, *PQTHREAD;
369 typedef struct qfile {
397 } QPROCESS, *PQPROCESS;
399 typedef struct sema {
416 } QSEMSTRUC, *PQSEMSTRUC;
421 } QSEMOWNER32, *PQSEMOWNER32;
426 PVOID semrecs; /* array of associated sema's */
430 USHORT _reserved_; /* padding to ULONG */
431 } QSEMSMUX32, *PQSEMSMUX32;
439 } QSEMEV32, *PQSEMEV32;
448 USHORT _reserved_; /* padding to ULONG */
449 } QSEMMUX32, *PQSEMMUX32;
451 typedef struct semstr32 {
456 } QSEMSTRUC32, *PQSEMSTRUC32;
458 typedef struct shrmem {
464 } QSHRMEM, *PQSHRMEM;
466 typedef struct module {
475 } QMODULE, *PQMODULE;
481 PQSEMSTRUC32 sem32data;
486 } QTOPLEVEL, *PQTOPLEVEL;
487 /* ************************************************************ */
489 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
491 #endif /* _OS2EMX_H */