This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
parts/inc/parse_version: Call fcn to not duplicate logic
[perl5.git] / dosish.h
1 /*    dosish.h
2  *
3  *    Copyright (C) 1993, 1994, 1996, 1997, 1998, 1999,
4  *    2000, 2001, 2002, 2007, by Larry Wall and others
5  *
6  *    You may distribute under the terms of either the GNU General Public
7  *    License or the Artistic License, as specified in the README file.
8  *
9  */
10 #define ABORT() abort();
11
12 #ifndef SH_PATH
13 #define SH_PATH "/bin/sh"
14 #endif
15
16 #ifdef DJGPP
17 #  define BIT_BUCKET "nul"
18 #  define OP_BINARY O_BINARY
19 #  define PERL_SYS_INIT_BODY(c,v)                                       \
20          MALLOC_CHECK_TAINT2(*c,*v) Perl_DJGPP_init(c,v); PERLIO_INIT
21 #  define init_os_extras Perl_init_os_extras
22 #  define HAS_UTIME
23 #  define HAS_KILL
24    char *djgpp_pathexp (const char*);
25    void Perl_DJGPP_init (int *argcp,char ***argvp);
26 #  if (DJGPP==2 && DJGPP_MINOR < 2)
27 #    define NO_LOCALECONV_MON_THOUSANDS_SEP
28 #  endif
29 #  ifndef PERL_CORE
30 #    define PERL_FS_VER_FMT     "%d_%d_%d"
31 #  endif
32 #  define PERL_FS_VERSION       STRINGIFY(PERL_REVISION) "_" \
33                                 STRINGIFY(PERL_VERSION) "_" \
34                                 STRINGIFY(PERL_SUBVERSION)
35 #elif defined(WIN32)
36 #  define PERL_SYS_INIT_BODY(c,v)                                       \
37       MALLOC_CHECK_TAINT2(*c,*v) Perl_win32_init(c,v); PERLIO_INIT
38 #  define PERL_SYS_TERM_BODY()   Perl_win32_term()
39 #  define BIT_BUCKET "nul"
40 #elif defined(NETWARE)
41 #  define PERL_SYS_INIT_BODY(c,v)                                       \
42     MALLOC_CHECK_TAINT2(*c,*v) Perl_nw5_init(c,v); PERLIO_INIT
43 #  define BIT_BUCKET "nwnul"
44 #else
45 #  define PERL_SYS_INIT_BODY(c,v)               \
46     MALLOC_CHECK_TAINT2(*c,*v); PERLIO_INIT
47 #  define BIT_BUCKET "\\dev\\nul" /* "wanna be like, umm, Newlined, or somethin?" */
48 #endif
49
50 #ifndef PERL_SYS_TERM_BODY
51 #  define PERL_SYS_TERM_BODY()                         \
52     HINTS_REFCNT_TERM; KEYWORD_PLUGIN_MUTEX_TERM;      \
53     OP_CHECK_MUTEX_TERM; OP_REFCNT_TERM; PERLIO_TERM;  \
54     MALLOC_TERM; LOCALE_TERM; USER_PROP_MUTEX_TERM;
55 #endif
56 #define dXSUB_SYS dNOOP
57
58 /* USEMYBINMODE
59  *      This symbol, if defined, indicates that the program should
60  *      use the routine my_binmode(FILE *fp, char iotype, int mode) to insure
61  *      that a file is in "binary" mode -- that is, that no translation
62  *      of bytes occurs on read or write operations.
63  */
64 #undef USEMYBINMODE
65
66 /* Stat_t:
67  *      This symbol holds the type used to declare buffers for information
68  *      returned by stat().  It's usually just struct stat.  It may be necessary
69  *      to include <sys/stat.h> and <sys/types.h> to get any typedef'ed
70  *      information.
71  */
72 #if defined(WIN64) || defined(USE_LARGE_FILES)
73 #  define Stat_t struct _stati64
74 #else
75 #  define Stat_t struct stat
76 #endif
77
78 /* USE_STAT_RDEV:
79  *      This symbol is defined if this system has a stat structure declaring
80  *      st_rdev
81  */
82 #define USE_STAT_RDEV   /**/
83
84 /* ACME_MESS:
85  *      This symbol, if defined, indicates that error messages should be 
86  *      should be generated in a format that allows the use of the Acme
87  *      GUI/editor's autofind feature.
88  */
89 #undef ACME_MESS        /**/
90
91 /* ALTERNATE_SHEBANG:
92  *      This symbol, if defined, contains a "magic" string which may be used
93  *      as the first line of a Perl program designed to be executed directly
94  *      by name, instead of the standard Unix #!.  If ALTERNATE_SHEBANG
95  *      begins with a character other then #, then Perl will only treat
96  *      it as a command line if it finds the string "perl" in the first
97  *      word; otherwise it's treated as the first line of code in the script.
98  *      (IOW, Perl won't hand off to another interpreter via an alternate
99  *      shebang sequence that might be legal Perl code.)
100  */
101 /* #define ALTERNATE_SHEBANG "#!" / **/
102
103 #include <signal.h>
104
105 /*
106  * fwrite1() should be a routine with the same calling sequence as fwrite(),
107  * but which outputs all of the bytes requested as a single stream (unlike
108  * fwrite() itself, which on some systems outputs several distinct records
109  * if the number_of_items parameter is >1).
110  */
111 #define fwrite1 fwrite
112
113 #define Fstat(fd,bufptr)   fstat((fd),(bufptr))
114 #ifdef DJGPP
115 #   define Fflush(fp)      djgpp_fflush(fp)
116 #else
117 #   define Fflush(fp)      fflush(fp)
118 #endif
119 #define Mkdir(path,mode)   mkdir((path),(mode))
120
121 #ifndef WIN32
122 #  define Stat(fname,bufptr) stat((fname),(bufptr))
123 #else
124 #  define HAS_IOCTL
125 #  define HAS_UTIME
126 #  define HAS_KILL
127 #  define HAS_WAIT
128 #  define HAS_CHOWN
129 #endif  /* WIN32 */
130
131 /*
132  * <rich@phekda.freeserve.co.uk>: The DJGPP port has code that converts
133  * the return code of system() into the form that Unixy wait usually
134  * returns:
135  *
136  * - signal number in bits 0-6;
137  * - core dump flag in bit 7;
138  * - exit code in bits 8-15.
139  *
140  * Bits 0-7 are always zero for DJGPP, because it uses system().
141  * See djgpp.c.
142  *
143  * POSIX::W* use the W* macros from <sys/wait.h> to decode
144  * the return code. Unfortunately the W* macros for DJGPP use
145  * a different format than Unixy wait does. So there's a mismatch
146  * and, say, WEXITSTATUS($?) will return bogus values.
147  *
148  * So here we add hack to redefine the W* macros from DJGPP's <sys/wait.h>
149  * to work with our return-code conversion.
150  */
151
152 #ifdef DJGPP
153
154 #include <sys/wait.h>
155
156 #undef WEXITSTATUS
157 #undef WIFEXITED
158 #undef WIFSIGNALED
159 #undef WIFSTOPPED
160 #undef WNOHANG
161 #undef WSTOPSIG
162 #undef WTERMSIG
163 #undef WUNTRACED
164
165 #define WEXITSTATUS(stat_val) ((stat_val) >> 8)
166 #define WIFEXITED(stat_val)   0
167 #define WIFSIGNALED(stat_val) 0
168 #define WIFSTOPPED(stat_val)  0
169 #define WNOHANG               0
170 #define WSTOPSIG(stat_val)    0
171 #define WTERMSIG(stat_val)    0
172 #define WUNTRACED             0
173
174 #endif
175
176 /* Don't go reading from /dev/urandom */
177 #define PERL_NO_DEV_RANDOM
178
179 /*
180  * ex: set ts=8 sts=4 sw=4 et:
181  */