From: Sara Golemon <sgolemon@fb.com>
Date: Wed, 11 Feb 2015 02:00:05 +0000 (-0800)
Subject: Autodetect pthread_atfork() support
X-Git-Tag: v0.25.0~1
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=07367f14d28f86f6395b6ea46a0015405e799a46;p=folly.git

Autodetect pthread_atfork() support

Summary: This is usually available on linux

Test Plan: Existing tests and manual test on arclinux

Reviewed By: mpawlowski@fb.com

Subscribers: folly-diffs@, yfeldblum

FB internal diff: D1840081

Signature: t1:1840081:1423619986:911c95f9f04f286e9f113543ab4b705cf1b17396
---

diff --git a/folly/configure.ac b/folly/configure.ac
index 023a9fb6..8b3eb1ac 100644
--- a/folly/configure.ac
+++ b/folly/configure.ac
@@ -264,6 +264,23 @@ AC_SEARCH_LIBS([clock_gettime], [rt],
     [Define to 1 if we support clock_gettime(2).]),
   [])
 
+# Check for pthread_atfork(3). This is not in an AC_CHECK_FUNCS() because we
+# want to include pthread.h if necessary.
+AC_CACHE_CHECK(
+  [for pthread_atfork support],
+  [folly_cv_prog_cc_pthread_atfork],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_SOURCE[
+      #include <pthread.h>
+      void func() {pthread_atfork(NULL, NULL, NULL);}]
+    ],
+    [folly_cv_prog_cc_pthread_atfork=yes],
+    [folly_cv_prog_cc_pthread_atfork=no])])
+
+if test "$folly_cv_prog_cc_pthread_atfork" = "yes"; then
+  AC_DEFINE([HAVE_PTHREAD_ATFORK], [1], [Define to 1 if the compiler supports pthread_atfork])
+fi
+
 # Checks for library functions.
 AC_CHECK_FUNCS([getdelim \
                 gettimeofday \
@@ -272,7 +289,6 @@ AC_CHECK_FUNCS([getdelim \
                 pow \
                 strerror \
                 pthread_yield \
-                pthread_atfork \
                 malloc_size \
                 malloc_usable_size \
                 memrchr \