diff --git a/changes/bug19139 b/changes/bug19139 new file mode 100644 index 000000000..2e53d7d44 --- /dev/null +++ b/changes/bug19139 @@ -0,0 +1,3 @@ + o Minor features (build): + - Use the Autoconf macro AC_USE_SYSTEM_EXTENSIONS to automatically + turn on C and POSIX extensions. Closes ticket 19139. diff --git a/configure.ac b/configure.ac index 386fcdd13..6d721a2fc 100644 --- a/configure.ac +++ b/configure.ac @@ -16,6 +16,7 @@ AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AC_CONFIG_HEADERS([orconfig.h]) +AC_USE_SYSTEM_EXTENSIONS AC_CANONICAL_HOST PKG_PROG_PKG_CONFIG @@ -1552,9 +1553,6 @@ int main(int c, char **v) { puts(__FUNCTION__); }])], AC_CACHE_CHECK([whether we have extern char **environ already declared], tor_cv_have_environ_declared, AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -/* We define _GNU_SOURCE here because it is also defined in compat.c. - * Without it environ doesn't get declared. */ -#define _GNU_SOURCE #ifdef HAVE_UNISTD_H #include #endif diff --git a/m4/pc_from_ucontext.m4 b/m4/pc_from_ucontext.m4 index 6bedcbb2d..8a9dc459e 100644 --- a/m4/pc_from_ucontext.m4 +++ b/m4/pc_from_ucontext.m4 @@ -79,24 +79,21 @@ AC_DEFUN([AC_PC_FROM_UCONTEXT], if ! $pc_field_found; then # Prefer sys/ucontext.h to ucontext.h, for OS X's sake. if test "x$ac_cv_header_cygwin_signal_h" = xyes; then - AC_TRY_COMPILE([#define _GNU_SOURCE 1 - #include ], + AC_TRY_COMPILE([#include ], [ucontext_t u; return u.$pc_field == 0;], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) pc_field_found=true) elif test "x$ac_cv_header_sys_ucontext_h" = xyes; then - AC_TRY_COMPILE([#define _GNU_SOURCE 1 - #include ], + AC_TRY_COMPILE([#include ], [ucontext_t u; return u.$pc_field == 0;], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) AC_MSG_RESULT([$pc_field]) pc_field_found=true) elif test "x$ac_cv_header_ucontext_h" = xyes; then - AC_TRY_COMPILE([#define _GNU_SOURCE 1 - #include ], + AC_TRY_COMPILE([#include ], [ucontext_t u; return u.$pc_field == 0;], AC_DEFINE_UNQUOTED(PC_FROM_UCONTEXT, $pc_field, How to access the PC from a struct ucontext) diff --git a/src/common/backtrace.c b/src/common/backtrace.c index 3b762b68e..afdc10d6a 100644 --- a/src/common/backtrace.c +++ b/src/common/backtrace.c @@ -13,9 +13,6 @@ * detect crashes. */ -#define __USE_GNU -#define _GNU_SOURCE 1 - #include "orconfig.h" #include "compat.h" #include "util.h" diff --git a/src/common/compat.c b/src/common/compat.c index 370881b07..72dffe2a6 100644 --- a/src/common/compat.c +++ b/src/common/compat.c @@ -12,18 +12,6 @@ * the platform. **/ -/* This is required on rh7 to make strptime not complain. - * We also need it to make memmem get defined (where available) - */ - -/* XXXX We should just use AC_USE_SYSTEM_EXTENSIONS in our autoconf, - * and get this (and other important stuff!) automatically. Once we do that, - * make sure to also change the extern char **environ detection in - * configure.ac, because whether that is declared or not depends on whether - * we have _GNU_SOURCE defined! Maybe that means that once we take this out, - * we can also take out the configure check. */ -#define _GNU_SOURCE - #define COMPAT_PRIVATE #include "compat.h" diff --git a/src/common/compat_pthreads.c b/src/common/compat_pthreads.c index 1b24cc3c2..1d6db3422 100644 --- a/src/common/compat_pthreads.c +++ b/src/common/compat_pthreads.c @@ -10,8 +10,6 @@ * functions. */ -#define _GNU_SOURCE - #include "orconfig.h" #include #include diff --git a/src/common/compat_threads.c b/src/common/compat_threads.c index 8f9001258..9c6fa55b3 100644 --- a/src/common/compat_threads.c +++ b/src/common/compat_threads.c @@ -11,8 +11,6 @@ * modules.) */ -#define _GNU_SOURCE - #include "orconfig.h" #include #include "compat.h" diff --git a/src/common/crypto.c b/src/common/crypto.c index f47f5d247..d5043c324 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -56,7 +56,6 @@ ENABLE_GCC_WARNING(redundant-decls) #include #endif #ifdef HAVE_UNISTD_H -#define _GNU_SOURCE #include #endif #ifdef HAVE_FCNTL_H diff --git a/src/common/sandbox.c b/src/common/sandbox.c index 4e2c5cde2..94b2fc678 100644 --- a/src/common/sandbox.c +++ b/src/common/sandbox.c @@ -39,8 +39,6 @@ #if defined(USE_LIBSECCOMP) -#define _GNU_SOURCE - #include #include #include diff --git a/src/common/sandbox.h b/src/common/sandbox.h index 2defd8bbd..c5963e311 100644 --- a/src/common/sandbox.h +++ b/src/common/sandbox.h @@ -39,12 +39,6 @@ typedef struct sandbox_cfg_elem sandbox_cfg_t; */ #ifdef USE_LIBSECCOMP -#ifndef __USE_GNU -#define __USE_GNU -#endif -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif #include #include #include diff --git a/src/common/util.c b/src/common/util.c index 2f7cc4f89..7217cdc81 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -9,10 +9,6 @@ * process control. **/ -/* This is required on rh7 to make strptime not complain. - */ -#define _GNU_SOURCE - #include "orconfig.h" #ifdef HAVE_FCNTL_H #include diff --git a/src/ext/eventdns.c b/src/ext/eventdns.c index 7046f32eb..f5b7723b5 100644 --- a/src/ext/eventdns.c +++ b/src/ext/eventdns.c @@ -50,9 +50,6 @@ #endif #endif -/* #define _POSIX_C_SOURCE 200507 */ -#define _GNU_SOURCE - #ifdef DNS_USE_CPU_CLOCK_FOR_ID #ifdef DNS_USE_OPENSSL_FOR_ID #error Multiple id options selected