]> git.saurik.com Git - redis.git/blob - src/config.h
Lua scripting: Honor SELECT command in both ways
[redis.git] / src / config.h
1 #ifndef __CONFIG_H
2 #define __CONFIG_H
3
4 #ifdef __APPLE__
5 #include <AvailabilityMacros.h>
6 #endif
7
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)
18 #endif
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)
26 #endif
27 #elif defined(__APPLE__)
28 #include <malloc/malloc.h>
29 #define HAVE_MALLOC_SIZE 1
30 #define redis_malloc_size(p) malloc_size(p)
31 #endif
32
33 #ifndef REDIS_MALLOC
34 #define REDIS_MALLOC "libc"
35 #endif
36
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
41 #else
42 #define redis_fstat fstat
43 #define redis_stat stat
44 #endif
45
46 /* Test for proc filesystem */
47 #ifdef __linux__
48 #define HAVE_PROCFS 1
49 #endif
50
51 /* Test for task_info() */
52 #if defined(__APPLE__)
53 #define HAVE_TASKINFO 1
54 #endif
55
56 /* Test for backtrace() */
57 #if defined(__APPLE__) || defined(__linux__)
58 #define HAVE_BACKTRACE 1
59 #endif
60
61 /* Test for polling API */
62 #ifdef __linux__
63 #define HAVE_EPOLL 1
64 #endif
65
66 #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
67 #define HAVE_KQUEUE 1
68 #endif
69
70 /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
71 #ifdef __linux__
72 #define aof_fsync fdatasync
73 #else
74 #define aof_fsync fsync
75 #endif
76
77 /* Byte ordering detection */
78 #include <sys/types.h> /* This will likely define BYTE_ORDER */
79
80 #ifndef BYTE_ORDER
81 #if (BSD >= 199103)
82 # include <machine/endian.h>
83 #else
84 #if defined(linux) || defined(__linux__)
85 # include <endian.h>
86 #else
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)*/
90
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
95 #endif
96
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
105 #endif
106 #endif /* linux */
107 #endif /* BSD */
108 #endif /* BYTE_ORDER */
109
110 #if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
111 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
112 #define BYTE_ORDER LITTLE_ENDIAN
113 #else
114 #define BYTE_ORDER BIG_ENDIAN
115 #endif
116 #endif
117
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
123 * the above macros.
124 */
125 #error "Undefined or invalid BYTE_ORDER"
126 #endif
127
128 #endif