summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Brewer <jzb0012@auburn.edu>2018-04-13 14:40:34 -0500
committerJustin Brewer <jzb0012@auburn.edu>2018-04-28 16:35:40 -0500
commit49bbaacc79dc73ed797450aa94463106b18d2a5d (patch)
treea6850a1e0c1d145b0ca5131dabc7a65a0c00944e
parentbbeab80090556ef115b6e11c9bbab534b9ea7717 (diff)
Strip down fmacros.h
strerror_r and addrinfo require _POSIX_C_SOURCE >= 200112L, which is implied by _XOPEN_SOURCE >= 600. With the removal of AF_LOCAL usage, the only non-standard features being used are the TCP_KEEP* socket flags. _DARWIN_C_SOURCE is required to expose TCP_KEEPALIVE. Fall back to using _XOPEN_SOURCE 600 for all platforms, and additionally define _DARWIN_C_SOURCE for Darwin. Signed-off-by: Justin Brewer <jzb0012@auburn.edu>
-rw-r--r--fmacros.h30
-rw-r--r--net.c2
2 files changed, 3 insertions, 29 deletions
diff --git a/fmacros.h b/fmacros.h
index 4cdbc13..3227faa 100644
--- a/fmacros.h
+++ b/fmacros.h
@@ -1,38 +1,12 @@
#ifndef __HIREDIS_FMACRO_H
#define __HIREDIS_FMACRO_H
-#if defined(__linux__)
-#define _BSD_SOURCE
-#define _DEFAULT_SOURCE
-#endif
-
-#if defined(__CYGWIN__)
-#include <sys/cdefs.h>
-#endif
-
-#if defined(__linux__) || defined(__OpenBSD__) || defined(__NetBSD__)
#define _XOPEN_SOURCE 600
-#elif defined(__APPLE__) && defined(__MACH__)
-#define _XOPEN_SOURCE
-#elif defined(__FreeBSD__)
-// intentionally left blank, don't define _XOPEN_SOURCE
-#elif defined(AIX)
-// intentionally left blank, don't define _XOPEN_SOURCE
-#else
-#define _XOPEN_SOURCE
-#endif
-
-#if defined(__sun__)
#define _POSIX_C_SOURCE 200112L
-#endif
#if defined(__APPLE__) && defined(__MACH__)
-#define _OSX
-#endif
-
-#ifndef AIX
-# define _XOPEN_SOURCE_EXTENDED 1
-# define _ALL_SOURCE
+/* Enable TCP_KEEPALIVE */
+#define _DARWIN_C_SOURCE
#endif
#endif
diff --git a/net.c b/net.c
index 99f647d..44f2575 100644
--- a/net.c
+++ b/net.c
@@ -136,7 +136,7 @@ int redisKeepAlive(redisContext *c, int interval) {
val = interval;
-#ifdef _OSX
+#if defined(__APPLE__) && defined(__MACH__)
if (setsockopt(fd, IPPROTO_TCP, TCP_KEEPALIVE, &val, sizeof(val)) < 0) {
__redisSetError(c,REDIS_ERR_OTHER,strerror(errno));
return REDIS_ERR;