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