Move some code from module 'lock' to module 'threadlib'.
authorBruno Haible <bruno@clisp.org>
Sun, 17 Aug 2008 14:26:05 +0000 (16:26 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 17 Aug 2008 14:28:15 +0000 (16:28 +0200)
ChangeLog
lib/glthread/lock.c
lib/glthread/threadlib.c [new file with mode: 0644]
modules/threadlib

index 062b03e..e50ea6f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 
        New module 'threadlib'.
        * modules/threadlib: New file.
+       * lib/glthread/threadlib.c: New file, extracted from
+       lib/glthread/lock.c.
+       * lib/glthread/lock.c (dummy_thread_func, glthread_in_use): Remove
+       functions.
        * m4/threadlib.m4: New file, from m4/lock.m4, renaming gl_LOCK to
        gl_THREADLIB and gl_LOCK_EARLY to gl_THREADLIB_EARLY.
        * m4/lock.m4 (gl_LOCK_EARLY, gl_LOCK_EARLY_BODY, gl_LOCK_BODY): Remove
index 1391617..2ad0e06 100644 (file)
 
 #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 ------------------------- */
diff --git a/lib/glthread/threadlib.c b/lib/glthread/threadlib.c
new file mode 100644 (file)
index 0000000..a1601de
--- /dev/null
@@ -0,0 +1,67 @@
+/* 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 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 General Public License for more details.
+
+   You should have received a copy of the GNU 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
+
+/* ========================================================================= */
index ac659ea..9e3438c 100644 (file)
@@ -2,6 +2,7 @@ Description:
 Access to multithreading primitives.
 
 Files:
+lib/glthread/threadlib.c
 m4/threadlib.m4
 build-aux/config.rpath
 
@@ -15,6 +16,7 @@ configure.ac:
 gl_THREADLIB
 
 Makefile.am:
+lib_SOURCES += glthread/threadlib.c
 
 Include: