+2008-08-17 Bruno Haible <bruno@clisp.org>
+
+ * threadlib.c: New file, extracted from lock.c.
+ * lock.c (dummy_thread_func, glthread_in_use): Remove functions.
+ * Makefile.in (SOURCES): Add threadlib.c.
+ (OBJECTS): Add threadlib.$lo.
+ (threadlib.lo): New rule.
+
2008-08-14 Bruno Haible <bruno@clisp.org>
* lock.h (glthread_lock_lock, glthread_lock_unlock,
plural.y \
plural-exp.c \
localcharset.c \
+ threadlib.c \
lock.c \
relocatable.c \
langprefs.c \
plural.$lo \
plural-exp.$lo \
localcharset.$lo \
+ threadlib.$lo \
lock.$lo \
relocatable.$lo \
langprefs.$lo \
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c
localcharset.lo: $(srcdir)/localcharset.c
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c
+threadlib.lo: $(srcdir)/threadlib.c
+ $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/threadlib.c
lock.lo: $(srcdir)/lock.c
$(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/lock.c
relocatable.lo: $(srcdir)/relocatable.c
#if USE_POSIX_THREADS
-/* Use the POSIX threads library. */
-
-# if PTHREAD_IN_USE_DETECTION_HARD
-
-/* The function to be executed by a dummy thread. */
-static void *
-dummy_thread_func (void *arg)
-{
- return arg;
-}
-
-int
-glthread_in_use (void)
-{
- static int tested;
- static int result; /* 1: linked with -lpthread, 0: only with libc */
-
- if (!tested)
- {
- pthread_t thread;
-
- if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
- /* Thread creation failed. */
- result = 0;
- else
- {
- /* Thread creation works. */
- void *retval;
- if (pthread_join (thread, &retval) != 0)
- abort ();
- result = 1;
- }
- tested = 1;
- }
- return result;
-}
-
-# endif
-
/* -------------------------- gl_lock_t datatype -------------------------- */
/* ------------------------- gl_rwlock_t datatype ------------------------- */
--- /dev/null
+/* Multithreading primitives.
+ Copyright (C) 2005-2008 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Library General Public License as published
+ by the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+/* Written by Bruno Haible <bruno@clisp.org>, 2005. */
+
+#include <config.h>
+
+/* ========================================================================= */
+
+#if USE_POSIX_THREADS
+
+/* Use the POSIX threads library. */
+
+# if PTHREAD_IN_USE_DETECTION_HARD
+
+/* The function to be executed by a dummy thread. */
+static void *
+dummy_thread_func (void *arg)
+{
+ return arg;
+}
+
+int
+glthread_in_use (void)
+{
+ static int tested;
+ static int result; /* 1: linked with -lpthread, 0: only with libc */
+
+ if (!tested)
+ {
+ pthread_t thread;
+
+ if (pthread_create (&thread, NULL, dummy_thread_func, NULL) != 0)
+ /* Thread creation failed. */
+ result = 0;
+ else
+ {
+ /* Thread creation works. */
+ void *retval;
+ if (pthread_join (thread, &retval) != 0)
+ abort ();
+ result = 1;
+ }
+ tested = 1;
+ }
+ return result;
+}
+
+# endif
+
+#endif
+
+/* ========================================================================= */