changeset 10322:794059e94b36

Move some code from module 'lock' to module 'threadlib'.
author Bruno Haible <bruno@clisp.org>
date Sun, 17 Aug 2008 16:26:05 +0200
parents a6493a165dd2
children 44cc53e4b3f9
files ChangeLog lib/glthread/lock.c lib/glthread/threadlib.c modules/threadlib
diffstat 4 files changed, 73 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Aug 16 13:47:58 2008 -0600
+++ b/ChangeLog	Sun Aug 17 16:26:05 2008 +0200
@@ -18,6 +18,10 @@
 
 	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
--- a/lib/glthread/lock.c	Sat Aug 16 13:47:58 2008 -0600
+++ b/lib/glthread/lock.c	Sun Aug 17 16:26:05 2008 +0200
@@ -27,45 +27,6 @@
 
 #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	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/glthread/threadlib.c	Sun Aug 17 16:26:05 2008 +0200
@@ -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
+
+/* ========================================================================= */
--- a/modules/threadlib	Sat Aug 16 13:47:58 2008 -0600
+++ b/modules/threadlib	Sun Aug 17 16:26:05 2008 +0200
@@ -2,6 +2,7 @@
 Access to multithreading primitives.
 
 Files:
+lib/glthread/threadlib.c
 m4/threadlib.m4
 build-aux/config.rpath
 
@@ -15,6 +16,7 @@
 gl_THREADLIB
 
 Makefile.am:
+lib_SOURCES += glthread/threadlib.c
 
 Include: