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 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(getpid(),SIGABRT);
69 #define BIT_BUCKET "/dev/nul" /* Will this work? */
71 #if defined(I_SYS_UN) && !defined(TCPIPV4)
72 /* It is not working without TCPIPV4 defined. */
78 #define OS2_ERROR_ALREADY_POSTED 299 /* Avoid os2.h */
82 #define MUTEX_INIT(m) \
85 if ((rc = _rmutex_create(m,0))) \
86 croak("panic: MUTEX_INIT: rc=%i", rc); \
88 #define MUTEX_LOCK(m) \
91 if ((rc = _rmutex_request(m,_FMR_IGNINT))) \
92 croak("panic: MUTEX_LOCK: rc=%i", rc); \
94 #define MUTEX_UNLOCK(m) \
97 if ((rc = _rmutex_release(m))) \
98 croak("panic: MUTEX_UNLOCK: rc=%i", rc); \
100 #define MUTEX_DESTROY(m) \
103 if ((rc = _rmutex_close(m))) \
104 croak("panic: MUTEX_DESTROY: rc=%i", rc); \
107 #define COND_INIT(c) \
110 if ((rc = DosCreateEventSem(NULL,c,0,0))) \
111 croak("panic: COND_INIT: rc=%i", rc); \
113 #define COND_SIGNAL(c) \
116 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED) \
117 croak("panic: COND_SIGNAL, rc=%ld", rc); \
119 #define COND_BROADCAST(c) \
122 if ((rc = DosPostEventSem(*(c))) && rc != OS2_ERROR_ALREADY_POSTED)\
123 croak("panic: COND_BROADCAST, rc=%i", rc); \
125 /* #define COND_WAIT(c, m) \
127 if (WaitForSingleObject(*(c),INFINITE) == WAIT_FAILED) \
128 croak("panic: COND_WAIT"); \
131 #define COND_WAIT(c, m) os2_cond_wait(c,m)
133 #define COND_WAIT_win32(c, m) \
136 if ((rc = SignalObjectAndWait(*(m),*(c),INFINITE,FALSE)))\
137 croak("panic: COND_WAIT"); \
141 #define COND_DESTROY(c) \
144 if ((rc = DosCloseEventSem(*(c)))) \
145 croak("panic: COND_DESTROY, rc=%i", rc); \
147 /*#define THR ((struct thread *) TlsGetValue(PL_thr_key))
148 #define dTHR struct thread *thr = THR
151 #define pthread_getspecific(k) (*_threadstore())
152 #define pthread_setspecific(k,v) (*_threadstore()=v,0)
153 #define pthread_self() _gettid()
154 #define pthread_key_create(keyp,flag) (*keyp=_gettid(),0)
155 #define sched_yield() DosSleep(0)
157 #ifdef PTHREADS_INCLUDED /* For ./x2p stuff. */
158 int pthread_join(pthread_t tid, void **status);
159 int pthread_detach(pthread_t tid);
160 int pthread_create(pthread_t *tid, const pthread_attr_t *attr,
161 void *(*start_routine)(void*), void *arg);
164 #define THREADS_ELSEWHERE
168 void Perl_OS2_init(char **);
170 /* XXX This code hideously puts env inside: */
173 # define PERL_SYS_INIT(argcp, argvp) STMT_START { \
174 _response(argcp, argvp); \
175 _wildcard(argcp, argvp); \
176 Perl_OS2_init(env); } STMT_END
177 #else /* Compiling embedded Perl with non-EMX compiler */
178 # define PERL_SYS_INIT(argcp, argvp) STMT_START { \
179 Perl_OS2_init(env); } STMT_END
180 # define PERL_CALLCONV _System
182 #define PERL_SYS_TERM() MALLOC_TERM
184 /* #define PERL_SYS_TERM() STMT_START { \
185 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
187 #define dXSUB_SYS OS2_XS_init()
190 /* # define HAS_FORK */
191 /* # define HIDEMYMALLOC */
192 /* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
193 #else /* !PERL_IS_AOUT */
194 # ifndef PERL_FOR_X2P
196 # define USE_PERL_SBRK
201 # define SYSTEM_ALLOC(a) sys_alloc(a)
203 void *sys_alloc(int size);
205 #endif /* !PERL_IS_AOUT */
206 #if !defined(PERL_CORE) && !defined(PerlIO) /* a2p */
210 #define TMPPATH tmppath
211 #define TMPPATH1 "plXXXXXX"
212 extern char *tmppath;
213 PerlIO *my_syspopen(char *cmd, char *mode);
214 /* Cannot prototype with I32 at this point. */
215 int my_syspclose(PerlIO *f);
216 FILE *my_tmpfile (void);
217 char *my_tmpnam (char *);
219 #define tmpfile my_tmpfile
220 #define tmpnam my_tmpnam
221 #define isatty _isterm
223 #define srand srandom
226 * fwrite1() should be a routine with the same calling sequence as fwrite(),
227 * but which outputs all of the bytes requested as a single stream (unlike
228 * fwrite() itself, which on some systems outputs several distinct records
229 * if the number_of_items parameter is >1).
231 #define fwrite1 fwrite
233 #define my_getenv(var) getenv(var)
234 #define flock my_flock
236 void *emx_calloc (size_t, size_t);
237 void emx_free (void *);
238 void *emx_malloc (size_t);
239 void *emx_realloc (void *, size_t);
241 /*****************************************************************************/
243 #include <stdlib.h> /* before the following definitions */
244 #include <unistd.h> /* before the following definitions */
246 #define chdir _chdir2
247 #define getcwd _getcwd2
249 /* This guy is needed for quick stdstd */
251 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
252 /* Perl uses ungetc only with successful return */
253 # define ungetc(c,fp) \
254 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
255 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
258 #define OP_BINARY O_BINARY
260 #define OS2_STAT_HACK 1
263 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
264 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
265 #define Fflush(fp) fflush(fp)
266 #define Mkdir(path,mode) mkdir((path),(mode))
270 #define S_IFBLK 0120000
271 #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
275 #define Stat(fname,bufptr) stat((fname),(bufptr))
276 #define Fstat(fd,bufptr) fstat((fd),(bufptr))
277 #define Fflush(fp) fflush(fp)
278 #define Mkdir(path,mode) mkdir((path),(mode))
282 /* With SD386 it is impossible to debug register variables. */
283 #if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register)
287 /* Our private OS/2 specific data. */
289 typedef struct OS2_Perl_data {
294 unsigned long severity;
297 extern OS2_Perl_data_t OS2_Perl_data;
299 #define Perl_hab ((HAB)OS2_Perl_data.phab)
300 #define Perl_rc (OS2_Perl_data.rc)
301 #define Perl_severity (OS2_Perl_data.severity)
302 #define errno_isOS2 12345678
303 #define OS2_Perl_flags (OS2_Perl_data.flags)
304 #define Perl_HAB_set_f 1
305 #define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
306 #define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
307 #define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
308 #define OS2_XS_init() (*OS2_Perl_data.xs_init)()
309 /* The expressions below return true on error. */
310 /* INCL_DOSERRORS needed. rc should be declared outside. */
311 #define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
312 /* INCL_WINERRORS needed. */
313 #define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
314 #define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
315 #define FillOSError(rc) (Perl_rc = rc, \
316 errno = errno_isOS2, \
317 Perl_severity = SEVERITY_ERROR)
318 #define FillWinError (Perl_rc = WinGetLastError(Perl_hab), \
319 errno = errno_isOS2, \
320 Perl_severity = ERRORIDSEV(Perl_rc), \
321 Perl_rc = ERRORIDERROR(Perl_rc))
322 #define Acquire_hab() if (!Perl_HAB_set) { \
323 Perl_hab = WinInitialize(0); \
324 if (!Perl_hab) die("WinInitialize failed"); \
328 #define STATIC_FILE_LENGTH 127
330 #define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
331 char *perllib_mangle(char *, unsigned int);
333 char *os2error(int rc);
335 /* ************************************************************ */
336 #define Dos32QuerySysState DosQuerySysState
337 #define QuerySysState(flags, pid, buf, bufsz) \
338 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
340 #define QSS_PROCESS 1
342 #define QSS_SEMAPHORES 2
343 #define QSS_FILE 8 /* Buggy until fixpack18 */
344 #define QSS_SHARED 16
348 APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
349 ULONG _res_,PVOID buf,ULONG bufsz);
354 } QGLOBAL, *PQGLOBAL;
365 UCHAR _reserved1_; /* padding to ULONG */
366 USHORT _reserved2_; /* padding to ULONG */
367 } QTHREAD, *PQTHREAD;
382 typedef struct qfile {
410 } QPROCESS, *PQPROCESS;
412 typedef struct sema {
429 } QSEMSTRUC, *PQSEMSTRUC;
434 } QSEMOWNER32, *PQSEMOWNER32;
439 PVOID semrecs; /* array of associated sema's */
443 USHORT _reserved_; /* padding to ULONG */
444 } QSEMSMUX32, *PQSEMSMUX32;
452 } QSEMEV32, *PQSEMEV32;
461 USHORT _reserved_; /* padding to ULONG */
462 } QSEMMUX32, *PQSEMMUX32;
464 typedef struct semstr32 {
469 } QSEMSTRUC32, *PQSEMSTRUC32;
471 typedef struct shrmem {
477 } QSHRMEM, *PQSHRMEM;
479 typedef struct module {
488 } QMODULE, *PQMODULE;
494 PQSEMSTRUC32 sem32data;
499 } QTOPLEVEL, *PQTOPLEVEL;
500 /* ************************************************************ */
502 PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
504 #endif /* _OS2EMX_H */