]> git.saurik.com Git - redis.git/blob - src/config.h
Merge pull request #481 from dtran320/unstable
[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 /* Define redis_fstat to fstat or fstat64() */
9 #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6)
10 #define redis_fstat fstat64
11 #define redis_stat stat64
12 #else
13 #define redis_fstat fstat
14 #define redis_stat stat
15 #endif
16
17 /* Test for proc filesystem */
18 #ifdef __linux__
19 #define HAVE_PROCFS 1
20 #endif
21
22 /* Test for task_info() */
23 #if defined(__APPLE__)
24 #define HAVE_TASKINFO 1
25 #endif
26
27 /* Test for backtrace() */
28 #if defined(__APPLE__) || defined(__linux__) || defined(__sun)
29 #define HAVE_BACKTRACE 1
30 #endif
31
32 /* Test for polling API */
33 #ifdef __linux__
34 #define HAVE_EPOLL 1
35 #endif
36
37 #if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
38 #define HAVE_KQUEUE 1
39 #endif
40
41 /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
42 #ifdef __linux__
43 #define aof_fsync fdatasync
44 #else
45 #define aof_fsync fsync
46 #endif
47
48 /* Byte ordering detection */
49 #include <sys/types.h> /* This will likely define BYTE_ORDER */
50
51 #ifndef BYTE_ORDER
52 #if (BSD >= 199103)
53 # include <machine/endian.h>
54 #else
55 #if defined(linux) || defined(__linux__)
56 # include <endian.h>
57 #else
58 #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
59 #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
60 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
61
62 #if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
63 defined(vax) || defined(ns32000) || defined(sun386) || \
64 defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
65 defined(__alpha__) || defined(__alpha)
66 #define BYTE_ORDER LITTLE_ENDIAN
67 #endif
68
69 #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
70 defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
71 defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
72 defined(apollo) || defined(__convex__) || defined(_CRAY) || \
73 defined(__hppa) || defined(__hp9000) || \
74 defined(__hp9000s300) || defined(__hp9000s700) || \
75 defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
76 #define BYTE_ORDER BIG_ENDIAN
77 #endif
78 #endif /* linux */
79 #endif /* BSD */
80 #endif /* BYTE_ORDER */
81
82 #if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
83 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
84 #define BYTE_ORDER LITTLE_ENDIAN
85 #else
86 #define BYTE_ORDER BIG_ENDIAN
87 #endif
88 #endif
89
90 #if !defined(BYTE_ORDER) || \
91 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
92 /* you must determine what the correct bit order is for
93 * your compiler - the next line is an intentional error
94 * which will force your compiles to bomb until you fix
95 * the above macros.
96 */
97 #error "Undefined or invalid BYTE_ORDER"
98 #endif
99
100 #if (__i386 || __amd64) && __GNUC__
101 #define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
102 #if GNUC_VERSION >= 40100
103 #define HAVE_ATOMIC
104 #endif
105 #endif
106
107
108 #endif