]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use the Autoconf macro AC_USE_SYSTEM_EXTENSIONS
authorcypherpunks <cypherpunks@torproject.org>
Fri, 17 Jun 2016 13:43:25 +0000 (13:43 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 17 Jun 2016 14:17:44 +0000 (10:17 -0400)
The Autoconf macro AC_USE_SYSTEM_EXTENSIONS defines preprocessor macros
which turn on extensions to C and POSIX. The macro also makes it easier
for developers to use the extensions without needing (or forgetting) to
define them manually.

The macro can be safely used because it was introduced in Autoconf 2.60
and Tor requires Autoconf 2.63 and above.

12 files changed:
changes/bug19139 [new file with mode: 0644]
configure.ac
m4/pc_from_ucontext.m4
src/common/backtrace.c
src/common/compat.c
src/common/compat_pthreads.c
src/common/compat_threads.c
src/common/crypto.c
src/common/sandbox.c
src/common/sandbox.h
src/common/util.c
src/ext/eventdns.c

diff --git a/changes/bug19139 b/changes/bug19139
new file mode 100644 (file)
index 0000000..2e53d7d
--- /dev/null
@@ -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.
index 386fcdd132cfa7eb910fbe6077162b0524da0a6a..6d721a2fc595c30e586289dddde5a06e7c24ab62 100644 (file)
@@ -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 <unistd.h>
 #endif
index 6bedcbb2da3156d2013cc7058a091a2c435bf49b..8a9dc459e6658fa876635166261cee904defed8e 100644 (file)
@@ -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 <cygwin/signal.h>],
+         AC_TRY_COMPILE([#include <cygwin/signal.h>],
                         [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 <sys/ucontext.h>],
+         AC_TRY_COMPILE([#include <sys/ucontext.h>],
                         [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 <ucontext.h>],
+         AC_TRY_COMPILE([#include <ucontext.h>],
                         [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)
index 3b762b68e39230455a4606a79931c1e8e281ab0b..afdc10d6a9ad87942d84140f5598f7159371e2e9 100644 (file)
@@ -13,9 +13,6 @@
  * detect crashes.
  */
 
-#define __USE_GNU
-#define _GNU_SOURCE 1
-
 #include "orconfig.h"
 #include "compat.h"
 #include "util.h"
index 370881b07e4974b09c43a38a653649fb4758068d..72dffe2a6e18d5d04ab8ca7def301f69479e95f3 100644 (file)
  * 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"
 
index 1b24cc3c2a668874cae911f6a40e7dc6c5c9cd47..1d6db3422532311d8ac3c96e843c8e62dc3881ea 100644 (file)
@@ -10,8 +10,6 @@
  * functions.
  */
 
-#define _GNU_SOURCE
-
 #include "orconfig.h"
 #include <pthread.h>
 #include <signal.h>
index 8f9001258a31a50260b091b52af76feb1e23a7db..9c6fa55b32824dc20af51c1b4883b7d7dd6067bc 100644 (file)
@@ -11,8 +11,6 @@
  *  modules.)
  */
 
-#define _GNU_SOURCE
-
 #include "orconfig.h"
 #include <stdlib.h>
 #include "compat.h"
index f47f5d2471b6b0a4f52836d7d5864c28daa6a4c3..d5043c32463c66055af29a2686797db542fe9335 100644 (file)
@@ -56,7 +56,6 @@ ENABLE_GCC_WARNING(redundant-decls)
 #include <ctype.h>
 #endif
 #ifdef HAVE_UNISTD_H
-#define _GNU_SOURCE
 #include <unistd.h>
 #endif
 #ifdef HAVE_FCNTL_H
index 4e2c5cde22f7980d9d112fdf18f70774d8eb1908..94b2fc678845cfb519d8b6b8d657233031c05b26 100644 (file)
@@ -39,8 +39,6 @@
 
 #if defined(USE_LIBSECCOMP)
 
-#define _GNU_SOURCE
-
 #include <sys/mman.h>
 #include <sys/syscall.h>
 #include <sys/types.h>
index 2defd8bbd4fc768492803c6fc154e5a9ac7d2cf1..c5963e311927ed405896873e3e56ad1fa10e8757 100644 (file)
@@ -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 <sys/ucontext.h>
 #include <seccomp.h>
 #include <netdb.h>
index 2f7cc4f8929f6fb2758935c7bbc74711c928679a..7217cdc81e11a73972569a0e75ac2ef1b71cd6fd 100644 (file)
@@ -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 <fcntl.h>
index 7046f32eb9965308e2cdf87028593b8b8e743885..f5b7723b54f6c40f62fe8cee7bdef5f3e4d78bb7 100644 (file)
@@ -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