1/************************************************
2
3  defines.h -
4
5  $Author: ngoto $
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)
14extern "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
71void *xmalloc(size_t);
72void *xmalloc2(size_t,size_t);
73void *xcalloc(size_t,size_t);
74void *xrealloc(void*,size_t);
75void *xrealloc2(void*,size_t,size_t);
76void 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 _WIN32
153#include "ruby/win32.h"
154#endif
155
156#if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
157#include <net/socket.h> /* intern.h needs fd_set definition */
158#elif defined (__SYMBIAN32__) && defined (HAVE_SYS_SELECT_H)
159# include <sys/select.h>
160#endif
161
162#ifdef __SYMBIAN32__
163# define FALSE 0
164# define TRUE 1
165#endif
166
167#ifdef RUBY_EXPORT
168#undef RUBY_EXTERN
169
170#ifndef FALSE
171# define FALSE 0
172#elif FALSE
173# error FALSE must be false
174#endif
175#ifndef TRUE
176# define TRUE 1
177#elif !TRUE
178# error TRUE must be true
179#endif
180
181#endif
182
183#ifndef RUBY_FUNC_EXPORTED
184#define RUBY_FUNC_EXPORTED
185#endif
186
187#ifndef RUBY_EXTERN
188#define RUBY_EXTERN extern
189#endif
190
191#ifndef EXTERN
192#define EXTERN RUBY_EXTERN	/* deprecated */
193#endif
194
195#ifndef RUBY_MBCHAR_MAXSIZE
196#define RUBY_MBCHAR_MAXSIZE INT_MAX
197        /* MB_CUR_MAX will not work well in C locale */
198#endif
199
200#if defined(__sparc)
201void rb_sparc_flush_register_windows(void);
202#  define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
203#elif defined(__ia64)
204void *rb_ia64_bsp(void);
205void rb_ia64_flushrs(void);
206#  define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
207#else
208#  define FLUSH_REGISTER_WINDOWS ((void)0)
209#endif
210
211#if defined(DOSISH)
212#define PATH_SEP ";"
213#else
214#define PATH_SEP ":"
215#endif
216#define PATH_SEP_CHAR PATH_SEP[0]
217
218#define PATH_ENV "PATH"
219
220#if defined(DOSISH) && !defined(__EMX__)
221#define ENV_IGNORECASE
222#endif
223
224#ifndef CASEFOLD_FILESYSTEM
225# if defined DOSISH
226#   define CASEFOLD_FILESYSTEM 1
227# else
228#   define CASEFOLD_FILESYSTEM 0
229# endif
230#endif
231
232#ifndef DLEXT_MAXLEN
233#define DLEXT_MAXLEN 4
234#endif
235
236#ifndef RUBY_PLATFORM
237#define RUBY_PLATFORM "unknown-unknown"
238#endif
239
240#ifndef RUBY_ALIAS_FUNCTION_TYPE
241#define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
242    type prot {return name args;}
243#endif
244#ifndef RUBY_ALIAS_FUNCTION_VOID
245#define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
246    void prot {name args;}
247#endif
248#ifndef RUBY_ALIAS_FUNCTION
249#define RUBY_ALIAS_FUNCTION(prot, name, args) \
250    RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
251#endif
252
253#if defined __GNUC__ && __GNUC__ >= 4
254#pragma GCC visibility pop
255#endif
256
257#if defined(__cplusplus)
258#if 0
259{ /* satisfy cc-mode */
260#endif
261}  /* extern "C" { */
262#endif
263
264#endif /* RUBY_DEFINES_H */
265