]>
Commit | Line | Data |
---|---|---|
dde65f3f | 1 | #ifndef __CONFIG_H |
2 | #define __CONFIG_H | |
3 | ||
06db1f50 | 4 | #ifdef __APPLE__ |
5 | #include <AvailabilityMacros.h> | |
6 | #endif | |
7 | ||
d94ac406 PN |
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()! */ | |
7cdc98b6 PN |
12 | #if defined(USE_TCMALLOC) |
13 | #include <google/tcmalloc.h> | |
14 | #if TC_VERSION_MAJOR >= 1 && TC_VERSION_MINOR >= 6 | |
15 | #define HAVE_MALLOC_SIZE 1 | |
16 | #define redis_malloc_size(p) tc_malloc_size(p) | |
17 | #endif | |
52825621 PN |
18 | #elif defined(USE_JEMALLOC) |
19 | #define JEMALLOC_MANGLE | |
20 | #include <jemalloc/jemalloc.h> | |
21 | #if JEMALLOC_VERSION_MAJOR >= 2 && JEMALLOC_VERSION_MINOR >= 1 | |
22 | #define HAVE_MALLOC_SIZE 1 | |
23 | #define redis_malloc_size(p) JEMALLOC_P(malloc_usable_size)(p) | |
24 | #endif | |
d94ac406 | 25 | #elif defined(__APPLE__) |
dde65f3f | 26 | #include <malloc/malloc.h> |
d76412d1 | 27 | #define HAVE_MALLOC_SIZE 1 |
dde65f3f | 28 | #define redis_malloc_size(p) malloc_size(p) |
29 | #endif | |
30 | ||
b1a8e3e8 | 31 | /* Tefine redis_fstat to fstat or fstat64() */ |
06db1f50 | 32 | #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) |
dde65f3f | 33 | #define redis_fstat fstat64 |
34 | #define redis_stat stat64 | |
35 | #else | |
36 | #define redis_fstat fstat | |
37 | #define redis_stat stat | |
38 | #endif | |
39 | ||
b1a8e3e8 | 40 | /* Test for proc filesystem */ |
eddb388e | 41 | #ifdef __linux__ |
42 | #define HAVE_PROCFS 1 | |
43 | #endif | |
44 | ||
b1a8e3e8 | 45 | /* Test for task_info() */ |
73db2acc | 46 | #if defined(__APPLE__) |
47 | #define HAVE_TASKINFO 1 | |
48 | #endif | |
49 | ||
b1a8e3e8 | 50 | /* Test for backtrace() */ |
d76412d1 | 51 | #if defined(__APPLE__) || defined(__linux__) |
52 | #define HAVE_BACKTRACE 1 | |
53 | #endif | |
54 | ||
b1a8e3e8 | 55 | /* Test for polling API */ |
266373b2 | 56 | #ifdef __linux__ |
57 | #define HAVE_EPOLL 1 | |
58 | #endif | |
59 | ||
37be2765 | 60 | #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__) |
f3053eb0 HM |
61 | #define HAVE_KQUEUE 1 |
62 | #endif | |
63 | ||
b1a8e3e8 | 64 | /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */ |
10ce1276 | 65 | #ifdef __linux__ |
66 | #define aof_fsync fdatasync | |
67 | #else | |
68 | #define aof_fsync fsync | |
69 | #endif | |
70 | ||
b1a8e3e8 | 71 | /* Byte ordering detection */ |
72 | #include <sys/types.h> /* This will likely define BYTE_ORDER */ | |
73 | ||
74 | #ifndef BYTE_ORDER | |
75 | #if (BSD >= 199103) | |
76 | # include <machine/endian.h> | |
77 | #else | |
78 | #if defined(linux) || defined(__linux__) | |
79 | # include <endian.h> | |
80 | #else | |
81 | #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */ | |
82 | #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */ | |
83 | #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/ | |
84 | ||
85 | #if defined(vax) || defined(ns32000) || defined(sun386) || defined(__i386__) || \ | |
86 | defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \ | |
87 | defined(__alpha__) || defined(__alpha) | |
88 | #define BYTE_ORDER LITTLE_ENDIAN | |
89 | #endif | |
90 | ||
91 | #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \ | |
92 | defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \ | |
93 | defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\ | |
94 | defined(apollo) || defined(__convex__) || defined(_CRAY) || \ | |
95 | defined(__hppa) || defined(__hp9000) || \ | |
96 | defined(__hp9000s300) || defined(__hp9000s700) || \ | |
97 | defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc) | |
98 | #define BYTE_ORDER BIG_ENDIAN | |
99 | #endif | |
100 | #endif /* linux */ | |
101 | #endif /* BSD */ | |
102 | #endif /* BYTE_ORDER */ | |
103 | ||
104 | #if defined(__BYTE_ORDER) && !defined(BYTE_ORDER) | |
105 | #if (__BYTE_ORDER == __LITTLE_ENDIAN) | |
106 | #define BYTE_ORDER LITTLE_ENDIAN | |
107 | #else | |
108 | #define BYTE_ORDER BIG_ENDIAN | |
109 | #endif | |
110 | #endif | |
111 | ||
112 | #if !defined(BYTE_ORDER) || \ | |
48e46215 | 113 | (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN) |
b1a8e3e8 | 114 | /* you must determine what the correct bit order is for |
115 | * your compiler - the next line is an intentional error | |
116 | * which will force your compiles to bomb until you fix | |
117 | * the above macros. | |
118 | */ | |
119 | #error "Undefined or invalid BYTE_ORDER" | |
120 | #endif | |
121 | ||
dde65f3f | 122 | #endif |