Ruby 2.1.5p273(2014-11-13revision48405)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

defines.h
Go to the documentation of this file.
1 /************************************************
2
3 defines.h -
4
5 $Author: akr $
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 /* AC_INCLUDES_DEFAULT */
26 #include <stdio.h>
27 #ifdef HAVE_SYS_TYPES_H
28 # include <sys/types.h>
29 #endif
30 #ifdef HAVE_SYS_STAT_H
31 # include <sys/stat.h>
32 #endif
33 #ifdef STDC_HEADERS
34 # include <stdlib.h>
35 # include <stddef.h>
36 #else
37 # ifdef HAVE_STDLIB_H
38 # include <stdlib.h>
39 # endif
40 #endif
41 #ifdef HAVE_STRING_H
42 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
43 # include <memory.h>
44 # endif
45 # include <string.h>
46 #endif
47 #ifdef HAVE_STRINGS_H
48 # include <strings.h>
49 #endif
50 #ifdef HAVE_INTTYPES_H
51 # include <inttypes.h>
52 #endif
53 #ifdef HAVE_STDINT_H
54 # include <stdint.h>
55 #endif
56 #ifdef HAVE_UNISTD_H
57 # include <unistd.h>
58 #endif
59
60 #ifdef HAVE_SYS_SELECT_H
61 # include <sys/select.h>
62 #endif
63
64 #if defined HAVE_SETJMPEX_H && defined HAVE__SETJMPEX
65 #include <setjmpex.h>
66 #endif
67
68 #include "ruby/missing.h"
69
70 #define RUBY
71
72 #ifdef __cplusplus
73 # ifndef HAVE_PROTOTYPES
74 # define HAVE_PROTOTYPES 1
75 # endif
76 # ifndef HAVE_STDARG_PROTOTYPES
77 # define HAVE_STDARG_PROTOTYPES 1
78 # endif
79 #endif
80
81 #undef _
82 #ifdef HAVE_PROTOTYPES
83 # define _(args) args
84 #else
85 # define _(args) ()
86 #endif
87
88 #undef __
89 #ifdef HAVE_STDARG_PROTOTYPES
90 # define __(args) args
91 #else
92 # define __(args) ()
93 #endif
94
95 #ifdef __cplusplus
96 #define ANYARGS ...
97 #else
98 #define ANYARGS
99 #endif
100
101 #ifndef RUBY_SYMBOL_EXPORT_BEGIN
102 # define RUBY_SYMBOL_EXPORT_BEGIN /* begin */
103 # define RUBY_SYMBOL_EXPORT_END /* end */
104 #endif
105
106 RUBY_SYMBOL_EXPORT_BEGIN
107
108 #define xmalloc ruby_xmalloc
109 #define xmalloc2 ruby_xmalloc2
110 #define xcalloc ruby_xcalloc
111 #define xrealloc ruby_xrealloc
112 #define xrealloc2 ruby_xrealloc2
113 #define xfree ruby_xfree
114
115 #if defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3
116 # define RUBY_ATTR_ALLOC_SIZE(params) __attribute__ ((__alloc_size__ params))
117 #else
118 # define RUBY_ATTR_ALLOC_SIZE(params)
119 #endif
120
121 void *xmalloc(size_t) RUBY_ATTR_ALLOC_SIZE((1));
122 void *xmalloc2(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
123 void *xcalloc(size_t,size_t) RUBY_ATTR_ALLOC_SIZE((1,2));
124 void *xrealloc(void*,size_t) RUBY_ATTR_ALLOC_SIZE((2));
125 void *xrealloc2(void*,size_t,size_t) RUBY_ATTR_ALLOC_SIZE((2,3));
126 void xfree(void*);
127
128 #define STRINGIZE(expr) STRINGIZE0(expr)
129 #ifndef STRINGIZE0
130 #define STRINGIZE0(expr) #expr
131 #endif
132
133 #ifdef HAVE_LONG_LONG
134 # define HAVE_TRUE_LONG_LONG 1
135 #endif
136
137 #if SIZEOF_LONG_LONG > 0
138 # define LONG_LONG long long
139 #elif SIZEOF___INT64 > 0
140 # define HAVE_LONG_LONG 1
141 # define LONG_LONG __int64
142 # undef SIZEOF_LONG_LONG
143 # define SIZEOF_LONG_LONG SIZEOF___INT64
144 #endif
145
146 #ifndef BDIGIT
147 # if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
148 # define BDIGIT unsigned int
149 # define SIZEOF_BDIGITS SIZEOF_INT
150 # define BDIGIT_DBL unsigned LONG_LONG
151 # define BDIGIT_DBL_SIGNED LONG_LONG
152 # define PRI_BDIGIT_PREFIX ""
153 # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
154 # elif SIZEOF_INT*2 <= SIZEOF_LONG
155 # define BDIGIT unsigned int
156 # define SIZEOF_BDIGITS SIZEOF_INT
157 # define BDIGIT_DBL unsigned long
158 # define BDIGIT_DBL_SIGNED long
159 # define PRI_BDIGIT_PREFIX ""
160 # define PRI_BDIGIT_DBL_PREFIX "l"
161 # elif SIZEOF_SHORT*2 <= SIZEOF_LONG
162 # define BDIGIT unsigned short
163 # define SIZEOF_BDIGITS SIZEOF_SHORT
164 # define BDIGIT_DBL unsigned long
165 # define BDIGIT_DBL_SIGNED long
166 # define PRI_BDIGIT_PREFIX "h"
167 # define PRI_BDIGIT_DBL_PREFIX "l"
168 # else
169 # define BDIGIT unsigned short
170 # define SIZEOF_BDIGITS (SIZEOF_LONG/2)
171 # define SIZEOF_ACTUAL_BDIGIT SIZEOF_LONG
172 # define BDIGIT_DBL unsigned long
173 # define BDIGIT_DBL_SIGNED long
174 # define PRI_BDIGIT_PREFIX "h"
175 # define PRI_BDIGIT_DBL_PREFIX "l"
176 # endif
177 #endif
178 #ifndef SIZEOF_ACTUAL_BDIGIT
179 # define SIZEOF_ACTUAL_BDIGIT SIZEOF_BDIGITS
180 #endif
181
182 #ifdef PRI_BDIGIT_PREFIX
183 # define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
184 # define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
185 # define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
186 # define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
187 # define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
188 # define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
189 #endif
190
191 #ifdef PRI_BDIGIT_DBL_PREFIX
192 # define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
193 # define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
194 # define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
195 # define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
196 # define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
197 # define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
198 #endif
199
200 #ifdef __CYGWIN__
201 #undef _WIN32
202 #endif
203
204 #if defined(_WIN32) || defined(__EMX__)
205 #define DOSISH 1
206 # define DOSISH_DRIVE_LETTER
207 #endif
208
209 #ifdef AC_APPLE_UNIVERSAL_BUILD
210 #undef WORDS_BIGENDIAN
211 #ifdef __BIG_ENDIAN__
212 #define WORDS_BIGENDIAN
213 #endif
214 #endif
215
216 #ifdef _WIN32
217 #include "ruby/win32.h"
218 #endif
219
220 #if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
221 #include <net/socket.h> /* intern.h needs fd_set definition */
222 #endif
223
224 #ifdef __SYMBIAN32__
225 # define FALSE 0
226 # define TRUE 1
227 #endif
228
229 #ifdef RUBY_EXPORT
230 #undef RUBY_EXTERN
231
232 #ifndef FALSE
233 # define FALSE 0
234 #elif FALSE
235 # error FALSE must be false
236 #endif
237 #ifndef TRUE
238 # define TRUE 1
239 #elif !TRUE
240 # error TRUE must be true
241 #endif
242
243 #endif
244
245 #ifndef RUBY_FUNC_EXPORTED
246 #define RUBY_FUNC_EXPORTED
247 #endif
248
249 #ifndef RUBY_EXTERN
250 #define RUBY_EXTERN extern
251 #endif
252
253 #ifndef EXTERN
254 #define EXTERN RUBY_EXTERN /* deprecated */
255 #endif
256
257 #ifndef RUBY_MBCHAR_MAXSIZE
258 #define RUBY_MBCHAR_MAXSIZE INT_MAX
259 /* MB_CUR_MAX will not work well in C locale */
260 #endif
261
262 #if defined(__sparc)
263 void rb_sparc_flush_register_windows(void);
264 # define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
265 #elif defined(__ia64)
266 void *rb_ia64_bsp(void);
267 void rb_ia64_flushrs(void);
268 # define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
269 #else
270 # define FLUSH_REGISTER_WINDOWS ((void)0)
271 #endif
272
273 #if defined(DOSISH)
274 #define PATH_SEP ";"
275 #else
276 #define PATH_SEP ":"
277 #endif
278 #define PATH_SEP_CHAR PATH_SEP[0]
279
280 #define PATH_ENV "PATH"
281
282 #if defined(DOSISH) && !defined(__EMX__)
283 #define ENV_IGNORECASE
284 #endif
285
286 #ifndef CASEFOLD_FILESYSTEM
287 # if defined DOSISH
288 # define CASEFOLD_FILESYSTEM 1
289 # else
290 # define CASEFOLD_FILESYSTEM 0
291 # endif
292 #endif
293
294 #ifndef DLEXT_MAXLEN
295 #define DLEXT_MAXLEN 4
296 #endif
297
298 #ifndef RUBY_PLATFORM
299 #define RUBY_PLATFORM "unknown-unknown"
300 #endif
301
302 #ifndef RUBY_ALIAS_FUNCTION_TYPE
303 #define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
304 type prot {return name args;}
305 #endif
306 #ifndef RUBY_ALIAS_FUNCTION_VOID
307 #define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
308 void prot {name args;}
309 #endif
310 #ifndef RUBY_ALIAS_FUNCTION
311 #define RUBY_ALIAS_FUNCTION(prot, name, args) \
312 RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
313 #endif
314
315 RUBY_SYMBOL_EXPORT_END
316
317 #if defined(__cplusplus)
318 #if 0
319 { /* satisfy cc-mode */
320 #endif
321 } /* extern "C" { */
322 #endif
323
324 #endif /* RUBY_DEFINES_H */
xrealloc2
#define xrealloc2
Definition: defines.h:112
xmalloc2
#define xmalloc2
Definition: defines.h:109
missing.h
RUBY_ATTR_ALLOC_SIZE
#define RUBY_ATTR_ALLOC_SIZE(params)
Definition: defines.h:118
unistd.h
RUBY_SYMBOL_EXPORT_END
#define RUBY_SYMBOL_EXPORT_END
Definition: missing.h:39
RUBY_SYMBOL_EXPORT_BEGIN
#define RUBY_SYMBOL_EXPORT_BEGIN
Definition: missing.h:38
xfree
#define xfree
Definition: defines.h:113
xmalloc
#define xmalloc
Definition: defines.h:108
xrealloc
#define xrealloc
Definition: defines.h:111
rb_sparc_flush_register_windows
void rb_sparc_flush_register_windows(void)
Definition: sparc.c:13
win32.h
xcalloc
#define xcalloc
Definition: defines.h:110