Main Page | Class List | Directories | File List | Class Members | File Members

global.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: global.h,v 1.106 2005/02/03 15:42:45 grubba Exp $
00006 */
00007 
00008 #ifndef GLOBAL_H
00009 #define GLOBAL_H
00010 
00011 /* Mingw32 workarounds */
00012 #if (defined(__WINNT__) || defined(__WIN32__)) && !defined(__NT__)
00013 #define __NT__
00014 #endif
00015 
00016 #ifndef _LARGEFILE_SOURCE
00017 #  define _FILE_OFFSET_BITS 64
00018 #  define _LARGEFILE_SOURCE
00019 /* #  define _LARGEFILE64_SOURCE 1 */   /* This one is for explicit 64bit. */
00020 #endif
00021 
00022 /* HPUX needs these too... */
00023 #ifndef __STDC_EXT__
00024 #  define __STDC_EXT__
00025 #endif /* !__STDC_EXT__ */
00026 #ifndef _PROTOTYPES
00027 #  define _PROTOTYPES
00028 #endif /* !_PROTOTYPES */
00029 
00030 /* And Linux wants this one... */
00031 #ifndef _GNU_SOURCE
00032 #define _GNU_SOURCE
00033 #endif /* !_GNU_SOURCE */
00034 
00035 #ifdef __NT__
00036 /* To get <windows.h> to stop including the entire OS,
00037  * we need to define this one.
00038  */
00039 #ifndef WIN32_LEAN_AND_MEAN
00040 #define WIN32_LEAN_AND_MEAN
00041 #endif
00042 
00043 /* We also need to ensure that we get the WIN32 APIs. */
00044 #ifndef WIN32
00045 #define WIN32   100     /* WinNT 1.0 */
00046 #endif
00047 
00048 /* We want WinNT 5.0 API's if available. */
00049 #if !defined(_WIN32_WINDOWS) || (_WIN32_WINDOWS < 0x500)
00050 #undef _WIN32_WINDOWS
00051 #define _WIN32_WINDOWS 0x0500
00052 #endif
00053 
00054 #if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x500)
00055 #undef _WIN32_WINNT
00056 #define _WIN32_WINNT 0x0500
00057 #endif
00058 
00059 #endif /* __NT__ */
00060 
00061 #ifdef __amigaos__
00062 /* Avoid getting definitions of struct in_addr from <unistd.h>... */
00063 #define __USE_NETINET_IN_H
00064 #endif
00065 
00066 /*
00067  * Some structure forward declarations are needed.
00068  */
00069 
00070 /* This is needed for linux */
00071 #ifdef MALLOC_REPLACED
00072 #define NO_FIX_MALLOC
00073 #endif
00074 
00075 #ifndef STRUCT_PROGRAM_DECLARED
00076 #define STRUCT_PROGRAM_DECLARED
00077 struct program;
00078 #endif
00079 
00080 struct function;
00081 #ifndef STRUCT_SVALUE_DECLARED
00082 #define STRUCT_SVALUE_DECLARED
00083 struct svalue;
00084 #endif
00085 struct sockaddr;
00086 struct object;
00087 struct array;
00088 struct svalue;
00089 
00090 #ifndef STRUCT_TIMEVAL_DECLARED
00091 #define STRUCT_TIMEVAL_DECLARED
00092 struct timeval;
00093 #endif
00094 
00095 #ifndef CONFIGURE_TEST
00096 /* machine.h doesn't exist if we're included from a configure test
00097  * program. In that case these defines will already be included. */
00098 #include "machine.h"
00099 #endif
00100 
00101 /*
00102  * Max number of local variables in a function.
00103  * Currently there is no support for more than 256
00104  */
00105 #define MAX_LOCAL       256
00106 
00107 /*
00108  * define NO_GC to get rid of garbage collection
00109  */
00110 #ifndef NO_GC
00111 #define GC2
00112 #endif
00113 
00114 #if defined(i386)
00115 #ifndef HANDLES_UNALIGNED_MEMORY_ACCESS
00116 #define HANDLES_UNALIGNED_MEMORY_ACCESS
00117 #endif
00118 #endif
00119 
00120 /* AIX requires this to be the first thing in the file.  */
00121 #if HAVE_ALLOCA_H
00122 # include <alloca.h>
00123 # ifdef __GNUC__
00124 #  ifdef alloca
00125 #   undef alloca
00126 #  endif
00127 #  define alloca __builtin_alloca
00128 # endif 
00129 #else
00130 # ifdef __GNUC__
00131 #  ifdef alloca
00132 #   undef alloca
00133 #  endif
00134 #  define alloca __builtin_alloca
00135 # else
00136 #  ifdef _AIX
00137  #pragma alloca
00138 #  else
00139 #   ifndef alloca /* predefined by HP cc +Olibcalls */
00140 void *alloca();
00141 #   endif
00142 #  endif
00143 # endif
00144 #endif
00145 
00146 #ifdef __NT__
00147 /* We are running NT */
00148 #undef FD_SETSIZE
00149 #define FD_SETSIZE MAX_OPEN_FILEDESCRIPTORS
00150 #endif
00151 
00152 #ifdef HAVE_DEVICES_TIMER_H
00153 /* On AmigaOS, struct timeval is defined in a variety of places
00154    and a variety of ways.  Making sure <devices/timer.h> is included
00155    first brings some amount of order to the chaos. */
00156 #include <devices/timer.h>
00157 #endif
00158 
00159 #include <stdio.h>
00160 
00161 #ifdef HAVE_STDLIB_H
00162 #include <stdlib.h>
00163 #undef HAVE_STDLIB_H
00164 #endif
00165 
00166 #ifdef HAVE_STDDEF_H
00167 #include <stddef.h>
00168 #undef HAVE_STDDEF_H
00169 #endif
00170 
00171 #ifdef HAVE_MALLOC_H
00172 #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
00173 /* FreeBSD and OpenBSD has <malloc.h>, but it just contains a warning... */
00174 #include <malloc.h>
00175 #endif /* !__FreeBSD__ && !__OpenBSD */
00176 #undef HAVE_MALLOC_H
00177 #endif
00178 
00179 #ifdef HAVE_UNISTD_H
00180 #include <unistd.h>
00181 #undef HAVE_UNISTD_H
00182 #endif
00183 
00184 #ifdef HAVE_STRING_H
00185 #include <string.h>
00186 #undef HAVE_STRING_H
00187 #endif
00188 
00189 #ifdef HAVE_LIMITS_H
00190 #include <limits.h>
00191 #undef HAVE_LIMITS_H
00192 #endif
00193 
00194 #ifdef HAVE_SYS_TYPES_H
00195 #include <sys/types.h>
00196 #undef HAVE_SYS_TYPES_H
00197 #endif
00198 
00199 #ifdef HAVE_MEMORY_H
00200 #include <memory.h>
00201 #undef HAVE_MEMORY_H
00202 #endif
00203 
00204 #ifdef HAVE_WINDOWS_H
00205 #include <windows.h>
00206 #undef HAVE_WINDOWS_H
00207 #endif
00208 
00209 #include <float.h>
00210 
00211 /* Get INT64, INT32, INT16, INT8, et al. */
00212 #include "pike_int_types.h"
00213 
00214 #define SIZE_T unsigned INT32
00215 
00216 #define TYPE_T unsigned int
00217 #define TYPE_FIELD unsigned INT16
00218 
00219 #define B1_T char
00220 
00221 #if SIZEOF_SHORT == 2
00222 #define B2_T short
00223 #elif SIZEOF_INT == 2
00224 #define B2_T int
00225 #endif
00226 
00227 #if SIZEOF_SHORT == 4
00228 #define B4_T short
00229 #elif SIZEOF_INT == 4
00230 #define B4_T int
00231 #elif SIZEOF_LONG == 4
00232 #define B4_T long
00233 #endif
00234 
00235 #if SIZEOF_INT == 8
00236 #define B8_T int
00237 #elif SIZEOF_LONG == 8
00238 #define B8_T long
00239 #elif (SIZEOF_LONG_LONG - 0) == 8
00240 #define B8_T long long
00241 #elif (SIZEOF___INT64 - 0) == 8
00242 #define B8_T __int64
00243 #elif SIZEOF_CHAR_P == 8
00244 #define B8_T char *
00245 #elif defined(B4_T)
00246 struct b8_t_s { B4_T x,y; };
00247 #define B8_T struct b8_t_s
00248 #endif
00249 
00250 #if defined(B8_T)
00251 struct b16_t_s { B8_T x,y; };
00252 #define B16_T struct b16_t_s
00253 #endif
00254 
00255 /* INT_TYPE stuff */
00256 #ifndef MAX_INT_TYPE
00257 # if defined (WITH_SHORT_INT)
00258 
00259 #  define MAX_INT_TYPE  SHRT_MAX
00260 #  define MIN_INT_TYPE  SHRT_MIN
00261 #  define PRINTPIKEINT  "h"
00262 #  define INT_ARG_TYPE  int
00263 
00264 # elif defined (WITH_INT_INT)
00265 
00266 #  define MAX_INT_TYPE  INT_MAX
00267 #  define MIN_INT_TYPE  INT_MIN
00268 #  define PRINTPIKEINT  ""
00269 
00270 # elif defined (WITH_LONG_INT)
00271 
00272 #  define MAX_INT_TYPE  LONG_MAX
00273 #  define MIN_INT_TYPE  LONG_MIN
00274 #  define PRINTPIKEINT  "l"
00275 
00276 # elif defined (WITH_LONG_LONG_INT)
00277 
00278 #  ifdef LLONG_MAX
00279 #   define MAX_INT_TYPE LLONG_MAX
00280 #   define MIN_INT_TYPE LLONG_MIN
00281 #  else
00282 #   define MAX_INT_TYPE LONG_LONG_MAX
00283 #   define MIN_INT_TYPE LONG_LONG_MIN
00284 #  endif
00285 #  define PRINTPIKEINT  "ll"
00286 
00287 # endif
00288 #endif
00289 
00290 /* INT_ARG_TYPE is a type suitable for argument passing that at least
00291  * can hold an INT_TYPE value. */
00292 #ifndef INT_ARG_TYPE
00293 #define INT_ARG_TYPE INT_TYPE
00294 #endif
00295 
00296 #if SIZEOF_INT_TYPE - 0 == 0
00297 # error Unsupported type chosen for native pike integers.
00298 #endif
00299 
00300 #if SIZEOF_INT_TYPE != 4
00301 # define INT_TYPE_INT32_CONVERSION
00302 #endif
00303 
00304 /* FLOAT_TYPE stuff */
00305 #if defined (WITH_LONG_DOUBLE_PRECISION_SVALUE)
00306 
00307 #  define PIKEFLOAT_MANT_DIG    LDBL_MANT_DIG
00308 #  define PIKEFLOAT_DIG         LDBL_DIG
00309 #  define PIKEFLOAT_MIN_EXP     LDBL_MIN_EXP
00310 #  define PIKEFLOAT_MAX_EXP     LDBL_MAX_EXP
00311 #  define PIKEFLOAT_MIN_10_EXP  LDBL_MIN_10_EXP
00312 #  define PIKEFLOAT_MAX_10_EXP  LDBL_MAX_10_EXP
00313 #  define PIKEFLOAT_MAX         LDBL_MAX
00314 #  define PIKEFLOAT_MIN         LDBL_MIN
00315 #  define PIKEFLOAT_EPSILON     LDBL_EPSILON
00316 #  define PRINTPIKEFLOAT        "L"
00317 
00318 #elif defined (WITH_DOUBLE_PRECISION_SVALUE)
00319 
00320 #  define PIKEFLOAT_MANT_DIG    DBL_MANT_DIG
00321 #  define PIKEFLOAT_DIG         DBL_DIG
00322 #  define PIKEFLOAT_MIN_EXP     DBL_MIN_EXP
00323 #  define PIKEFLOAT_MAX_EXP     DBL_MAX_EXP
00324 #  define PIKEFLOAT_MIN_10_EXP  DBL_MIN_10_EXP
00325 #  define PIKEFLOAT_MAX_10_EXP  DBL_MAX_10_EXP
00326 #  define PIKEFLOAT_MAX         DBL_MAX
00327 #  define PIKEFLOAT_MIN         DBL_MIN
00328 #  define PIKEFLOAT_EPSILON     DBL_EPSILON
00329 #  define PRINTPIKEFLOAT        ""
00330 
00331 #else
00332 
00333 #  define PIKEFLOAT_MANT_DIG    FLT_MANT_DIG
00334 #  define PIKEFLOAT_DIG         FLT_DIG
00335 #  define PIKEFLOAT_MIN_EXP     FLT_MIN_EXP
00336 #  define PIKEFLOAT_MAX_EXP     FLT_MAX_EXP
00337 #  define PIKEFLOAT_MIN_10_EXP  FLT_MIN_10_EXP
00338 #  define PIKEFLOAT_MAX_10_EXP  FLT_MAX_10_EXP
00339 #  define PIKEFLOAT_MAX         FLT_MAX
00340 #  define PIKEFLOAT_MIN         FLT_MIN
00341 #  define PIKEFLOAT_EPSILON     FLT_EPSILON
00342 #  define PRINTPIKEFLOAT        ""
00343 #  define FLOAT_ARG_TYPE        double
00344 
00345 #endif
00346 
00347 /* FLOAT_ARG_TYPE is a type suitable for argument passing that at
00348  * least can hold a FLOAT_TYPE value. */
00349 #ifndef FLOAT_ARG_TYPE
00350 #define FLOAT_ARG_TYPE FLOAT_TYPE
00351 #endif
00352 
00353 #if SIZEOF_FLOAT_TYPE - 0 == 0
00354 #error Unsupported type chosen for pike floats.
00355 #endif
00356 
00357 typedef unsigned char p_wchar0;
00358 typedef unsigned INT16 p_wchar1;
00359 typedef unsigned INT32 p_wchar2;
00360 
00361 typedef struct p_wchar_p
00362 {
00363   p_wchar0 *ptr;
00364   int shift;
00365 } PCHARP;
00366 
00367 #ifndef CONFIGURE_TEST
00368 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
00369 #define RCSID(X) \
00370  static const char rcsid[] __attribute__ ((unused)) =X
00371 #elif __GNUC__ == 2
00372 #define RCSID(X) \
00373  static const char rcsid[] = X; \
00374  static const void *use_rcsid=(&use_rcsid, (void *)&rcsid)
00375 #else
00376 #define RCSID(X) \
00377  static const char rcsid[] = X
00378 #endif
00379 #else
00380 #define RCSID(X)
00381 #endif
00382 
00383 #ifdef PIKE_DEBUG
00384 #define DO_IF_DEBUG(X) X
00385 #else
00386 #define DO_IF_DEBUG(X)
00387 #define NDEBUG
00388 #endif
00389 
00390 #ifdef INTERNAL_PROFILING
00391 #define DO_IF_INTERNAL_PROFILING(X) X
00392 #else
00393 #define DO_IF_INTERNAL_PROFILING(X)
00394 #endif
00395 
00396 #ifndef INLINE
00397 #if defined(__GNUC__) && !defined(PIKE_DEBUG) && !defined(lint)
00398 #define INLINE inline
00399 #else
00400 #define INLINE
00401 #endif
00402 #endif
00403 
00404 /* PMOD_EXPORT exports a function / variable / whatever.
00405  * Putting PMOD_PROTO in front of a prototype does nothing.
00406  */
00407 #ifndef PMOD_EXPORT
00408 #ifdef __NT__
00409 #ifdef DYNAMIC_MODULE
00410 #ifdef _M_IA64
00411 /* Make sure we use long calls to functions in the main binary. */
00412 #define PMOD_EXPORT     __declspec(dllimport)
00413 #endif /* _M_IA64 */
00414 #else /* !DYNAMIC_MODULE */
00415 /* #define PMOD_EXPORT  __declspec(dllexport) */
00416 #endif /* DYNAMIC_MODULE */
00417 #endif /* __NT__ */
00418 #ifndef PMOD_EXPORT
00419 #define PMOD_EXPORT
00420 #endif /* !PMOD_EXPORT */
00421 #endif /* !PMOD_EXPORT */
00422 
00423 
00424 /* PMOD_PROTO is essentially the same as PMOD_EXPORT, but
00425  * it exports the identifier even if it only a prototype.
00426  */
00427 #ifndef PMOD_PROTO
00428 #define PMOD_PROTO
00429 #endif
00430 
00431 #ifndef DO_PIKE_CLEANUP
00432 #if defined(PURIFY) || defined(__CHECKER__) || defined(DEBUG_MALLOC)
00433 #define DO_PIKE_CLEANUP
00434 #endif
00435 #endif
00436 
00437 #ifdef PIKE_SECURITY
00438 #define DO_IF_SECURITY(X) X
00439 #else
00440 #define DO_IF_SECURITY(X)
00441 #endif
00442 
00443 /* Used by the AutoBuild system to mark known warnings. */
00444 #define DO_NOT_WARN(X)  (X)
00445 
00446 /* Some functions/macros used to avoid loss of precision warnings. */
00447 #ifdef __ECL
00448 static INLINE long PTRDIFF_T_TO_LONG(ptrdiff_t x)
00449 {
00450   return DO_NOT_WARN((long)x);
00451 }
00452 #else /* !__ECL */
00453 #define PTRDIFF_T_TO_LONG(x)       ((long)(x))
00454 #endif /* __ECL */
00455 
00456 #include "port.h"
00457 #include "dmalloc.h"
00458 #include "pike_cpulib.h"
00459 
00460 #ifdef BUFSIZ
00461 #define PROT_STDIO(x) PROT(x)
00462 #else
00463 #define PROT_STDIO(x) ()
00464 #endif
00465 
00466 #ifdef __STDC__
00467 #define PROT(x) x
00468 #else
00469 #define PROT(x) ()
00470 #endif
00471 
00472 #ifdef MALLOC_DECL_MISSING
00473 char *malloc PROT((int));
00474 char *realloc PROT((char *,int));
00475 void free PROT((char *));
00476 char *calloc PROT((int,int));
00477 #endif
00478 
00479 #ifdef GETPEERNAME_DECL_MISSING
00480 int getpeername PROT((int, struct sockaddr *, int *));
00481 #endif
00482 
00483 #ifdef GETHOSTNAME_DECL_MISSING
00484 void gethostname PROT((char *,int));
00485 #endif
00486 
00487 #ifdef POPEN_DECL_MISSING
00488 FILE *popen PROT((char *,char *));
00489 #endif
00490 
00491 #ifdef GETENV_DECL_MISSING
00492 char *getenv PROT((char *));
00493 #endif
00494 
00495 #ifdef USE_CRYPT_C
00496 char *crypt(const char *, const char *);
00497 #endif /* USE_CRYPT_C */
00498 
00499 /* If this define is present, error() has been renamed to Pike_error() and
00500  * error.h has been renamed to pike_error.h
00501  * Expect to see other similar defines in the future. -Hubbe
00502  */
00503 #define Pike_error_present
00504 
00505 /* Compatibility... */
00506 #define USE_PIKE_TYPE   2
00507 
00508 #ifdef PIKE_RUN_UNLOCKED
00509 #define DO_IF_RUN_UNLOCKED(X) X
00510 #else
00511 #define DO_IF_RUN_UNLOCKED(X)
00512 #endif
00513 
00514 /* Used in more than one place, better put it here */
00515 
00516 #if defined(PROFILING)
00517 #define DO_IF_PROFILING(X) X
00518 #else
00519 #define DO_IF_PROFILING(X)
00520 #endif
00521 
00522 /* #define PROFILING_DEBUG */
00523 
00524 #ifdef PROFILING_DEBUG
00525 #define DO_IF_PROFILING_DEBUG(X)        X
00526 #else /* !PROFILING_DEBUG */
00527 #define DO_IF_PROFILING_DEBUG(X)
00528 #endif /* PROFILING_DEBUG */
00529 
00530 
00531 
00532 #endif

Generated on Fri Jul 22 23:44:24 2005 for Pike by  doxygen 1.3.9.1