Ruby  1.9.3p551(2014-11-13revision48407)
defines.h
Go to the documentation of this file.
1 /************************************************
2 
3  defines.h -
4 
5  $Author: kosaki $
6  created at: Wed May 18 00:21:44 JST 1994
7 
8 ************************************************/
9 
10 #ifndef RUBY_DEFINES_H
11 #define RUBY_DEFINES_H 1
12 
13 #if defined(__cplusplus)
14 extern "C" {
15 #if 0
16 } /* satisfy cc-mode */
17 #endif
18 #endif
19 
20 #include "ruby/config.h"
21 #ifdef RUBY_EXTCONF_H
22 #include RUBY_EXTCONF_H
23 #endif
24 
25 #define RUBY
26 
27 # include <stddef.h>
28 #ifdef HAVE_STDLIB_H
29 # include <stdlib.h>
30 #endif
31 #ifdef __cplusplus
32 # ifndef HAVE_PROTOTYPES
33 # define HAVE_PROTOTYPES 1
34 # endif
35 # ifndef HAVE_STDARG_PROTOTYPES
36 # define HAVE_STDARG_PROTOTYPES 1
37 # endif
38 #endif
39 
40 #undef _
41 #ifdef HAVE_PROTOTYPES
42 # define _(args) args
43 #else
44 # define _(args) ()
45 #endif
46 
47 #undef __
48 #ifdef HAVE_STDARG_PROTOTYPES
49 # define __(args) args
50 #else
51 # define __(args) ()
52 #endif
53 
54 #ifdef __cplusplus
55 #define ANYARGS ...
56 #else
57 #define ANYARGS
58 #endif
59 
60 #if defined __GNUC__ && __GNUC__ >= 4
61 #pragma GCC visibility push(default)
62 #endif
63 
64 #define xmalloc ruby_xmalloc
65 #define xmalloc2 ruby_xmalloc2
66 #define xcalloc ruby_xcalloc
67 #define xrealloc ruby_xrealloc
68 #define xrealloc2 ruby_xrealloc2
69 #define xfree ruby_xfree
70 
71 void *xmalloc(size_t);
72 void *xmalloc2(size_t,size_t);
73 void *xcalloc(size_t,size_t);
74 void *xrealloc(void*,size_t);
75 void *xrealloc2(void*,size_t,size_t);
76 void xfree(void*);
77 
78 #define STRINGIZE(expr) STRINGIZE0(expr)
79 #ifndef STRINGIZE0
80 #define STRINGIZE0(expr) #expr
81 #endif
82 
83 #if SIZEOF_LONG_LONG > 0
84 # define LONG_LONG long long
85 #elif SIZEOF___INT64 > 0
86 # define HAVE_LONG_LONG 1
87 # define LONG_LONG __int64
88 # undef SIZEOF_LONG_LONG
89 # define SIZEOF_LONG_LONG SIZEOF___INT64
90 #endif
91 
92 #if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
93 # define BDIGIT unsigned int
94 # define SIZEOF_BDIGITS SIZEOF_INT
95 # define BDIGIT_DBL unsigned LONG_LONG
96 # define BDIGIT_DBL_SIGNED LONG_LONG
97 # define PRI_BDIGIT_PREFIX ""
98 # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
99 #elif SIZEOF_INT*2 <= SIZEOF_LONG
100 # define BDIGIT unsigned int
101 # define SIZEOF_BDIGITS SIZEOF_INT
102 # define BDIGIT_DBL unsigned long
103 # define BDIGIT_DBL_SIGNED long
104 # define PRI_BDIGIT_PREFIX ""
105 # define PRI_BDIGIT_DBL_PREFIX "l"
106 #elif SIZEOF_SHORT*2 <= SIZEOF_LONG
107 # define BDIGIT unsigned short
108 # define SIZEOF_BDIGITS SIZEOF_SHORT
109 # define BDIGIT_DBL unsigned long
110 # define BDIGIT_DBL_SIGNED long
111 # define PRI_BDIGIT_PREFIX "h"
112 # define PRI_BDIGIT_DBL_PREFIX "l"
113 #else
114 # define BDIGIT unsigned short
115 # define SIZEOF_BDIGITS (SIZEOF_LONG/2)
116 # define BDIGIT_DBL unsigned long
117 # define BDIGIT_DBL_SIGNED long
118 # define PRI_BDIGIT_PREFIX "h"
119 # define PRI_BDIGIT_DBL_PREFIX "l"
120 #endif
121 
122 #define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
123 #define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
124 #define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
125 #define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
126 #define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
127 #define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
128 
129 #define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
130 #define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
131 #define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
132 #define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
133 #define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
134 #define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
135 
136 #ifdef __CYGWIN__
137 #undef _WIN32
138 #endif
139 
140 #if defined(_WIN32) || defined(__EMX__)
141 #define DOSISH 1
142 # define DOSISH_DRIVE_LETTER
143 #endif
144 
145 #ifdef AC_APPLE_UNIVERSAL_BUILD
146 #undef WORDS_BIGENDIAN
147 #ifdef __BIG_ENDIAN__
148 #define WORDS_BIGENDIAN
149 #endif
150 #endif
151 
152 #ifdef __NeXT__
153 /* NextStep, OpenStep, Rhapsody */
154 #ifndef S_IRUSR
155 #define S_IRUSR 0000400 /* read permission, owner */
156 #endif
157 #ifndef S_IRGRP
158 #define S_IRGRP 0000040 /* read permission, group */
159 #endif
160 #ifndef S_IROTH
161 #define S_IROTH 0000004 /* read permission, other */
162 #endif
163 #ifndef S_IWUSR
164 #define S_IWUSR 0000200 /* write permission, owner */
165 #endif
166 #ifndef S_IWGRP
167 #define S_IWGRP 0000020 /* write permission, group */
168 #endif
169 #ifndef S_IWOTH
170 #define S_IWOTH 0000002 /* write permission, other */
171 #endif
172 #ifndef S_IXUSR
173 #define S_IXUSR 0000100 /* execute/search permission, owner */
174 #endif
175 #ifndef S_IXGRP
176 #define S_IXGRP 0000010 /* execute/search permission, group */
177 #endif
178 #ifndef S_IXOTH
179 #define S_IXOTH 0000001 /* execute/search permission, other */
180 #endif
181 #ifndef S_IRWXU
182 #define S_IRWXU 0000700 /* read, write, execute permissions, owner */
183 #endif
184 #ifndef S_IRWXG
185 #define S_IRWXG 0000070 /* read, write, execute permissions, group */
186 #endif
187 #ifndef S_IRWXO
188 #define S_IRWXO 0000007 /* read, write, execute permissions, other */
189 #endif
190 #ifndef S_ISBLK
191 #define S_ISBLK(mode) (((mode) & (0170000)) == (0060000))
192 #endif
193 #ifndef S_ISCHR
194 #define S_ISCHR(mode) (((mode) & (0170000)) == (0020000))
195 #endif
196 #ifndef S_ISDIR
197 #define S_ISDIR(mode) (((mode) & (0170000)) == (0040000))
198 #endif
199 #ifndef S_ISFIFO
200 #define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
201 #endif
202 #ifndef S_ISREG
203 #define S_ISREG(mode) (((mode) & (0170000)) == (0100000))
204 #endif
205 #ifndef __APPLE__
206 /* NextStep, OpenStep (but not Rhapsody) */
207 #ifndef GETPGRP_VOID
208 #define GETPGRP_VOID 1
209 #endif
210 #ifndef WNOHANG
211 #define WNOHANG 01
212 #endif
213 #ifndef WUNTRACED
214 #define WUNTRACED 02
215 #endif
216 #ifndef X_OK
217 #define X_OK 1
218 #endif
219 #endif /* __APPLE__ */
220 #endif /* NeXT */
221 
222 #ifdef _WIN32
223 #include "ruby/win32.h"
224 #endif
225 
226 #if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
227 #include <net/socket.h> /* intern.h needs fd_set definition */
228 #elif defined (__SYMBIAN32__) && defined (HAVE_SYS_SELECT_H)
229 # include <sys/select.h>
230 #endif
231 
232 #ifdef __SYMBIAN32__
233 # define FALSE 0
234 # define TRUE 1
235 #endif
236 
237 #ifdef RUBY_EXPORT
238 #undef RUBY_EXTERN
239 
240 #ifndef FALSE
241 # define FALSE 0
242 #elif FALSE
243 # error FALSE must be false
244 #endif
245 #ifndef TRUE
246 # define TRUE 1
247 #elif !TRUE
248 # error TRUE must be true
249 #endif
250 
251 #endif
252 
253 #ifndef RUBY_FUNC_EXPORTED
254 #define RUBY_FUNC_EXPORTED
255 #endif
256 
257 #ifndef RUBY_EXTERN
258 #define RUBY_EXTERN extern
259 #endif
260 
261 #ifndef EXTERN
262 #define EXTERN RUBY_EXTERN /* deprecated */
263 #endif
264 
265 #ifndef RUBY_MBCHAR_MAXSIZE
266 #define RUBY_MBCHAR_MAXSIZE INT_MAX
267  /* MB_CUR_MAX will not work well in C locale */
268 #endif
269 
270 #if defined(sparc) || defined(__sparc__)
272 # define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
273 #elif defined(__ia64)
274 void *rb_ia64_bsp(void);
275 void rb_ia64_flushrs(void);
276 # define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
277 #else
278 # define FLUSH_REGISTER_WINDOWS ((void)0)
279 #endif
280 
281 #if defined(DOSISH)
282 #define PATH_SEP ";"
283 #else
284 #define PATH_SEP ":"
285 #endif
286 #define PATH_SEP_CHAR PATH_SEP[0]
287 
288 #define PATH_ENV "PATH"
289 
290 #if defined(DOSISH) && !defined(__EMX__)
291 #define ENV_IGNORECASE
292 #endif
293 
294 #ifndef CASEFOLD_FILESYSTEM
295 # if defined DOSISH
296 # define CASEFOLD_FILESYSTEM 1
297 # else
298 # define CASEFOLD_FILESYSTEM 0
299 # endif
300 #endif
301 
302 #ifndef DLEXT_MAXLEN
303 #define DLEXT_MAXLEN 4
304 #endif
305 
306 #ifndef RUBY_PLATFORM
307 #define RUBY_PLATFORM "unknown-unknown"
308 #endif
309 
310 #ifndef RUBY_ALIAS_FUNCTION_TYPE
311 #define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
312  type prot {return name args;}
313 #endif
314 #ifndef RUBY_ALIAS_FUNCTION_VOID
315 #define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
316  void prot {name args;}
317 #endif
318 #ifndef RUBY_ALIAS_FUNCTION
319 #define RUBY_ALIAS_FUNCTION(prot, name, args) \
320  RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
321 #endif
322 
323 #if defined __GNUC__ && __GNUC__ >= 4
324 #pragma GCC visibility pop
325 #endif
326 
327 #if defined(__cplusplus)
328 #if 0
329 { /* satisfy cc-mode */
330 #endif
331 } /* extern "C" { */
332 #endif
333 
334 #endif /* RUBY_DEFINES_H */
#define xrealloc2
Definition: defines.h:68
#define xmalloc2
Definition: defines.h:65
#define xfree
Definition: defines.h:69
#define xmalloc
Definition: defines.h:64
#define xrealloc
Definition: defines.h:67
void rb_sparc_flush_register_windows(void)
Definition: sparc.c:12
#define xcalloc
Definition: defines.h:66