1 | /************************************************
|
---|
2 |
|
---|
3 | defines.h -
|
---|
4 |
|
---|
5 | $Author: knu $
|
---|
6 | $Date: 2007-02-25 02:52:08 +0900 (Sun, 25 Feb 2007) $
|
---|
7 | created at: Wed May 18 00:21:44 JST 1994
|
---|
8 |
|
---|
9 | ************************************************/
|
---|
10 | #ifndef DEFINES_H
|
---|
11 | #define DEFINES_H
|
---|
12 |
|
---|
13 | #define RUBY
|
---|
14 |
|
---|
15 | #ifdef __cplusplus
|
---|
16 | # ifndef HAVE_PROTOTYPES
|
---|
17 | # define HAVE_PROTOTYPES 1
|
---|
18 | # endif
|
---|
19 | # ifndef HAVE_STDARG_PROTOTYPES
|
---|
20 | # define HAVE_STDARG_PROTOTYPES 1
|
---|
21 | # endif
|
---|
22 | #endif
|
---|
23 |
|
---|
24 | #undef _
|
---|
25 | #ifdef HAVE_PROTOTYPES
|
---|
26 | # define _(args) args
|
---|
27 | #else
|
---|
28 | # define _(args) ()
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #undef __
|
---|
32 | #ifdef HAVE_STDARG_PROTOTYPES
|
---|
33 | # define __(args) args
|
---|
34 | #else
|
---|
35 | # define __(args) ()
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | #ifdef __cplusplus
|
---|
39 | #define ANYARGS ...
|
---|
40 | #else
|
---|
41 | #define ANYARGS
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #define xmalloc ruby_xmalloc
|
---|
45 | #define xcalloc ruby_xcalloc
|
---|
46 | #define xrealloc ruby_xrealloc
|
---|
47 | #define xfree ruby_xfree
|
---|
48 |
|
---|
49 | void *xmalloc _((long));
|
---|
50 | void *xcalloc _((long,long));
|
---|
51 | void *xrealloc _((void*,long));
|
---|
52 | void xfree _((void*));
|
---|
53 |
|
---|
54 | #if SIZEOF_LONG_LONG > 0
|
---|
55 | # define LONG_LONG long long
|
---|
56 | #elif SIZEOF___INT64 > 0
|
---|
57 | # define HAVE_LONG_LONG 1
|
---|
58 | # define LONG_LONG __int64
|
---|
59 | # undef SIZEOF_LONG_LONG
|
---|
60 | # define SIZEOF_LONG_LONG SIZEOF___INT64
|
---|
61 | #endif
|
---|
62 |
|
---|
63 | #if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
|
---|
64 | # define BDIGIT unsigned int
|
---|
65 | # define SIZEOF_BDIGITS SIZEOF_INT
|
---|
66 | # define BDIGIT_DBL unsigned LONG_LONG
|
---|
67 | # define BDIGIT_DBL_SIGNED LONG_LONG
|
---|
68 | #elif SIZEOF_INT*2 <= SIZEOF_LONG
|
---|
69 | # define BDIGIT unsigned int
|
---|
70 | # define SIZEOF_BDIGITS SIZEOF_INT
|
---|
71 | # define BDIGIT_DBL unsigned long
|
---|
72 | # define BDIGIT_DBL_SIGNED long
|
---|
73 | #elif SIZEOF_SHORT*2 <= SIZEOF_LONG
|
---|
74 | # define BDIGIT unsigned short
|
---|
75 | # define SIZEOF_BDIGITS SIZEOF_SHORT
|
---|
76 | # define BDIGIT_DBL unsigned long
|
---|
77 | # define BDIGIT_DBL_SIGNED long
|
---|
78 | #else
|
---|
79 | # define BDIGIT unsigned short
|
---|
80 | # define SIZEOF_BDIGITS (SIZEOF_LONG/2)
|
---|
81 | # define BDIGIT_DBL unsigned long
|
---|
82 | # define BDIGIT_DBL_SIGNED long
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | #ifdef __CYGWIN__
|
---|
86 | #undef _WIN32
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | #if defined(MSDOS) || defined(_WIN32) || defined(__human68k__) || defined(__EMX__)
|
---|
90 | #define DOSISH 1
|
---|
91 | #ifndef _WIN32_WCE
|
---|
92 | # define DOSISH_DRIVE_LETTER
|
---|
93 | #endif
|
---|
94 | #endif
|
---|
95 |
|
---|
96 | /* define RUBY_USE_EUC/SJIS for default kanji-code */
|
---|
97 | #ifndef DEFAULT_KCODE
|
---|
98 | #if defined(DOSISH) || defined(__CYGWIN__) || defined(__MACOS__) || defined(OS2)
|
---|
99 | #define DEFAULT_KCODE KCODE_SJIS
|
---|
100 | #else
|
---|
101 | #define DEFAULT_KCODE KCODE_EUC
|
---|
102 | #endif
|
---|
103 | #endif
|
---|
104 |
|
---|
105 | #ifdef __NeXT__
|
---|
106 | /* NextStep, OpenStep, Rhapsody */
|
---|
107 | #ifndef S_IRUSR
|
---|
108 | #define S_IRUSR 0000400 /* read permission, owner */
|
---|
109 | #endif
|
---|
110 | #ifndef S_IRGRP
|
---|
111 | #define S_IRGRP 0000040 /* read permission, group */
|
---|
112 | #endif
|
---|
113 | #ifndef S_IROTH
|
---|
114 | #define S_IROTH 0000004 /* read permission, other */
|
---|
115 | #endif
|
---|
116 | #ifndef S_IWUSR
|
---|
117 | #define S_IWUSR 0000200 /* write permission, owner */
|
---|
118 | #endif
|
---|
119 | #ifndef S_IWGRP
|
---|
120 | #define S_IWGRP 0000020 /* write permission, group */
|
---|
121 | #endif
|
---|
122 | #ifndef S_IWOTH
|
---|
123 | #define S_IWOTH 0000002 /* write permission, other */
|
---|
124 | #endif
|
---|
125 | #ifndef S_IXUSR
|
---|
126 | #define S_IXUSR 0000100 /* execute/search permission, owner */
|
---|
127 | #endif
|
---|
128 | #ifndef S_IXGRP
|
---|
129 | #define S_IXGRP 0000010 /* execute/search permission, group */
|
---|
130 | #endif
|
---|
131 | #ifndef S_IXOTH
|
---|
132 | #define S_IXOTH 0000001 /* execute/search permission, other */
|
---|
133 | #endif
|
---|
134 | #ifndef S_IRWXU
|
---|
135 | #define S_IRWXU 0000700 /* read, write, execute permissions, owner */
|
---|
136 | #endif
|
---|
137 | #ifndef S_IRWXG
|
---|
138 | #define S_IRWXG 0000070 /* read, write, execute permissions, group */
|
---|
139 | #endif
|
---|
140 | #ifndef S_IRWXO
|
---|
141 | #define S_IRWXO 0000007 /* read, write, execute permissions, other */
|
---|
142 | #endif
|
---|
143 | #ifndef S_ISBLK
|
---|
144 | #define S_ISBLK(mode) (((mode) & (0170000)) == (0060000))
|
---|
145 | #endif
|
---|
146 | #ifndef S_ISCHR
|
---|
147 | #define S_ISCHR(mode) (((mode) & (0170000)) == (0020000))
|
---|
148 | #endif
|
---|
149 | #ifndef S_ISDIR
|
---|
150 | #define S_ISDIR(mode) (((mode) & (0170000)) == (0040000))
|
---|
151 | #endif
|
---|
152 | #ifndef S_ISFIFO
|
---|
153 | #define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
|
---|
154 | #endif
|
---|
155 | #ifndef S_ISREG
|
---|
156 | #define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
|
---|
157 | #endif
|
---|
158 | /* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
|
---|
159 | result in a different endian. Instead trust __BIG_ENDIAN__ and
|
---|
160 | __LITTLE_ENDIAN__ which are set correctly by -arch. */
|
---|
161 | #undef WORDS_BIGENDIAN
|
---|
162 | #ifdef __BIG_ENDIAN__
|
---|
163 | #define WORDS_BIGENDIAN
|
---|
164 | #endif
|
---|
165 | #ifndef __APPLE__
|
---|
166 | /* NextStep, OpenStep (but not Rhapsody) */
|
---|
167 | #ifndef GETPGRP_VOID
|
---|
168 | #define GETPGRP_VOID 1
|
---|
169 | #endif
|
---|
170 | #ifndef WNOHANG
|
---|
171 | #define WNOHANG 01
|
---|
172 | #endif
|
---|
173 | #ifndef WUNTRACED
|
---|
174 | #define WUNTRACED 02
|
---|
175 | #endif
|
---|
176 | #ifndef X_OK
|
---|
177 | #define X_OK 1
|
---|
178 | #endif
|
---|
179 | #endif /* __APPLE__ */
|
---|
180 | #endif /* NeXT */
|
---|
181 |
|
---|
182 | #ifdef _WIN32
|
---|
183 | #include "win32/win32.h"
|
---|
184 | #endif
|
---|
185 |
|
---|
186 | #if defined(__VMS)
|
---|
187 | #include "vms.h"
|
---|
188 | #endif
|
---|
189 |
|
---|
190 | #if defined(__BEOS__)
|
---|
191 | #include <net/socket.h> /* intern.h needs fd_set definition */
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | #ifdef RUBY_EXPORT
|
---|
195 | #undef RUBY_EXTERN
|
---|
196 | #endif
|
---|
197 |
|
---|
198 | #ifndef RUBY_EXTERN
|
---|
199 | #define RUBY_EXTERN extern
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | #ifndef EXTERN
|
---|
203 | #define EXTERN RUBY_EXTERN /* deprecated */
|
---|
204 | #endif
|
---|
205 |
|
---|
206 | #ifndef RUBY_MBCHAR_MAXSIZE
|
---|
207 | #define RUBY_MBCHAR_MAXSIZE INT_MAX
|
---|
208 | /* MB_CUR_MAX will not work well in C locale */
|
---|
209 | #endif
|
---|
210 |
|
---|
211 | #if defined(sparc) || defined(__sparc__)
|
---|
212 | static inline void
|
---|
213 | flush_register_windows(void)
|
---|
214 | {
|
---|
215 | asm
|
---|
216 | #ifdef __GNUC__
|
---|
217 | volatile
|
---|
218 | #endif
|
---|
219 | # if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
|
---|
220 | ("flushw")
|
---|
221 | # elif defined(linux) || defined(__linux__)
|
---|
222 | ("ta 0x83")
|
---|
223 | # else /* Solaris, OpenBSD, NetBSD, etc. */
|
---|
224 | ("ta 0x03")
|
---|
225 | # endif /* trap always to flush register windows if we are on a Sparc system */
|
---|
226 | ;
|
---|
227 | }
|
---|
228 | # define FLUSH_REGISTER_WINDOWS flush_register_windows()
|
---|
229 | #elif defined(__ia64)
|
---|
230 | void *rb_ia64_bsp(void);
|
---|
231 | void rb_ia64_flushrs(void);
|
---|
232 | # define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
|
---|
233 | #else
|
---|
234 | # define FLUSH_REGISTER_WINDOWS ((void)0)
|
---|
235 | #endif
|
---|
236 |
|
---|
237 | #if defined(DOSISH)
|
---|
238 | #define PATH_SEP ";"
|
---|
239 | #elif defined(riscos)
|
---|
240 | #define PATH_SEP ","
|
---|
241 | #else
|
---|
242 | #define PATH_SEP ":"
|
---|
243 | #endif
|
---|
244 | #define PATH_SEP_CHAR PATH_SEP[0]
|
---|
245 |
|
---|
246 | #if defined(__human68k__)
|
---|
247 | #define PATH_ENV "path"
|
---|
248 | #else
|
---|
249 | #define PATH_ENV "PATH"
|
---|
250 | #endif
|
---|
251 |
|
---|
252 | #if defined(DOSISH) && !defined(__human68k__) && !defined(__EMX__)
|
---|
253 | #define ENV_IGNORECASE
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | #ifndef DLEXT_MAXLEN
|
---|
257 | #define DLEXT_MAXLEN 4
|
---|
258 | #endif
|
---|
259 |
|
---|
260 | #ifndef RUBY_PLATFORM
|
---|
261 | #define RUBY_PLATFORM "unknown-unknown"
|
---|
262 | #endif
|
---|
263 |
|
---|
264 | #endif
|
---|