summaryrefslogtreecommitdiffstats
path: root/gl/glthread/threadlib.c
diff options
context:
space:
mode:
authorKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
committerKristian Schuster <116557017+KriSchu@users.noreply.github.com>2023-02-19 22:49:18 (GMT)
commita0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch)
tree8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/glthread/threadlib.c
parentca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff)
parentc07206f2ccc2356aa74bc6813a94c2190017d44e (diff)
downloadmonitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
Diffstat (limited to 'gl/glthread/threadlib.c')
-rw-r--r--gl/glthread/threadlib.c55
1 files changed, 45 insertions, 10 deletions
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c
index b447657..5ecf827 100644
--- a/gl/glthread/threadlib.c
+++ b/gl/glthread/threadlib.c
@@ -1,18 +1,18 @@
1/* Multithreading primitives. 1/* Multithreading primitives.
2 Copyright (C) 2005-2013 Free Software Foundation, Inc. 2 Copyright (C) 2005-2023 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU Lesser General Public License as
6 the Free Software Foundation; either version 3, or (at your option) 6 published by the Free Software Foundation; either version 2.1 of the
7 any later version. 7 License, or (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This file is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU Lesser General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU Lesser General Public License
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */ 15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16 16
17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */ 17/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
18 18
@@ -20,15 +20,48 @@
20 20
21/* ========================================================================= */ 21/* ========================================================================= */
22 22
23#if USE_POSIX_THREADS 23#if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS
24 24
25/* Use the POSIX threads library. */ 25/* Use the POSIX threads library. */
26 26
27# include <errno.h>
27# include <pthread.h> 28# include <pthread.h>
28# include <stdlib.h> 29# include <stdlib.h>
29 30
30# if PTHREAD_IN_USE_DETECTION_HARD 31# if PTHREAD_IN_USE_DETECTION_HARD
31 32
33# if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
34
35/* Test using pthread_key_create. */
36
37int
38glthread_in_use (void)
39{
40 static int tested;
41 static int result; /* 1: linked with -lpthread, 0: only with libc */
42
43 if (!tested)
44 {
45 pthread_key_t key;
46 int err = pthread_key_create (&key, NULL);
47
48 if (err == ENOSYS)
49 result = 0;
50 else
51 {
52 result = 1;
53 if (err == 0)
54 pthread_key_delete (key);
55 }
56 tested = 1;
57 }
58 return result;
59}
60
61# else /* Solaris, HP-UX */
62
63/* Test using pthread_create. */
64
32/* The function to be executed by a dummy thread. */ 65/* The function to be executed by a dummy thread. */
33static void * 66static void *
34dummy_thread_func (void *arg) 67dummy_thread_func (void *arg)
@@ -62,6 +95,8 @@ glthread_in_use (void)
62 return result; 95 return result;
63} 96}
64 97
98# endif
99
65# endif 100# endif
66 101
67#endif 102#endif