pike.git/src/global.h:7:
#ifndef GLOBAL_H
#define GLOBAL_H
/* Mingw32 workarounds */
#if (defined(__WINNT__) || defined(__WIN32__)) && !defined(__NT__)
#define __NT__
#endif
#ifndef _LARGEFILE_SOURCE
# define _FILE_OFFSET_BITS 64
+ # define _TIME_BITS 64
# define _LARGEFILE_SOURCE
/* # define _LARGEFILE64_SOURCE 1 */ /* This one is for explicit 64bit. */
#endif
/* HPUX needs these too... */
#ifndef __STDC_EXT__
# define __STDC_EXT__
#endif /* !__STDC_EXT__ */
#ifndef _PROTOTYPES
# define _PROTOTYPES
pike.git/src/global.h:86: Inside #if defined(_MSC_VER)
*/
#define inline __inline
#if _MSC_VER <= 1800
/* The isnan() macro was added in VS 2015.
*/
#define isnan(X) _isnan(X)
#endif /* _MSC_VER <= 1800 */
#endif /* _MSC_VER <= 1900 */
#endif /* _MSC_VER */
+ /* NB: Defaults to 64. */
+ #ifndef FD_SETSIZE
+ /*
+ * In reality: almost unlimited actually.
+ */
+ #define FD_SETSIZE 65536
+ #endif /* FD_SETSIZE */
+
#endif /* __NT__ */
- #ifdef __amigaos__
- /* Avoid getting definitions of struct in_addr from <unistd.h>... */
- #define __USE_NETINET_IN_H
- #endif
-
+
/*
* Some structure forward declarations are needed.
*/
/* This is needed for linux */
#ifdef MALLOC_REPLACED
#define NO_FIX_MALLOC
#endif
- #ifndef STRUCT_PROGRAM_DECLARED
- #define STRUCT_PROGRAM_DECLARED
- struct program;
- #endif
-
+ struct array;
struct function;
- #ifndef STRUCT_SVALUE_DECLARED
- #define STRUCT_SVALUE_DECLARED
- struct svalue;
- #endif
- struct sockaddr;
+ struct mapping;
+ struct multiset;
struct object;
- struct array;
+ struct pike_string;
+ struct program;
+ struct sockaddr;
struct svalue;
-
- #ifndef STRUCT_TIMEVAL_DECLARED
- #define STRUCT_TIMEVAL_DECLARED
+
struct timeval;
- #endif
+
-
+
#ifndef CONFIGURE_TEST
/* machine.h doesn't exist if we're included from a configure test
* program. In that case these defines will already be included. */
/* Newer autoconf adds the PACKAGE_* defines for us, regardless
* whether we want them or not. If we're being included from a module
* they will clash, and so we need to ensure the one for the module
* survives, either they are defined already or get defined later.
* Tedious work.. */
#ifndef PIKE_CORE
pike.git/src/global.h:238: Inside #if defined(HAS___BUILTIN_UNREACHABLE)
#ifdef HAS___BUILTIN_UNREACHABLE
# define UNREACHABLE(X) __builtin_unreachable()
#else
# define UNREACHABLE(X) X
#endif
#ifdef HAS___BUILTIN_ASSUME
# define STATIC_ASSUME(X) __builtin_assume(X)
#else
- # define STATIC_ASSUME(X) do { if (!(X)) UNREACHABLE(0); } while(0)
+ # ifdef HAS___BUILTIN_UNREACHABLE
+ # define STATIC_ASSUME(X) do { if (!(X)) UNREACHABLE(0); } while(0)
+ # else
+ # define STATIC_ASSUME(X)
+ # endif
#endif
-
+ #ifdef HAS___BUILTIN_CONSTANT_P
+ # define STATIC_IS_CONSTANT(X) __builtin_constant_p(X)
+ #else
+ # define STATIC_IS_CONSTANT(X) 0
+ #endif
+
#ifndef HAVE_WORKING_REALLOC_NULL
#define realloc(PTR, SZ) pike_realloc(PTR,SZ)
#endif
/* NOTE:
* PIKE_CONCAT doesn't get defined if there isn't any way to
* concatenate symbols
*/
#ifdef HAVE_ANSI_CONCAT
#define PIKE_CONCAT(X,Y) X##Y
pike.git/src/global.h:270:
#define TOSTR(X) #X
#define DEFINETOSTR(X) TOSTR(X)
/*
* Max number of local variables in a function.
* Currently there is no support for more than 256
*/
#define MAX_LOCAL 256
- /*
- * define NO_GC to get rid of garbage collection
- */
- #ifndef NO_GC
- #define GC2
- #endif
-
- #ifdef i386
+ #if defined(i386) || defined(__powerpc__) || defined(__x86_64__) || (defined(__aarch64__) && defined(__ARM_FEATURE_UNALIGNED))
#ifndef HANDLES_UNALIGNED_MEMORY_ACCESS
#define HANDLES_UNALIGNED_MEMORY_ACCESS
#endif
#endif /* i386 */
/* AIX requires this to be the first thing in the file. */
#if HAVE_ALLOCA_H
# include <alloca.h>
# ifdef __GNUC__
# ifdef alloca
pike.git/src/global.h:335: Inside #if defined(HAVE_MALLOC_H) and #if !defined(__FreeBSD__) && !defined(__OpenBSD__)
#if !defined(__FreeBSD__) && !defined(__OpenBSD__)
/* FreeBSD and OpenBSD has <malloc.h>, but it just contains a warning... */
#include <malloc.h>
#endif /* !__FreeBSD__ && !__OpenBSD */
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
- #ifdef HAVE_SYS_TYPES_H
+
#include <sys/types.h>
- #endif
+
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_WINDOWS_H
#include <windows.h>
#endif
/* Get INT64, INT32, INT16, INT8, et al. */
pike.git/src/global.h:381:
#if SIZEOF_INT == 8
#define B8_T int
#elif SIZEOF_LONG == 8
#define B8_T long
#elif (SIZEOF_LONG_LONG - 0) == 8
#define B8_T long long
#elif (SIZEOF___INT64 - 0) == 8
#define B8_T __int64
#elif SIZEOF_CHAR_P == 8
#define B8_T char *
- #elif defined(B4_T)
- struct b8_t_s { B4_T x,y; };
- #define B8_T struct b8_t_s
+
#endif
- #ifdef B8_T
- struct b16_t_s { B8_T x,y; };
- #define B16_T struct b16_t_s
+ #if (SIZEOF___INT128 - 0) == 16
+ #define B16_T __int128
#endif
/* INT_TYPE stuff */
#ifndef MAX_INT_TYPE
# ifdef WITH_SHORT_INT
# define MAX_INT_TYPE SHRT_MAX
# define MIN_INT_TYPE SHRT_MIN
# define PRINTPIKEINT "h"
# define INT_ARG_TYPE int
pike.git/src/global.h:519:
} PCHARP;
#define WERR(...) fprintf(stderr,__VA_ARGS__)
#ifdef PIKE_DEBUG
#define DO_IF_DEBUG(X) X
#define DO_IF_DEBUG_ELSE(DEBUG, NO_DEBUG) DEBUG
#define DWERR(...) WERR(__VA_ARGS__)
+ /* Control assert() definition in <assert.h> */
#undef NDEBUG
/* Set of macros to simplify passing __FILE__ and __LINE__ to
* functions only in debug mode. */
#define DLOC __FILE__, __LINE__
#define COMMA_DLOC , __FILE__, __LINE__
#define DLOC_DECL const char *dloc_file, int dloc_line
#define COMMA_DLOC_DECL , const char *dloc_file, int dloc_line
#define DLOC_ARGS dloc_file, dloc_line
#define DLOC_ARGS_OPT dloc_file, dloc_line
pike.git/src/global.h:643:
#endif
#ifndef HAVE_STRUCT_IOVEC
#define HAVE_STRUCT_IOVEC
struct iovec {
void *iov_base;
size_t iov_len;
};
#endif /* !HAVE_STRUCT_IOVEC */
+ #ifdef HAVE_NON_SCALAR_OFF64_T
+ /* Old Solaris uses unions instead of long long for 64bit values when __STDC__.
+ *
+ * Add some conversion functions for convenience.
+ *
+ * The types longlong_t and u_longlong_t are both from <sys/types.h>.
+ *
+ * Common types that are compatible with longlong_t:
+ * off64_t, blckcnt64_t, offset_t, diskaddr_t
+ *
+ * Common types that are compatible with u_longlong_t:
+ * ino64_t, fsblkcnt64_t, fsfilcnt64_t, u_offset_t, len_t
+ */
+ static inline INT64 PIKE_UNUSED_ATTRIBUTE pike_longlong_to_int64(longlong_t val)
+ {
+ union {
+ INT64 scalar;
+ longlong_t longlong;
+ } tmp;
+ tmp.longlong = val;
+ return tmp.scalar;
+ }
+ static inline unsigned INT64 PIKE_UNUSED_ATTRIBUTE pike_ulonglong_to_uint64(u_longlong_t val)
+ {
+ union {
+ unsigned INT64 uscalar;
+ u_longlong_t ulonglong;
+ } tmp;
+ tmp.ulonglong = val;
+ return tmp.uscalar;
+ }
+ static inline longlong_t PIKE_UNUSED_ATTRIBUTE pike_int64_to_longlong(INT64 val)
+ {
+ union {
+ INT64 scalar;
+ longlong_t longlong;
+ } tmp;
+ tmp.scalar = val;
+ return tmp.longlong;
+ }
+ static inline u_longlong_t PIKE_UNUSED_ATTRIBUTE pike_uint64_to_ulonglong(unsigned INT64 val)
+ {
+ union {
+ unsigned INT64 uscalar;
+ u_longlong_t ulonglong;
+ } tmp;
+ tmp.uscalar = val;
+ return tmp.ulonglong;
+ }
+ #else /* !HAVE_NON_SCALAR_OFF64_T */
+ #define pike_longlong_to_int64(VAL) ((INT64)(VAL))
+ #define pike_ulonglong_to_uint64(VAL) ((unsigned INT64)(VAL))
+ #define pike_int64_to_longlong(VAL) ((INT64)(VAL))
+ #define pike_uint64_to_ulonglong(VAL) ((unsigned INT64)(VAL))
+ #endif /* HAVE_NON_SCALAR_OFF64_T */
+
#include "port.h"
#include "dmalloc.h"
/* Either this include must go or the include of threads.h in
* pike_cpulib.h. Otherwise we get pesky include loops. */
/* #include "pike_cpulib.h" */
#ifdef MALLOC_DECL_MISSING
void *malloc (int);
void *realloc (void *,int);
pike.git/src/global.h:697:
#endif
/* #define PROFILING_DEBUG */
#ifdef PROFILING_DEBUG
#define W_PROFILING_DEBUG(...) WERR(__VA_ARGS__)
#else /* !PROFILING_DEBUG */
#define W_PROFILING_DEBIG(...)
#endif /* PROFILING_DEBUG */
+ #ifdef HAVE_C99_STRUCT_LITERAL_EXPR
+ /* This macro is used for eg type-safe struct initializers. */
+ #define CAST_STRUCT_LITERAL(TYPE) (TYPE)
+ #else
+ /* Prior to C99 the literal was a special form only valid in
+ * initializers (ie not in general expressions).
+ */
+ #define CAST_STRUCT_LITERAL(TYPE)
#endif
-
+
+ #endif