configure.ac: stronger test for pthread linkage
[gitweb.git] / configure.ac
index 55e5a9b3e6c39f15d9d4cf419a72ee963713b662..a06177577c92b7e963cdbeb9a008bf1d7242bfa7 100644 (file)
@@ -1046,6 +1046,29 @@ GIT_CONF_SUBST([NO_INITGROUPS])
 #
 # Define NO_ICONV if your libc does not properly support iconv.
 
+AC_DEFUN([BSD_SYSCTL_SRC], [
+AC_LANG_PROGRAM([[
+#include <stddef.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+]],[[
+int val, mib[2];
+size_t len;
+mib[0] = CTL_HW;
+mib[1] = 1;
+len = sizeof(val);
+return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
+]])])
+
+#
+# Define HAVE_BSD_SYSCTL=YesPlease if a BSD-compatible sysctl function is available.
+AC_MSG_CHECKING([for BSD sysctl])
+AC_COMPILE_IFELSE([BSD_SYSCTL_SRC],
+       [AC_MSG_RESULT([yes])
+       HAVE_BSD_SYSCTL=YesPlease],
+       [AC_MSG_RESULT([no])
+       HAVE_BSD_SYSCTL=])
+GIT_CONF_SUBST([HAVE_BSD_SYSCTL])
 
 ## Other checks.
 # Define USE_PIC if you need the main git objects to be built with -fPIC
@@ -1060,14 +1083,19 @@ GIT_CONF_SUBST([NO_INITGROUPS])
 AC_DEFUN([PTHREADTEST_SRC], [
 AC_LANG_PROGRAM([[
 #include <pthread.h>
+static void *noop(void *ignore) { return ignore; }
 ]], [[
        pthread_mutex_t test_mutex;
        pthread_key_t test_key;
+       pthread_t th;
        int retcode = 0;
+       void *ret = (void *)0;
        retcode |= pthread_key_create(&test_key, (void *)0);
        retcode |= pthread_mutex_init(&test_mutex,(void *)0);
        retcode |= pthread_mutex_lock(&test_mutex);
        retcode |= pthread_mutex_unlock(&test_mutex);
+       retcode |= pthread_create(&th, ret, noop, ret);
+       retcode |= pthread_join(th, &ret);
        return retcode;
 ]])])