common: add more bytecode helpers
[lttng-tools.git] / m4 / lttng_pthread_getname_np.m4
1 # SYNOPSIS
2 #
3 # LTTNG_PTHREAD_GETNAME_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_GETNAME_NP], [
36 AC_REQUIRE([AX_PTHREAD])
37 AC_LANG_PUSH([C])
38
39 lttng_pthread_getname_np_save_LDFLAGS="$LDFLAGS"
40 lttng_pthread_getname_np_save_LIBS="$LIBS"
41 LDFLAGS="$LDFLAGS $PTHREAD_CFLAGS"
42 LIBS="$LIBS $PTHREAD_LIBS"
43
44 # GLIBC >= 2.12, Solaris >= 11.3, FreeBSD >= 12.2, MacOS X >= 10.6, iOS >= 3.2
45 AC_MSG_CHECKING(for pthread_getname_np(pthread_t, char*, size_t))
46 AC_LINK_IFELSE(
47 [AC_LANG_PROGRAM(
48 [[#include <pthread.h>
49 #ifdef __FreeBSD__
50 #include <pthread_np.h>
51 #endif
52 #define LTTNG_PTHREAD_NAMELEN 16
53 char lttng_pthread_name[LTTNG_PTHREAD_NAMELEN];]],
54 [pthread_getname_np(pthread_self(), lttng_pthread_name, LTTNG_PTHREAD_NAMELEN)])],
55 [AC_MSG_RESULT(yes)
56 AC_DEFINE(HAVE_PTHREAD_GETNAME_NP_WITH_TID,1,
57 [Have function pthread_getname_np(pthread_t, char*, size_t)])],
58 [AC_MSG_RESULT(no)])
59
60 AC_MSG_CHECKING(for pthread_getname_np(char*, size_t))
61 AC_LINK_IFELSE(
62 [AC_LANG_PROGRAM(
63 [[#include <pthread.h>
64 #ifdef __FreeBSD__
65 #include <pthread_np.h>
66 #endif
67 #define LTTNG_PTHREAD_NAMELEN 16
68 char lttng_pthread_name[LTTNG_PTHREAD_NAMELEN];]],
69 [pthread_getname_np(lttng_pthread_name, LTTNG_PTHREAD_NAMELEN)])],
70 [AC_MSG_RESULT(yes)
71 AC_DEFINE(HAVE_PTHREAD_GETNAME_NP_WITHOUT_TID,1,
72 [Have function pthread_getname_np(char*, size_t)])],
73 [AC_MSG_RESULT(no)])
74
75 # FreeBSD
76 AC_MSG_CHECKING(for pthread_get_name_np(pthread_t, char*, size_t))
77 AC_LINK_IFELSE(
78 [AC_LANG_PROGRAM(
79 [[#include <pthread.h>
80 #ifdef __FreeBSD__
81 #include <pthread_np.h>
82 #endif
83 #define LTTNG_PTHREAD_NAMELEN 16
84 char lttng_pthread_name[LTTNG_PTHREAD_NAMELEN];]],
85 [pthread_get_name_np(pthread_self(), lttng_pthread_name, LTTNG_PTHREAD_NAMELEN)])],
86 [AC_MSG_RESULT(yes)
87 AC_DEFINE(HAVE_PTHREAD_GET_NAME_NP_WITH_TID,1,
88 [Have function pthread_get_name_np(pthread_t, char*, size_t)])],
89 [AC_MSG_RESULT(no)])
90
91 LDFLAGS=$lttng_pthread_getname_np_save_LDFLAGS
92 LIBS=$lttng_pthread_getname_np_save_LIBS
93
94 AC_LANG_POP
95 ])dnl LTTNG_PTHREAD_GETNAME_NP
This page took 0.030435 seconds and 4 git commands to generate.