diff options
author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-01-31 14:46:01 +0100 |
commit | e8bd88d1fcded01ccd066572eeaae1b507989cb3 (patch) | |
tree | c8e7be6c07c6f635f6e803e6a6ba9e7a95fee7c0 /gl/glthread/threadlib.c | |
parent | 2ad962c13473607ca0d974bfaa516a0ed53ec73d (diff) | |
download | monitoring-plugins-e8bd88d1fcded01ccd066572eeaae1b507989cb3.tar.gz |
Sync with the latest Gnulib code 668c0b8ffa
Diffstat (limited to 'gl/glthread/threadlib.c')
-rw-r--r-- | gl/glthread/threadlib.c | 55 |
1 files changed, 45 insertions, 10 deletions
diff --git a/gl/glthread/threadlib.c b/gl/glthread/threadlib.c index b4476573..5ecf827f 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 | |||
37 | int | ||
38 | glthread_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. */ |
33 | static void * | 66 | static void * |
34 | dummy_thread_func (void *arg) | 67 | dummy_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 |