]>
git.saurik.com Git - redis.git/blob - src/config.h
2 * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of Redis nor the names of its contributors may be used
14 * to endorse or promote products derived from this software without
15 * specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
34 #include <AvailabilityMacros.h>
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__) || defined(__sun)
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__)
71 #include <sys/feature_tests.h>
72 #ifdef _DTRACE_VERSION
77 /* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
79 #define aof_fsync fdatasync
81 #define aof_fsync fsync
84 /* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
85 * the plain fsync() call. */
87 #include <linux/version.h>
89 #if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
90 #if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
91 #define HAVE_SYNC_FILE_RANGE 1
94 #if (LINUX_VERSION_CODE >= 0x020611)
95 #define HAVE_SYNC_FILE_RANGE 1
100 #ifdef HAVE_SYNC_FILE_RANGE
101 #define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE)
103 #define rdb_fsync_range(fd,off,size) fsync(fd)
106 /* Byte ordering detection */
107 #include <sys/types.h> /* This will likely define BYTE_ORDER */
111 # include <machine/endian.h>
113 #if defined(linux) || defined(__linux__)
116 #define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
117 #define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
118 #define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
120 #if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
121 defined(vax) || defined(ns32000) || defined(sun386) || \
122 defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
123 defined(__alpha__) || defined(__alpha)
124 #define BYTE_ORDER LITTLE_ENDIAN
127 #if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
128 defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
129 defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
130 defined(apollo) || defined(__convex__) || defined(_CRAY) || \
131 defined(__hppa) || defined(__hp9000) || \
132 defined(__hp9000s300) || defined(__hp9000s700) || \
133 defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
134 #define BYTE_ORDER BIG_ENDIAN
138 #endif /* BYTE_ORDER */
140 /* Sometimes after including an OS-specific header that defines the
141 * endianess we end with __BYTE_ORDER but not with BYTE_ORDER that is what
142 * the Redis code uses. In this case let's define everything without the
146 #if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
147 #ifndef LITTLE_ENDIAN
148 #define LITTLE_ENDIAN __LITTLE_ENDIAN
151 #define BIG_ENDIAN __BIG_ENDIAN
153 #if (__BYTE_ORDER == __LITTLE_ENDIAN)
154 #define BYTE_ORDER LITTLE_ENDIAN
156 #define BYTE_ORDER BIG_ENDIAN
162 #if !defined(BYTE_ORDER) || \
163 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
164 /* you must determine what the correct bit order is for
165 * your compiler - the next line is an intentional error
166 * which will force your compiles to bomb until you fix
169 #error "Undefined or invalid BYTE_ORDER"
172 #if (__i386 || __amd64) && __GNUC__
173 #define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
174 #if GNUC_VERSION >= 40100