]> Savannah Git Hosting - gnulib.git/commitdiff
sched_yield: Don't depend on threadlib and yield.
authorBruno Haible <bruno@clisp.org>
Sat, 21 Dec 2019 12:36:03 +0000 (13:36 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 21 Dec 2019 12:43:31 +0000 (13:43 +0100)
* m4/threadlib.m4 (gl_PTHREADLIB): Document that it sets
LIB_SCHED_YIELD.
(gl_PTHREADLIB_BODY): Set LIB_SCHED_YIELD (code moved here from
m4/yield.m4).
* m4/sched_yield.m4 (gl_FUNC_SCHED_YIELD): Require gl_PTHREADLIB, not
gl_THREADLIB and gl_YIELD.
* m4/yield.m4 (gl_YIELD): Require gl_PTHREADLIB. Determine YIELD_LIB
based on $(LIB_SCHED_YIELD).
* m4/threads.m4 (gl_THREADS_H): Don't require gl_YIELD. Use
$(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/sched_yield (Files): Remove yield.m4. Add threadlib.m4.
(Depends-on): Remove threadlib.
(Link): Mention $(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/threads-h (Files): Remove m4/yield.m4.
* modules/pthread-cond-tests (Makefile.am): Link the programs against
$(LIB_SCHED_YIELD), not $(YIELD_LIB).
* modules/pthread-mutex-tests (Makefile.am): Likewise.
* modules/pthread-once-tests (Makefile.am): Likewise.
* modules/pthread-rwlock-tests (Makefile.am): Likewise.
* modules/pthread-tss-tests (Makefile.am): Likewise.

12 files changed:
ChangeLog
m4/sched_yield.m4
m4/threadlib.m4
m4/threads.m4
m4/yield.m4
modules/pthread-cond-tests
modules/pthread-mutex-tests
modules/pthread-once-tests
modules/pthread-rwlock-tests
modules/pthread-tss-tests
modules/sched_yield
modules/threads-h

index da863d8594ee4c71415360e6af2c6bcb6ee18910..9d3018279be93a1fd33c226f1b235b8ca2c8dca5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2019-12-21  Bruno Haible  <bruno@clisp.org>
+
+       sched_yield: Don't depend on threadlib and yield.
+       * m4/threadlib.m4 (gl_PTHREADLIB): Document that it sets
+       LIB_SCHED_YIELD.
+       (gl_PTHREADLIB_BODY): Set LIB_SCHED_YIELD (code moved here from
+       m4/yield.m4).
+       * m4/sched_yield.m4 (gl_FUNC_SCHED_YIELD): Require gl_PTHREADLIB, not
+       gl_THREADLIB and gl_YIELD.
+       * m4/yield.m4 (gl_YIELD): Require gl_PTHREADLIB. Determine YIELD_LIB
+       based on $(LIB_SCHED_YIELD).
+       * m4/threads.m4 (gl_THREADS_H): Don't require gl_YIELD. Use
+       $(LIB_SCHED_YIELD), not $(YIELD_LIB).
+       * modules/sched_yield (Files): Remove yield.m4. Add threadlib.m4.
+       (Depends-on): Remove threadlib.
+       (Link): Mention $(LIB_SCHED_YIELD), not $(YIELD_LIB).
+       * modules/threads-h (Files): Remove m4/yield.m4.
+       * modules/pthread-cond-tests (Makefile.am): Link the programs against
+       $(LIB_SCHED_YIELD), not $(YIELD_LIB).
+       * modules/pthread-mutex-tests (Makefile.am): Likewise.
+       * modules/pthread-once-tests (Makefile.am): Likewise.
+       * modules/pthread-rwlock-tests (Makefile.am): Likewise.
+       * modules/pthread-tss-tests (Makefile.am): Likewise.
+
 2019-12-21  Bruno Haible  <bruno@clisp.org>
 
        threads-h: Don't depend on threadlib.
index a65b7e87954f0f21dd4be7e0d357d6cb338be0fd..cfecfc75c04096831c9f6b138ce2028c4b76e1fc 100644 (file)
@@ -1,4 +1,4 @@
-# sched_yield.m4 serial 1
+# sched_yield.m4 serial 2
 dnl Copyright (C) 2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,9 +7,8 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_SCHED_YIELD],
 [
   AC_REQUIRE([gl_SCHED_H_DEFAULTS])
-  AC_REQUIRE([gl_THREADLIB])
+  AC_REQUIRE([gl_PTHREADLIB])
   AC_REQUIRE([AC_CANONICAL_HOST])
-  AC_REQUIRE([gl_YIELD])
 
   if { case "$host_os" in mingw*) true;; *) false;; esac; } \
      && test $gl_threads_api = windows; then
index 96c74c18b300c79de6608e52beaa52ca536e02bb..bf9d4e61146eb191a6e042c5f62bc45585cc22a0 100644 (file)
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 24
+# threadlib.m4 serial 25
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,6 +16,8 @@ dnl Sets the variable LIBPMULTITHREAD, for programs that really need
 dnl multithread functionality. The difference between LIBPTHREAD and
 dnl LIBPMULTITHREAD is that on platforms supporting weak symbols, typically
 dnl LIBPTHREAD is empty whereas LIBPMULTITHREAD is not.
+dnl Sets the variable LIB_SCHED_YIELD to the linker options needed to use the
+dnl sched_yield() function.
 dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for
 dnl multithread-safe programs.
 dnl Defines the C macro HAVE_PTHREAD_API if (at least parts of) the POSIX
@@ -277,6 +279,21 @@ AC_DEFUN([gl_PTHREADLIB_BODY],
       AC_DEFINE([HAVE_PTHREAD_API], [1],
         [Define if you have the <pthread.h> header and the POSIX threads API.])
     fi
+
+    dnl On some systems, sched_yield is in librt, rather than in libpthread.
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#include <sched.h>]],
+         [[sched_yield ();]])],
+      [LIB_SCHED_YIELD=
+      ],
+      [dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
+       AC_CHECK_LIB([rt], [sched_yield], [LIB_SCHED_YIELD=-lrt],
+         [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
+          AC_CHECK_LIB([posix4], [sched_yield], [LIB_SCHED_YIELD=-lposix4])])
+      ])
+    AC_SUBST([LIB_SCHED_YIELD])
+
     gl_threadlib_body_done=done
   fi
 ])
index c8f74a1d57dea611a9f9c26cbc3100bf75b6218a..f98c594977c6636d6cd13e103205187b3423f8e3 100644 (file)
@@ -1,4 +1,4 @@
-# threads.m4 serial 6
+# threads.m4 serial 7
 dnl Copyright (C) 2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,7 +14,6 @@ AC_DEFUN([gl_THREADS_H],
   AC_REQUIRE([gl_THREADS_H_DEFAULTS])
   AC_REQUIRE([AC_CANONICAL_HOST])
   AC_REQUIRE([gl_THREADLIB_BODY])
-  AC_REQUIRE([gl_YIELD])
 
   gl_CHECK_NEXT_HEADERS([threads.h])
   if test $ac_cv_header_threads_h = yes; then
@@ -72,7 +71,7 @@ AC_DEFUN([gl_THREADS_H],
         fi
       else
         dnl Libraries needed by thrd.c, mtx.c, cnd.c, tss.c.
-        LIBSTDTHREAD="$LIBMULTITHREAD $YIELD_LIB"
+        LIBSTDTHREAD="$LIBMULTITHREAD $LIB_SCHED_YIELD"
       fi
       ;;
   esac
index 59c8c38eb4f3a1433b6cf46931e2db1e5d1a4dbd..9029ebe68271eb8d3a275094bb102bfae0a9670b 100644 (file)
@@ -1,4 +1,4 @@
-# yield.m4 serial 3
+# yield.m4 serial 4
 dnl Copyright (C) 2005-2019 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,14 +6,13 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_YIELD],
 [
+  AC_REQUIRE([gl_PTHREADLIB])
   AC_REQUIRE([gl_THREADLIB])
-  dnl On some systems, sched_yield is in librt, rather than in libpthread.
-  YIELD_LIB=
+
   if test $gl_threads_api = posix; then
-    dnl Solaris 7...10 has sched_yield in librt, not in libpthread or libc.
-    AC_CHECK_LIB([rt], [sched_yield], [YIELD_LIB=-lrt],
-      [dnl Solaris 2.5.1, 2.6 has sched_yield in libposix4, not librt.
-       AC_CHECK_LIB([posix4], [sched_yield], [YIELD_LIB=-lposix4])])
+    YIELD_LIB="$LIB_SCHED_YIELD"
+  else
+    YIELD_LIB=
   fi
   AC_SUBST([YIELD_LIB])
 ])
index 041047ee2decf9dc89311eb2d79cd64d97367dd0..75a335d5657a71a1f6860941a17fc357b6e94993 100644 (file)
@@ -13,4 +13,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-pthread-cond
 check_PROGRAMS += test-pthread-cond
-test_pthread_cond_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
+test_pthread_cond_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@
index 9d9861f09f43142f956dccf843d7e9593145390d..eb6ec7bea86fc9e7a50eaa00e0a8ff3e555ed255 100644 (file)
@@ -11,4 +11,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-pthread-mutex
 check_PROGRAMS += test-pthread-mutex
-test_pthread_mutex_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
+test_pthread_mutex_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@
index 17b25b6d33628c81607806fd1d7f5379e3805e4f..d77dc19a5a9331fb6e30ba7ac0c3e058ddfb46e5 100644 (file)
@@ -14,4 +14,4 @@ Makefile.am:
 TESTS += test-pthread-once1 test-pthread-once2
 check_PROGRAMS += test-pthread-once1 test-pthread-once2
 test_pthread_once1_LDADD = $(LDADD) @LIBPMULTITHREAD@
-test_pthread_once2_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
+test_pthread_once2_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@
index a8d51ee972620ff513b8708e91863544d7c76e31..7f35198e8786861e554ed2f4391c063f9c3e13e5 100644 (file)
@@ -12,4 +12,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-pthread-rwlock
 check_PROGRAMS += test-pthread-rwlock
-test_pthread_rwlock_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
+test_pthread_rwlock_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@
index 3a33e563f0d8dbe9cf8f62b01751c5f570dea4ea..caa4520e52133d8e0c894513dfbfee51761807d2 100644 (file)
@@ -12,4 +12,4 @@ configure.ac:
 Makefile.am:
 TESTS += test-pthread-tss
 check_PROGRAMS += test-pthread-tss
-test_pthread_tss_LDADD = $(LDADD) @LIBPMULTITHREAD@ @YIELD_LIB@
+test_pthread_tss_LDADD = $(LDADD) @LIBPMULTITHREAD@ @LIB_SCHED_YIELD@
index 3a2ae0150483a3a6898191c6004b1a0edd3592e9..69aa94c53a0964c7ba856add5f5537f92b4001be 100644 (file)
@@ -4,11 +4,10 @@ Schedule other threads to run.
 Files:
 lib/sched_yield.c
 m4/sched_yield.m4
-m4/yield.m4
+m4/threadlib.m4
 
 Depends-on:
 sched
-threadlib
 
 configure.ac:
 gl_FUNC_SCHED_YIELD
@@ -23,7 +22,7 @@ Include:
 <sched.h>
 
 Link:
-$(YIELD_LIB)
+$(LIB_SCHED_YIELD)
 
 License:
 LGPLv2+
index b9f4561a105f90cf657be077525d4395e25b0eea..927a057967ad471fe3fd07b68cbe8c1c33479a23 100644 (file)
@@ -14,7 +14,6 @@ lib/windows-tls.h
 lib/windows-initguard.h
 m4/threads.m4
 m4/threadlib.m4
-m4/yield.m4
 build-aux/config.rpath
 
 Depends-on: