]> git.saurik.com Git - redis.git/blame - src/config.h
Test: MULTI/EXEC tests moved into multi.tcl.
[redis.git] / src / config.h
CommitLineData
4365e5b2 1/*
2 * Copyright (c) 2009-2012, Salvatore Sanfilippo <antirez at gmail dot com>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
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.
16 *
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.
28 */
29
dde65f3f 30#ifndef __CONFIG_H
31#define __CONFIG_H
32
06db1f50 33#ifdef __APPLE__
34#include <AvailabilityMacros.h>
35#endif
36
32f99c51 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__
3cb43283 48#define HAVE_PROC_STAT 1
49#define HAVE_PROC_MAPS 1
50#define HAVE_PROC_SMAPS 1
eddb388e 51#endif
52
b1a8e3e8 53/* Test for task_info() */
73db2acc 54#if defined(__APPLE__)
55#define HAVE_TASKINFO 1
56#endif
57
b1a8e3e8 58/* Test for backtrace() */
ca2344f9 59#if defined(__APPLE__) || defined(__linux__) || defined(__sun)
d76412d1 60#define HAVE_BACKTRACE 1
61#endif
62
b1a8e3e8 63/* Test for polling API */
266373b2 64#ifdef __linux__
65#define HAVE_EPOLL 1
66#endif
67
37be2765 68#if (defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__)
f3053eb0
HM
69#define HAVE_KQUEUE 1
70#endif
71
05da63da
DP
72#ifdef __sun
73#include <sys/feature_tests.h>
74#ifdef _DTRACE_VERSION
75#define HAVE_EVPORT 1
76#endif
77#endif
78
b1a8e3e8 79/* Define aof_fsync to fdatasync() in Linux and fsync() for all the rest */
10ce1276 80#ifdef __linux__
81#define aof_fsync fdatasync
82#else
83#define aof_fsync fsync
84#endif
85
784b9308 86/* Define rdb_fsync_range to sync_file_range() on Linux, otherwise we use
87 * the plain fsync() call. */
88#ifdef __linux__
d2f83d4a 89#include <linux/version.h>
4800331b 90#include <features.h>
89423052 91#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
4800331b 92#if (LINUX_VERSION_CODE >= 0x020611 && __GLIBC_PREREQ(2, 6))
d2f83d4a 93#define HAVE_SYNC_FILE_RANGE 1
94#endif
95#else
4800331b 96#if (LINUX_VERSION_CODE >= 0x020611)
d2f83d4a 97#define HAVE_SYNC_FILE_RANGE 1
98#endif
99#endif
100#endif
101
102#ifdef HAVE_SYNC_FILE_RANGE
784b9308 103#define rdb_fsync_range(fd,off,size) sync_file_range(fd,off,size,SYNC_FILE_RANGE_WAIT_BEFORE|SYNC_FILE_RANGE_WRITE)
104#else
105#define rdb_fsync_range(fd,off,size) fsync(fd)
106#endif
107
b1a8e3e8 108/* Byte ordering detection */
109#include <sys/types.h> /* This will likely define BYTE_ORDER */
110
111#ifndef BYTE_ORDER
112#if (BSD >= 199103)
113# include <machine/endian.h>
114#else
115#if defined(linux) || defined(__linux__)
116# include <endian.h>
117#else
118#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
119#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
120#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
121
3f7438ef
PN
122#if defined(__i386__) || defined(__x86_64__) || defined(__amd64__) || \
123 defined(vax) || defined(ns32000) || defined(sun386) || \
124 defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
125 defined(__alpha__) || defined(__alpha)
126#define BYTE_ORDER LITTLE_ENDIAN
b1a8e3e8 127#endif
128
129#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
130 defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
131 defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
132 defined(apollo) || defined(__convex__) || defined(_CRAY) || \
133 defined(__hppa) || defined(__hp9000) || \
134 defined(__hp9000s300) || defined(__hp9000s700) || \
135 defined (BIT_ZERO_ON_LEFT) || defined(m68k) || defined(__sparc)
136#define BYTE_ORDER BIG_ENDIAN
137#endif
138#endif /* linux */
139#endif /* BSD */
140#endif /* BYTE_ORDER */
141
142#if defined(__BYTE_ORDER) && !defined(BYTE_ORDER)
143#if (__BYTE_ORDER == __LITTLE_ENDIAN)
144#define BYTE_ORDER LITTLE_ENDIAN
145#else
146#define BYTE_ORDER BIG_ENDIAN
147#endif
148#endif
149
150#if !defined(BYTE_ORDER) || \
48e46215 151 (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN)
b1a8e3e8 152 /* you must determine what the correct bit order is for
153 * your compiler - the next line is an intentional error
154 * which will force your compiles to bomb until you fix
155 * the above macros.
156 */
157#error "Undefined or invalid BYTE_ORDER"
158#endif
159
80ff1fc6 160#if (__i386 || __amd64) && __GNUC__
1d6628c0
JW
161#define GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
162#if GNUC_VERSION >= 40100
163#define HAVE_ATOMIC
164#endif
80ff1fc6
PH
165#endif
166
167
dde65f3f 168#endif