Skip to content
Snippets Groups Projects
Commit 78b79920 authored by David Klempner's avatar David Klempner
Browse files

Fix up feature test macros

Move all feature test macros to the start of the file and check that
they aren't already defined or defined to a lower value than the file
needs.

Projects should be allowed to put these in CFLAGS and we shouldn't break
when they do.
parent 78d1fd07
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
* *
*/ */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE #define _POSIX_SOURCE
#endif
#include "src/core/iomgr/sockaddr.h" #include "src/core/iomgr/sockaddr.h"
#include "src/core/iomgr/resolve_address.h" #include "src/core/iomgr/resolve_address.h"
......
...@@ -31,7 +31,9 @@ ...@@ -31,7 +31,9 @@
* *
*/ */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifdef GPR_LINUX #ifdef GPR_LINUX
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#ifdef GPR_POSIX_SOCKETUTILS #ifdef GPR_POSIX_SOCKETUTILS
#define _BSD_SOURCE
#include "src/core/iomgr/socket_utils_posix.h" #include "src/core/iomgr/socket_utils_posix.h"
#include <fcntl.h> #include <fcntl.h>
......
...@@ -31,11 +31,15 @@ ...@@ -31,11 +31,15 @@
* *
*/ */
/* FIXME: "posix" files shouldn't be depending on _GNU_SOURCE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifdef GPR_POSIX_SOCKET #ifdef GPR_POSIX_SOCKET
#define _GNU_SOURCE
#include "src/core/iomgr/tcp_server.h" #include "src/core/iomgr/tcp_server.h"
#include <limits.h> #include <limits.h>
......
...@@ -31,8 +31,14 @@ ...@@ -31,8 +31,14 @@
* *
*/ */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE #define _POSIX_SOURCE
#endif
#ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#ifdef GPR_LINUX #ifdef GPR_LINUX
......
...@@ -31,11 +31,16 @@ ...@@ -31,11 +31,16 @@
* *
*/ */
#ifndef _POSIX_C_SOURCE #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 200112L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#endif #endif
/* FIXME: "posix" files probably shouldn't depend on _GNU_SOURCE */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE #define _GNU_SOURCE
#endif
#include <grpc/support/port_platform.h> #include <grpc/support/port_platform.h>
#if defined(GPR_POSIX_LOG) #if defined(GPR_POSIX_LOG)
......
...@@ -33,7 +33,8 @@ ...@@ -33,7 +33,8 @@
/* Posix code for gpr snprintf support. */ /* Posix code for gpr snprintf support. */
#ifndef _POSIX_C_SOURCE #if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 200112L
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#endif #endif
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
* *
*/ */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE #define _POSIX_SOURCE
#endif
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
* *
*/ */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE #define _POSIX_SOURCE
#endif
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
......
...@@ -31,7 +31,10 @@ ...@@ -31,7 +31,10 @@
* *
*/ */
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE #define _POSIX_SOURCE
#endif
#include <unistd.h> #include <unistd.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment