Install gettext-0.18.1.1.tar.gz
[msysgit.git] / mingw / share / gettext / intl / threadlib.c
blobcb4fe4f05690c8e951bcd8bf794b245d45d7ce2d
1 /* Multithreading primitives.
2 Copyright (C) 2005-2009 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU Library General Public License as published
6 by the Free Software Foundation; either version 2, or (at your option)
7 any later version.
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 GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
17 USA. */
19 /* Written by Bruno Haible <bruno@clisp.org>, 2005. */
21 #include <config.h>
23 /* ========================================================================= */
25 #if USE_POSIX_THREADS
27 /* Use the POSIX threads library. */
29 # include <pthread.h>
30 # include <stdlib.h>
32 # if PTHREAD_IN_USE_DETECTION_HARD
34 /* The function to be executed by a dummy thread. */
35 static void *
36 dummy_thread_func (void *arg)
38 return arg;
41 int
42 glthread_in_use (void)
44 static int tested;
45 static int result; /* 1: linked with -lpthread, 0: only with libc */
47 if (!tested)
49 pthread_t thread;
51 if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
52 /* Thread creation failed. */
53 result = 0;
54 else
56 /* Thread creation works. */
57 void *retval;
58 if (pthread_join (thread, &retval) != 0)
59 abort ();
60 result = 1;
62 tested = 1;
64 return result;
67 # endif
69 #endif
71 /* ========================================================================= */
73 /* This declaration is solely to ensure that after preprocessing
74 this file is never empty. */
75 typedef int dummy;