Fix: different pthread_getname_np signature() on macOS causes build failure
[lttng-tools.git] / m4 / lttng_pthread_setname_np.m4
index a8526e8d23eac3985a3d0bcb068fafe5343ab261..99fcc8d1e69d79d348f77d058e817619994227f6 100644 (file)
@@ -41,11 +41,14 @@ lttng_pthread_setname_np_save_LIBS="$LIBS"
 LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS"
 LIBS="$LIBS $PTHREAD_LIBS"
 
-# GLIBC >= 2.12, Solaris >= 11.3
+# GLIBC >= 2.12, Solaris >= 11.3, FreeBSD >= 12.2
 AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
 AC_LINK_IFELSE(
     [AC_LANG_PROGRAM(
-        [#include <pthread.h>],
+        [[#include <pthread.h>
+         #ifdef __FreeBSD__
+         #include <pthread_np.h>
+         #endif]],
         [pthread_setname_np(pthread_self(), "example")])],
     [AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
@@ -56,13 +59,30 @@ AC_LINK_IFELSE(
 AC_MSG_CHECKING(for pthread_setname_np(const char*))
 AC_LINK_IFELSE(
     [AC_LANG_PROGRAM(
-        [#include <pthread.h>],
+        [[#include <pthread.h>
+         #ifdef __FreeBSD__
+         #include <pthread_np.h>
+         #endif]],
         [pthread_setname_np("example")])],
     [AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
         [Have function pthread_setname_np(const char*)])],
     [AC_MSG_RESULT(no)])
 
+# FreeBSD
+AC_MSG_CHECKING(for pthread_set_name_np(pthread_t, const char*))
+AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM(
+        [[#include <pthread.h>
+         #ifdef __FreeBSD__
+         #include <pthread_np.h>
+         #endif]],
+        [pthread_set_name_np(pthread_self(), "example")])],
+    [AC_MSG_RESULT(yes)
+     AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP_WITH_TID,1,
+        [Have function pthread_set_name_np(pthread_t, const char*)])],
+    [AC_MSG_RESULT(no)])
+
 LDFLAGS=$lttng_pthread_setname_np_save_LDFLAGS
 LIBS=$lttng_pthread_setname_np_save_LIBS
 
This page took 0.023556 seconds and 4 git commands to generate.