]>
git.saurik.com Git - redis.git/blob - src/config.h
208c7b93d2d3a901ea47980c2c32d6a072a6969e
5 #include <AvailabilityMacros.h>
8 /* Use tcmalloc's malloc_size() when available.
9 * When tcmalloc is used, native OSX malloc_size() may never be used because
10 * this expects a different allocation scheme. Therefore, *exclusively* use
11 * either tcmalloc or OSX's malloc_size()! */
12 #if defined(USE_TCMALLOC)
13 #define REDIS_MALLOC "tcmalloc"
14 #include <google/tcmalloc.h>
15 #if TC_VERSION_MAJOR >= 1 && TC_VERSION_MINOR >= 6
16 #define HAVE_MALLOC_SIZE 1
17 #define redis_malloc_size(p) tc_malloc_size(p)
19 #elif defined(USE_JEMALLOC)
20 #define REDIS_MALLOC "jemalloc"
21 #define JEMALLOC_MANGLE
22 #include <jemalloc/jemalloc.h>
23 #if JEMALLOC_VERSION_MAJOR >= 2 && JEMALLOC_VERSION_MINOR >= 1
24 #define HAVE_MALLOC_SIZE 1
25 #define redis_malloc_size(p) JEMALLOC_P(malloc_usable_size)(p)
27 #elif defined(__APPLE__)
28 #include <malloc/malloc.h>
29 #define HAVE_MALLOC_SIZE 1
30 #define redis_malloc_size(p) malloc_size(p)
34 #define REDIS_MALLOC "libc"
37 /* Define redis_fstat to fstat or fstat64() */
38 #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
39 #define redis_fstat fstat64
40 #define redis_stat stat64
42 #define redis_fstat fstat
43 #define redis_stat stat
46 /* Test for proc filesystem */
51 /* Test for task_info() */
52 #if defined(__APPLE__)
53 #define HAVE_TASKINFO 1
56 /* Test for backtrace() */
57 #if defined(__APPLE__) || defined(__linux__)
58 #define HAVE_BACKTRACE 1
61 /* Test for polling API */
66 #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
70 /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
72 #define aof_fsync fdatasync
74 #define aof_fsync fsync
77 /* Byte ordering detection */
78 #include <sys/types.h> /* This will likely define BYTE_ORDER */
82 # include <machine/endian.h>
84 #if defined(linux) || defined(__linux__)
87 #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
88 #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
89 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
91 #if defined(vax) || defined(ns32000) || defined(sun386) || defined(__i386__) || \
92 defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
93 defined(__alpha__) || defined(__alpha)
94 #define BYTE_ORDER LITTLE_ENDIAN
97 #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
98 defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
99 defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
100 defined(apollo) || defined(__convex__) || defined(_CRAY) || \
101 defined(__hppa) || defined(__hp9000) || \
102 defined(__hp9000s300) || defined(__hp9000s700) || \
103 defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
104 #define BYTE_ORDER BIG_ENDIAN
108 #endif /* BYTE_ORDER */
110 #if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
111 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
112 #define BYTE_ORDER LITTLE_ENDIAN
114 #define BYTE_ORDER BIG_ENDIAN
118 #if !defined(BYTE_ORDER) || \
119 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
120 /* you must determine what the correct bit order is for
121 * your compiler - the next line is an intentional error
122 * which will force your compiles to bomb until you fix
125 #error "Undefined or invalid BYTE_ORDER"