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