port: Add pthread_setname_np FreeBSD compat
[lttng-tools.git] / m4 / lttng_pthread_setname_np.m4
1 # SYNOPSIS
2 #
3 # LTTNG_PTHREAD_SETNAME_NP
4 #
5 # LICENSE
6 #
7 # Copyright (c) 2020 Michael Jeanson <mjeanson@efficios.com>
8 #
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation; either version 2 of the License, or (at your
12 # option) any later version.
13 #
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 # Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License along
20 # with this program. If not, see <https://www.gnu.org/licenses/>.
21 #
22 # As a special exception, the respective Autoconf Macro's copyright owner
23 # gives unlimited permission to copy, distribute and modify the configure
24 # scripts that are the output of Autoconf when processing the Macro. You
25 # need not follow the terms of the GNU General Public License when using
26 # or distributing such scripts, even though portions of the text of the
27 # Macro appear in them. The GNU General Public License (GPL) does govern
28 # all other use of the material that constitutes the Autoconf Macro.
29 #
30 # This special exception to the GPL applies to versions of the Autoconf
31 # Macro released by the Autoconf Archive. When you make and distribute a
32 # modified version of the Autoconf Macro, you may extend this special
33 # exception to the GPL to apply to your modified version as well.
34
35 AC_DEFUN([LTTNG_PTHREAD_SETNAME_NP], [
36 AC_REQUIRE([AX_PTHREAD])
37 AC_LANG_PUSH([C])
38
39 lttng_pthread_setname_np_save_LDFLAGS="$LDFLAGS"
40 lttng_pthread_setname_np_save_LIBS="$LIBS"
41 LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS"
42 LIBS="$LIBS $PTHREAD_LIBS"
43
44 # GLIBC >= 2.12, Solaris >= 11.3
45 AC_MSG_CHECKING(for pthread_setname_np(pthread_t, const char*))
46 AC_LINK_IFELSE(
47 [AC_LANG_PROGRAM(
48 [#include <pthread.h>],
49 [pthread_setname_np(pthread_self(), "example")])],
50 [AC_MSG_RESULT(yes)
51 AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITH_TID,1,
52 [Have function pthread_setname_np(pthread_t, const char*)])],
53 [AC_MSG_RESULT(no)])
54
55 # MacOS X >= 10.6, iOS >= 3.2
56 AC_MSG_CHECKING(for pthread_setname_np(const char*))
57 AC_LINK_IFELSE(
58 [AC_LANG_PROGRAM(
59 [#include <pthread.h>],
60 [pthread_setname_np("example")])],
61 [AC_MSG_RESULT(yes)
62 AC_DEFINE(HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID,1,
63 [Have function pthread_setname_np(const char*)])],
64 [AC_MSG_RESULT(no)])
65
66 # FreeBSD
67 AC_MSG_CHECKING(for pthread_set_name_np(pthread_t, const char*))
68 AC_LINK_IFELSE(
69 [AC_LANG_PROGRAM(
70 [#include <pthread.h>
71 #include <pthread_np.h>],
72 [pthread_set_name_np(pthread_self(), "example")])],
73 [AC_MSG_RESULT(yes)
74 AC_DEFINE(HAVE_PTHREAD_SET_NAME_NP_WITH_TID,1,
75 [Have function pthread_set_name_np(pthread_t, const char*)])],
76 [AC_MSG_RESULT(no)])
77
78 LDFLAGS=$lttng_pthread_setname_np_save_LDFLAGS
79 LIBS=$lttng_pthread_setname_np_save_LIBS
80
81 AC_LANG_POP
82 ])dnl LTTNG_PTHREAD_SETNAME_NP
This page took 0.056504 seconds and 5 git commands to generate.