1 /* Multithreading primitives.
2 Copyright (C) 2005-2021 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, see <https://www.gnu.org/licenses/>. */
17 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */
21 /* ========================================================================= */
23 #if USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS
25 /* Use the POSIX threads library. */
31 # if PTHREAD_IN_USE_DETECTION_HARD
33 # if defined __FreeBSD__ || defined __DragonFly__ /* FreeBSD */
35 /* Test using pthread_key_create. */
38 glthread_in_use (void)
41 static int result; /* 1: linked with -lpthread, 0: only with libc */
46 int err = pthread_key_create (&key, NULL);
54 pthread_key_delete (key);
61 # else /* Solaris, HP-UX */
63 /* Test using pthread_create. */
65 /* The function to be executed by a dummy thread. */
67 dummy_thread_func (void *arg)
73 glthread_in_use (void)
76 static int result; /* 1: linked with -lpthread, 0: only with libc */
82 if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
83 /* Thread creation failed. */
87 /* Thread creation works. */
89 if (pthread_join (thread, &retval) != 0)
104 /* ========================================================================= */
106 /* This declaration is solely to ensure that after preprocessing
107 this file is never empty. */