Ruby 1.9.3p327(2012-11-10revision37606)
include/ruby/defines.h
Go to the documentation of this file.
00001 /************************************************
00002 
00003   defines.h -
00004 
00005   $Author: kosaki $
00006   created at: Wed May 18 00:21:44 JST 1994
00007 
00008 ************************************************/
00009 
00010 #ifndef RUBY_DEFINES_H
00011 #define RUBY_DEFINES_H 1
00012 
00013 #if defined(__cplusplus)
00014 extern "C" {
00015 #if 0
00016 } /* satisfy cc-mode */
00017 #endif
00018 #endif
00019 
00020 #include "ruby/config.h"
00021 #ifdef RUBY_EXTCONF_H
00022 #include RUBY_EXTCONF_H
00023 #endif
00024 
00025 #define RUBY
00026 
00027 # include <stddef.h>
00028 #ifdef HAVE_STDLIB_H
00029 # include <stdlib.h>
00030 #endif
00031 #ifdef __cplusplus
00032 # ifndef  HAVE_PROTOTYPES
00033 #  define HAVE_PROTOTYPES 1
00034 # endif
00035 # ifndef  HAVE_STDARG_PROTOTYPES
00036 #  define HAVE_STDARG_PROTOTYPES 1
00037 # endif
00038 #endif
00039 
00040 #undef _
00041 #ifdef HAVE_PROTOTYPES
00042 # define _(args) args
00043 #else
00044 # define _(args) ()
00045 #endif
00046 
00047 #undef __
00048 #ifdef HAVE_STDARG_PROTOTYPES
00049 # define __(args) args
00050 #else
00051 # define __(args) ()
00052 #endif
00053 
00054 #ifdef __cplusplus
00055 #define ANYARGS ...
00056 #else
00057 #define ANYARGS
00058 #endif
00059 
00060 #if defined __GNUC__ && __GNUC__ >= 4
00061 #pragma GCC visibility push(default)
00062 #endif
00063 
00064 #define xmalloc ruby_xmalloc
00065 #define xmalloc2 ruby_xmalloc2
00066 #define xcalloc ruby_xcalloc
00067 #define xrealloc ruby_xrealloc
00068 #define xrealloc2 ruby_xrealloc2
00069 #define xfree ruby_xfree
00070 
00071 void *xmalloc(size_t);
00072 void *xmalloc2(size_t,size_t);
00073 void *xcalloc(size_t,size_t);
00074 void *xrealloc(void*,size_t);
00075 void *xrealloc2(void*,size_t,size_t);
00076 void xfree(void*);
00077 
00078 #define STRINGIZE(expr) STRINGIZE0(expr)
00079 #ifndef STRINGIZE0
00080 #define STRINGIZE0(expr) #expr
00081 #endif
00082 
00083 #if SIZEOF_LONG_LONG > 0
00084 # define LONG_LONG long long
00085 #elif SIZEOF___INT64 > 0
00086 # define HAVE_LONG_LONG 1
00087 # define LONG_LONG __int64
00088 # undef SIZEOF_LONG_LONG
00089 # define SIZEOF_LONG_LONG SIZEOF___INT64
00090 #endif
00091 
00092 #if SIZEOF_INT*2 <= SIZEOF_LONG_LONG
00093 # define BDIGIT unsigned int
00094 # define SIZEOF_BDIGITS SIZEOF_INT
00095 # define BDIGIT_DBL unsigned LONG_LONG
00096 # define BDIGIT_DBL_SIGNED LONG_LONG
00097 # define PRI_BDIGIT_PREFIX ""
00098 # define PRI_BDIGIT_DBL_PREFIX PRI_LL_PREFIX
00099 #elif SIZEOF_INT*2 <= SIZEOF_LONG
00100 # define BDIGIT unsigned int
00101 # define SIZEOF_BDIGITS SIZEOF_INT
00102 # define BDIGIT_DBL unsigned long
00103 # define BDIGIT_DBL_SIGNED long
00104 # define PRI_BDIGIT_PREFIX ""
00105 # define PRI_BDIGIT_DBL_PREFIX "l"
00106 #elif SIZEOF_SHORT*2 <= SIZEOF_LONG
00107 # define BDIGIT unsigned short
00108 # define SIZEOF_BDIGITS SIZEOF_SHORT
00109 # define BDIGIT_DBL unsigned long
00110 # define BDIGIT_DBL_SIGNED long
00111 # define PRI_BDIGIT_PREFIX "h"
00112 # define PRI_BDIGIT_DBL_PREFIX "l"
00113 #else
00114 # define BDIGIT unsigned short
00115 # define SIZEOF_BDIGITS (SIZEOF_LONG/2)
00116 # define BDIGIT_DBL unsigned long
00117 # define BDIGIT_DBL_SIGNED long
00118 # define PRI_BDIGIT_PREFIX "h"
00119 # define PRI_BDIGIT_DBL_PREFIX "l"
00120 #endif
00121 
00122 #define PRIdBDIGIT PRI_BDIGIT_PREFIX"d"
00123 #define PRIiBDIGIT PRI_BDIGIT_PREFIX"i"
00124 #define PRIoBDIGIT PRI_BDIGIT_PREFIX"o"
00125 #define PRIuBDIGIT PRI_BDIGIT_PREFIX"u"
00126 #define PRIxBDIGIT PRI_BDIGIT_PREFIX"x"
00127 #define PRIXBDIGIT PRI_BDIGIT_PREFIX"X"
00128 
00129 #define PRIdBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"d"
00130 #define PRIiBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"i"
00131 #define PRIoBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"o"
00132 #define PRIuBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"u"
00133 #define PRIxBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"x"
00134 #define PRIXBDIGIT_DBL PRI_BDIGIT_DBL_PREFIX"X"
00135 
00136 #ifdef __CYGWIN__
00137 #undef _WIN32
00138 #endif
00139 
00140 #if defined(_WIN32) || defined(__EMX__)
00141 #define DOSISH 1
00142 # define DOSISH_DRIVE_LETTER
00143 #endif
00144 
00145 #ifdef AC_APPLE_UNIVERSAL_BUILD
00146 #undef WORDS_BIGENDIAN
00147 #ifdef __BIG_ENDIAN__
00148 #define WORDS_BIGENDIAN
00149 #endif
00150 #endif
00151 
00152 #ifdef __NeXT__
00153 /* NextStep, OpenStep, Rhapsody */
00154 #ifndef S_IRUSR
00155 #define S_IRUSR 0000400        /* read permission, owner */
00156 #endif
00157 #ifndef S_IRGRP
00158 #define S_IRGRP 0000040        /* read permission, group */
00159 #endif
00160 #ifndef S_IROTH
00161 #define S_IROTH 0000004        /* read permission, other */
00162 #endif
00163 #ifndef S_IWUSR
00164 #define S_IWUSR 0000200        /* write permission, owner */
00165 #endif
00166 #ifndef S_IWGRP
00167 #define S_IWGRP 0000020        /* write permission, group */
00168 #endif
00169 #ifndef S_IWOTH
00170 #define S_IWOTH 0000002        /* write permission, other */
00171 #endif
00172 #ifndef S_IXUSR
00173 #define S_IXUSR 0000100        /* execute/search permission, owner */
00174 #endif
00175 #ifndef S_IXGRP
00176 #define S_IXGRP 0000010        /* execute/search permission, group */
00177 #endif
00178 #ifndef S_IXOTH
00179 #define S_IXOTH 0000001        /* execute/search permission, other */
00180 #endif
00181 #ifndef S_IRWXU
00182 #define S_IRWXU 0000700        /* read, write, execute permissions, owner */
00183 #endif
00184 #ifndef S_IRWXG
00185 #define S_IRWXG 0000070        /* read, write, execute permissions, group */
00186 #endif
00187 #ifndef S_IRWXO
00188 #define S_IRWXO 0000007        /* read, write, execute permissions, other */
00189 #endif
00190 #ifndef S_ISBLK
00191 #define S_ISBLK(mode)  (((mode) & (0170000)) == (0060000))
00192 #endif
00193 #ifndef S_ISCHR
00194 #define S_ISCHR(mode)  (((mode) & (0170000)) == (0020000))
00195 #endif
00196 #ifndef S_ISDIR
00197 #define S_ISDIR(mode)  (((mode) & (0170000)) == (0040000))
00198 #endif
00199 #ifndef S_ISFIFO
00200 #define S_ISFIFO(mode) (((mode) & (0170000)) == (0010000))
00201 #endif
00202 #ifndef S_ISREG
00203 #define S_ISREG(mode)  (((mode) & (0170000)) == (0100000))
00204 #endif
00205 #ifndef __APPLE__
00206 /* NextStep, OpenStep (but not Rhapsody) */
00207 #ifndef GETPGRP_VOID
00208 #define GETPGRP_VOID 1
00209 #endif
00210 #ifndef WNOHANG
00211 #define WNOHANG 01
00212 #endif
00213 #ifndef WUNTRACED
00214 #define WUNTRACED 02
00215 #endif
00216 #ifndef X_OK
00217 #define X_OK 1
00218 #endif
00219 #endif /* __APPLE__ */
00220 #endif /* NeXT */
00221 
00222 #ifdef _WIN32
00223 #include "ruby/win32.h"
00224 #endif
00225 
00226 #if defined(__BEOS__) && !defined(__HAIKU__) && !defined(BONE)
00227 #include <net/socket.h> /* intern.h needs fd_set definition */
00228 #elif defined (__SYMBIAN32__) && defined (HAVE_SYS_SELECT_H)
00229 # include <sys/select.h>
00230 #endif
00231 
00232 #ifdef __SYMBIAN32__
00233 # define FALSE 0
00234 # define TRUE 1
00235 #endif
00236 
00237 #ifdef RUBY_EXPORT
00238 #undef RUBY_EXTERN
00239 
00240 #ifndef FALSE
00241 # define FALSE 0
00242 #elif FALSE
00243 # error FALSE must be false
00244 #endif
00245 #ifndef TRUE
00246 # define TRUE 1
00247 #elif !TRUE
00248 # error TRUE must be true
00249 #endif
00250 
00251 #endif
00252 
00253 #ifndef RUBY_FUNC_EXPORTED
00254 #define RUBY_FUNC_EXPORTED
00255 #endif
00256 
00257 #ifndef RUBY_EXTERN
00258 #define RUBY_EXTERN extern
00259 #endif
00260 
00261 #ifndef EXTERN
00262 #define EXTERN RUBY_EXTERN      /* deprecated */
00263 #endif
00264 
00265 #ifndef RUBY_MBCHAR_MAXSIZE
00266 #define RUBY_MBCHAR_MAXSIZE INT_MAX
00267         /* MB_CUR_MAX will not work well in C locale */
00268 #endif
00269 
00270 #if defined(sparc) || defined(__sparc__)
00271 void rb_sparc_flush_register_windows(void);
00272 #  define FLUSH_REGISTER_WINDOWS rb_sparc_flush_register_windows()
00273 #elif defined(__ia64)
00274 void *rb_ia64_bsp(void);
00275 void rb_ia64_flushrs(void);
00276 #  define FLUSH_REGISTER_WINDOWS rb_ia64_flushrs()
00277 #else
00278 #  define FLUSH_REGISTER_WINDOWS ((void)0)
00279 #endif
00280 
00281 #if defined(DOSISH)
00282 #define PATH_SEP ";"
00283 #else
00284 #define PATH_SEP ":"
00285 #endif
00286 #define PATH_SEP_CHAR PATH_SEP[0]
00287 
00288 #define PATH_ENV "PATH"
00289 
00290 #if defined(DOSISH) && !defined(__EMX__)
00291 #define ENV_IGNORECASE
00292 #endif
00293 
00294 #ifndef CASEFOLD_FILESYSTEM
00295 # if defined DOSISH
00296 #   define CASEFOLD_FILESYSTEM 1
00297 # else
00298 #   define CASEFOLD_FILESYSTEM 0
00299 # endif
00300 #endif
00301 
00302 #ifndef DLEXT_MAXLEN
00303 #define DLEXT_MAXLEN 4
00304 #endif
00305 
00306 #ifndef RUBY_PLATFORM
00307 #define RUBY_PLATFORM "unknown-unknown"
00308 #endif
00309 
00310 #ifndef RUBY_ALIAS_FUNCTION_TYPE
00311 #define RUBY_ALIAS_FUNCTION_TYPE(type, prot, name, args) \
00312     type prot {return name args;}
00313 #endif
00314 #ifndef RUBY_ALIAS_FUNCTION_VOID
00315 #define RUBY_ALIAS_FUNCTION_VOID(prot, name, args) \
00316     void prot {name args;}
00317 #endif
00318 #ifndef RUBY_ALIAS_FUNCTION
00319 #define RUBY_ALIAS_FUNCTION(prot, name, args) \
00320     RUBY_ALIAS_FUNCTION_TYPE(VALUE, prot, name, args)
00321 #endif
00322 
00323 #if defined __GNUC__ && __GNUC__ >= 4
00324 #pragma GCC visibility pop
00325 #endif
00326 
00327 #if defined(__cplusplus)
00328 #if 0
00329 { /* satisfy cc-mode */
00330 #endif
00331 }  /* extern "C" { */
00332 #endif
00333 
00334 #endif /* RUBY_DEFINES_H */
00335