]> git.saurik.com Git - redis.git/blame - src/config.h
Variadic ZREM
[redis.git] / src / config.h
CommitLineData
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 12#if defined(USE_TCMALLOC)
32f99c51 13#define REDIS_MALLOC "tcmalloc"
7cdc98b6
PN
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
52825621 19#elif defined(USE_JEMALLOC)
32f99c51 20#define REDIS_MALLOC "jemalloc"
52825621
PN
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
d94ac406 27#elif defined(__APPLE__)
dde65f3f 28#include <malloc/malloc.h>
d76412d1 29#define HAVE_MALLOC_SIZE 1
dde65f3f 30#define redis_malloc_size(p) malloc_size(p)
31#endif
32
32f99c51
PN
33#ifndef REDIS_MALLOC
34#define REDIS_MALLOC "libc"
35#endif
36
37/* Define redis_fstat to fstat or fstat64() */
06db1f50 38#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
dde65f3f 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
b1a8e3e8 46/* Test for proc filesystem */
eddb388e 47#ifdef __linux__
48#define HAVE_PROCFS 1
49#endif
50
b1a8e3e8 51/* Test for task_info() */
73db2acc 52#if defined(__APPLE__)
53#define HAVE_TASKINFO 1
54#endif
55
b1a8e3e8 56/* Test for backtrace() */
d76412d1 57#if defined(__APPLE__) || defined(__linux__)
58#define HAVE_BACKTRACE 1
59#endif
60
b1a8e3e8 61/* Test for polling API */
266373b2 62#ifdef __linux__
63#define HAVE_EPOLL 1
64#endif
65
37be2765 66#if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
f3053eb0
HM
67#define HAVE_KQUEUE 1
68#endif
69
b1a8e3e8 70/* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
10ce1276 71#ifdef __linux__
72#define aof_fsync fdatasync
73#else
74#define aof_fsync fsync
75#endif
76
b1a8e3e8 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) || \
48e46215 119 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
b1a8e3e8 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
dde65f3f 128#endif