perl 5.003_06: dump.c embed.h gv.c run.c
[p5sagit/p5-mst-13.2.git] / os2 / os2ish.h
CommitLineData
4633a7c4 1#include <signal.h>
2
3/* HAS_IOCTL:
4 * This symbol, if defined, indicates that the ioctl() routine is
5 * available to set I/O characteristics
6 */
7#define HAS_IOCTL /**/
8
9/* HAS_UTIME:
10 * This symbol, if defined, indicates that the routine utime() is
11 * available to update the access and modification times of files.
12 */
13#define HAS_UTIME /**/
14
15#define HAS_KILL
16#define HAS_WAIT
4ea6d94f 17#define HAS_DLERROR
18
19/* USEMYBINMODE
20 * This symbol, if defined, indicates that the program should
21 * use the routine my_binmode(FILE *fp, char iotype) to insure
22 * that a file is in "binary" mode -- that is, that no translation
23 * of bytes occurs on read or write operations.
24 */
25#undef USEMYBINMODE
26
27/* USE_STAT_RDEV:
28 * This symbol is defined if this system has a stat structure declaring
29 * st_rdev
30 */
31#define USE_STAT_RDEV /**/
32
33/* ACME_MESS:
34 * This symbol, if defined, indicates that error messages should be
35 * should be generated in a format that allows the use of the Acme
36 * GUI/editor's autofind feature.
37 */
38#undef ACME_MESS /**/
4633a7c4 39
40#ifndef SIGABRT
41# define SIGABRT SIGILL
42#endif
43#ifndef SIGILL
44# define SIGILL 6 /* blech */
45#endif
46#define ABORT() kill(getpid(),SIGABRT);
47
760ac839 48#define BIT_BUCKET "/dev/nul" /* Will this work? */
c07a80fd 49
5ae7bdf7 50/* SH_PATH_INI:
51 * Duplicate for SH_PATH. This symbol allows redefinition of SH_PATH,
52 * which may be needed to make a binary distribution.
53 */
54#define SH_PATH_INI SH_PATH /**/
55
365eb7b5 56void Perl_OS2_init();
57
58#define PERL_SYS_INIT(argcp, argvp) STMT_START { \
eacfb5f1 59 _response(argcp, argvp); \
c0c09dfd 60 _wildcard(argcp, argvp); \
365eb7b5 61 Perl_OS2_init(); } STMT_END
62
63#define PERL_SYS_TERM()
64
4ea6d94f 65/* #define PERL_SYS_TERM() STMT_START { \
66 if (Perl_HAB_set) WinTerminate(Perl_hab); } STMT_END */
67
365eb7b5 68#define dXSUB_SYS int fake = OS2_XS_init()
eacfb5f1 69
4ea6d94f 70#ifdef PERL_IS_AOUT
760ac839 71# define HAS_FORK
72/* # define HIDEMYMALLOC */
73/* # define PERL_SBRK_VIA_MALLOC */ /* gets off-page sbrk... */
74#else /* !PERL_IS_AOUT */
75# ifndef PERL_FOR_X2P
76# define USE_PERL_SBRK
77# endif
78# define SYSTEM_ALLOC(a) sys_alloc(a)
79
80void *sys_alloc(int size);
81
82#endif /* !PERL_IS_AOUT */
4ea6d94f 83
c0c09dfd 84#define TMPPATH tmppath
85#define TMPPATH1 "plXXXXXX"
86extern char *tmppath;
eacfb5f1 87
4633a7c4 88/*
89 * fwrite1() should be a routine with the same calling sequence as fwrite(),
90 * but which outputs all of the bytes requested as a single stream (unlike
91 * fwrite() itself, which on some systems outputs several distinct records
92 * if the number_of_items parameter is >1).
93 */
94#define fwrite1 fwrite
95
96#define my_getenv(var) getenv(var)
97
98/*****************************************************************************/
99
100#include <stdlib.h> /* before the following definitions */
101#include <unistd.h> /* before the following definitions */
102
103#define chdir _chdir2
104#define getcwd _getcwd2
105
106/* This guy is needed for quick stdstd */
107
108#if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
109# define _filbuf _fill
110 /* Perl uses ungetc only with successful return */
111# define ungetc(c,fp) \
112 (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
113 ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
114#endif
115
116#define OP_BINARY O_BINARY
117
118#define OS2_STAT_HACK 1
119#if OS2_STAT_HACK
120
121#define Stat(fname,bufptr) os2_stat((fname),(bufptr))
122#define Fstat(fd,bufptr) fstat((fd),(bufptr))
365eb7b5 123#define Fflush(fp) fflush(fp)
4633a7c4 124
125#undef S_IFBLK
126#undef S_ISBLK
127#define S_IFBLK 0120000
128#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
129
130#else
131
132#define Stat(fname,bufptr) stat((fname),(bufptr))
133#define Fstat(fd,bufptr) fstat((fd),(bufptr))
365eb7b5 134#define Fflush(fp) fflush(fp)
4633a7c4 135
136#endif
365eb7b5 137
138/* Our private OS/2 specific data. */
139
140typedef struct OS2_Perl_data {
141 unsigned long flags;
142 unsigned long phab;
143 int (*xs_init)();
4ea6d94f 144 unsigned long rc;
145 unsigned long severity;
365eb7b5 146} OS2_Perl_data_t;
147
148extern OS2_Perl_data_t OS2_Perl_data;
149
4ea6d94f 150#define Perl_hab ((HAB)OS2_Perl_data.phab)
151#define Perl_rc (OS2_Perl_data.rc)
152#define Perl_severity (OS2_Perl_data.severity)
153#define errno_isOS2 12345678
154#define OS2_Perl_flags (OS2_Perl_data.flags)
365eb7b5 155#define Perl_HAB_set_f 1
4ea6d94f 156#define Perl_HAB_set (OS2_Perl_flags & Perl_HAB_set_f)
157#define set_Perl_HAB_f (OS2_Perl_flags |= Perl_HAB_set_f)
158#define set_Perl_HAB(h) (set_Perl_HAB_f, Perl_hab = h)
365eb7b5 159#define OS2_XS_init() (*OS2_Perl_data.xs_init)()
4ea6d94f 160/* The expressions below return true on error. */
161/* INCL_DOSERRORS needed. */
162#define CheckOSError(expr) (!(rc = (expr)) ? 0 : (FillOSError(rc), 1))
163/* INCL_WINERRORS needed. */
164#define SaveWinError(expr) ((expr) ? : (FillWinError, 0))
165#define CheckWinError(expr) ((expr) ? 0: (FillWinError, 1))
166#define FillOSError(rc) (Perl_rc = rc, \
167 errno = errno_isOS2, \
168 Perl_severity = SEVERITY_ERROR)
169#define FillWinError (Perl_rc = WinGetLastError(Perl_hab), \
170 errno = errno_isOS2, \
171 Perl_severity = ERRORIDSEV(Perl_rc), \
172 Perl_rc = ERRORIDERROR(Perl_rc))
173#define Acquire_hab() if (!Perl_HAB_set) { \
174 Perl_hab = WinInitialize(0); \
175 if (!Perl_hab) die("WinInitialize failed"); \
176 set_Perl_HAB_f; \
177 }
178
760ac839 179#define STATIC_FILE_LENGTH 127
180extern char sh_path[STATIC_FILE_LENGTH+1];
5ae7bdf7 181#undef SH_PATH
4ea6d94f 182#define SH_PATH sh_path
760ac839 183#define PERLLIB_MANGLE(s, n) perllib_mangle((s), (n))
184char *perllib_mangle(char *, unsigned int);
4ea6d94f 185
186char *os2error(int rc);
187
188/* ************************************************************ */
189#define Dos32QuerySysState DosQuerySysState
190#define QuerySysState(flags, pid, buf, bufsz) \
191 Dos32QuerySysState(flags, 0, pid, 0, buf, bufsz)
192
193#define QSS_PROCESS 1
194#define QSS_MODULE 2
195#define QSS_SEMAPHORES 4
196#define QSS_FILE 8 /* Buggy until fixpack18 */
197#define QSS_SHARED 16
198
199#ifdef _OS2EMX_H
200
201APIRET APIENTRY Dos32QuerySysState(ULONG func,ULONG arg1,ULONG pid,
202 ULONG _res_,PVOID buf,ULONG bufsz);
203typedef struct {
204 ULONG threadcnt;
205 ULONG proccnt;
206 ULONG modulecnt;
207} QGLOBAL, *PQGLOBAL;
208
209typedef struct {
210 ULONG rectype;
211 USHORT threadid;
212 USHORT slotid;
213 ULONG sleepid;
214 ULONG priority;
215 ULONG systime;
216 ULONG usertime;
217 UCHAR state;
218 UCHAR _reserved1_; /* padding to ULONG */
219 USHORT _reserved2_; /* padding to ULONG */
220} QTHREAD, *PQTHREAD;
221
222typedef struct {
223 USHORT sfn;
224 USHORT refcnt;
225 USHORT flags1;
226 USHORT flags2;
227 USHORT accmode1;
228 USHORT accmode2;
229 ULONG filesize;
230 USHORT volhnd;
231 USHORT attrib;
232 USHORT _reserved_;
233} QFDS, *PQFDS;
234
235typedef struct qfile {
236 ULONG rectype;
237 struct qfile *next;
238 ULONG opencnt;
239 PQFDS filedata;
240 char name[1];
241} QFILE, *PQFILE;
242
243typedef struct {
244 ULONG rectype;
245 PQTHREAD threads;
246 USHORT pid;
247 USHORT ppid;
248 ULONG type;
249 ULONG state;
250 ULONG sessid;
251 USHORT hndmod;
252 USHORT threadcnt;
253 ULONG privsem32cnt;
254 ULONG _reserved2_;
255 USHORT sem16cnt;
256 USHORT dllcnt;
257 USHORT shrmemcnt;
258 USHORT fdscnt;
259 PUSHORT sem16s;
260 PUSHORT dlls;
261 PUSHORT shrmems;
262 PUSHORT fds;
263} QPROCESS, *PQPROCESS;
264
265typedef struct sema {
266 struct sema *next;
267 USHORT refcnt;
268 UCHAR sysflags;
269 UCHAR sysproccnt;
270 ULONG _reserved1_;
271 USHORT index;
272 CHAR name[1];
273} QSEMA, *PQSEMA;
274
275typedef struct {
276 ULONG rectype;
277 ULONG _reserved1_;
278 USHORT _reserved2_;
279 USHORT syssemidx;
280 ULONG index;
281 QSEMA sema;
282} QSEMSTRUC, *PQSEMSTRUC;
283
284typedef struct {
285 USHORT pid;
286 USHORT opencnt;
287} QSEMOWNER32, *PQSEMOWNER32;
288
289typedef struct {
290 PQSEMOWNER32 own;
291 PCHAR name;
292 PVOID semrecs; /* array of associated sema's */
293 USHORT flags;
294 USHORT semreccnt;
295 USHORT waitcnt;
296 USHORT _reserved_; /* padding to ULONG */
297} QSEMSMUX32, *PQSEMSMUX32;
298
299typedef struct {
300 PQSEMOWNER32 own;
301 PCHAR name;
302 PQSEMSMUX32 mux;
303 USHORT flags;
304 USHORT postcnt;
305} QSEMEV32, *PQSEMEV32;
306
307typedef struct {
308 PQSEMOWNER32 own;
309 PCHAR name;
310 PQSEMSMUX32 mux;
311 USHORT flags;
312 USHORT refcnt;
313 USHORT thrdnum;
314 USHORT _reserved_; /* padding to ULONG */
315} QSEMMUX32, *PQSEMMUX32;
316
317typedef struct semstr32 {
318 struct semstr *next;
319 QSEMEV32 evsem;
320 QSEMMUX32 muxsem;
321 QSEMSMUX32 smuxsem;
322} QSEMSTRUC32, *PQSEMSTRUC32;
323
324typedef struct shrmem {
325 struct shrmem *next;
326 USHORT hndshr;
327 USHORT selshr;
328 USHORT refcnt;
329 CHAR name[1];
330} QSHRMEM, *PQSHRMEM;
331
332typedef struct module {
333 struct module *next;
334 USHORT hndmod;
335 USHORT type;
336 ULONG refcnt;
337 ULONG segcnt;
338 PVOID _reserved_;
339 PCHAR name;
340 USHORT modref[1];
341} QMODULE, *PQMODULE;
342
343typedef struct {
344 PQGLOBAL gbldata;
345 PQPROCESS procdata;
346 PQSEMSTRUC semadata;
347 PQSEMSTRUC32 sem32data;
348 PQSHRMEM shrmemdata;
349 PQMODULE moddata;
350 PVOID _reserved2_;
351 PQFILE filedata;
352} QTOPLEVEL, *PQTOPLEVEL;
353/* ************************************************************ */
354
355PQTOPLEVEL get_sysinfo(ULONG pid, ULONG flags);
356
357#endif /* _OS2EMX_H */
5ae7bdf7 358