perl 5.003_01: lib/File/Basename.pm
[p5sagit/p5-mst-13.2.git] / os2 / os2ish.h
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
17
18 #ifndef SIGABRT
19 #    define SIGABRT SIGILL
20 #endif
21 #ifndef SIGILL
22 #    define SIGILL 6         /* blech */
23 #endif
24 #define ABORT() kill(getpid(),SIGABRT);
25
26 #define BIT_BUCKET "/dev/null"  /* Will this work? */
27
28 void Perl_OS2_init();
29
30 #define PERL_SYS_INIT(argcp, argvp) STMT_START {        \
31     _response(argcp, argvp);                    \
32     _wildcard(argcp, argvp);                    \
33     Perl_OS2_init();    } STMT_END
34
35 #define PERL_SYS_TERM()
36
37 #define dXSUB_SYS int fake = OS2_XS_init()
38
39 #define TMPPATH tmppath
40 #define TMPPATH1 "plXXXXXX"
41 extern char *tmppath;
42
43 /*
44  * fwrite1() should be a routine with the same calling sequence as fwrite(),
45  * but which outputs all of the bytes requested as a single stream (unlike
46  * fwrite() itself, which on some systems outputs several distinct records
47  * if the number_of_items parameter is >1).
48  */
49 #define fwrite1 fwrite
50
51 #define my_getenv(var) getenv(var)
52
53 /*****************************************************************************/
54
55 #include <stdlib.h>     /* before the following definitions */
56 #include <unistd.h>     /* before the following definitions */
57
58 #define chdir   _chdir2
59 #define getcwd  _getcwd2
60
61 /* This guy is needed for quick stdstd  */
62
63 #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) && defined(STDIO_CNT_LVALUE)
64 #  define _filbuf _fill
65         /* Perl uses ungetc only with successful return */
66 #  define ungetc(c,fp) \
67         (FILE_ptr(fp) > FILE_base(fp) && c == (int)*(FILE_ptr(fp) - 1) \
68          ? (--FILE_ptr(fp), ++FILE_cnt(fp), (int)c) : ungetc(c,fp))
69 #endif
70
71 #define OP_BINARY O_BINARY
72
73 #define OS2_STAT_HACK 1
74 #if OS2_STAT_HACK
75
76 #define Stat(fname,bufptr) os2_stat((fname),(bufptr))
77 #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
78 #define Fflush(fp)         fflush(fp)
79
80 #undef S_IFBLK
81 #undef S_ISBLK
82 #define S_IFBLK         0120000
83 #define S_ISBLK(mode)   (((mode) & S_IFMT) == S_IFBLK)
84
85 #else
86
87 #define Stat(fname,bufptr) stat((fname),(bufptr))
88 #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
89 #define Fflush(fp)         fflush(fp)
90
91 #endif
92
93 /* Our private OS/2 specific data. */
94
95 typedef struct OS2_Perl_data {
96   unsigned long flags;
97   unsigned long phab;
98   int (*xs_init)();
99 } OS2_Perl_data_t;
100
101 extern OS2_Perl_data_t OS2_Perl_data;
102
103 #define hab             ((HAB)OS2_Perl_data->phab)
104 #define OS2_Perl_flag   (OS2_Perl_data->flag)
105 #define Perl_HAB_set_f  1
106 #define Perl_HAB_set    (OS2_Perl_flag & Perl_HAB_set_f)
107 #define set_Perl_HAB_f  (OS2_Perl_flag |= Perl_HAB_set_f)
108 #define set_Perl_HAB(h) (set_Perl_HAB_f, hab = h)
109 #define OS2_XS_init() (*OS2_Perl_data.xs_init)()