summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--m4/sched_yield.m45
-rw-r--r--m4/threadlib.m419
-rw-r--r--m4/threads.m45
-rw-r--r--m4/yield.m413
-rw-r--r--modules/pthread-cond-tests2
-rw-r--r--modules/pthread-mutex-tests2
-rw-r--r--modules/pthread-once-tests2
-rw-r--r--modules/pthread-rwlock-tests2
-rw-r--r--modules/pthread-tss-tests2
-rw-r--r--modules/sched_yield5
-rw-r--r--modules/threads-h1
12 files changed, 59 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index da863d8594..9d3018279b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,29 @@
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.
* modules/threads-h (configure.ac-early): Invoke gl_ANYTHREADLIB_EARLY,
not gl_THREADLIB_EARLY.
diff --git a/m4/sched_yield.m4 b/m4/sched_yield.m4
index a65b7e8795..cfecfc75c0 100644
--- a/m4/sched_yield.m4
+++ b/m4/sched_yield.m4
@@ -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
diff --git a/m4/threadlib.m4 b/m4/threadlib.m4
index 96c74c18b3..bf9d4e6114 100644
--- a/m4/threadlib.m4
+++ b/m4/threadlib.m4
@@ -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
])
diff --git a/m4/threads.m4 b/m4/threads.m4
index c8f74a1d57..f98c594977 100644
--- a/m4/threads.m4
+++ b/m4/threads.m4
@@ -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
diff --git a/m4/yield.m4 b/m4/yield.m4
index 59c8c38eb4..9029ebe682 100644
--- a/m4/yield.m4
+++ b/m4/yield.m4
@@ -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])
])
diff --git a/modules/pthread-cond-tests b/modules/pthread-cond-tests
index 041047ee2d..75a335d565 100644
--- a/modules/pthread-cond-tests
+++ b/modules/pthread-cond-tests
@@ -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@
diff --git a/modules/pthread-mutex-tests b/modules/pthread-mutex-tests
index 9d9861f09f..eb6ec7bea8 100644
--- a/modules/pthread-mutex-tests
+++ b/modules/pthread-mutex-tests
@@ -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@
diff --git a/modules/pthread-once-tests b/modules/pthread-once-tests
index 17b25b6d33..d77dc19a5a 100644
--- a/modules/pthread-once-tests
+++ b/modules/pthread-once-tests
@@ -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@
diff --git a/modules/pthread-rwlock-tests b/modules/pthread-rwlock-tests
index a8d51ee972..7f35198e87 100644
--- a/modules/pthread-rwlock-tests
+++ b/modules/pthread-rwlock-tests
@@ -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@
diff --git a/modules/pthread-tss-tests b/modules/pthread-tss-tests
index 3a33e563f0..caa4520e52 100644
--- a/modules/pthread-tss-tests
+++ b/modules/pthread-tss-tests
@@ -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@
diff --git a/modules/sched_yield b/modules/sched_yield
index 3a2ae01504..69aa94c53a 100644
--- a/modules/sched_yield
+++ b/modules/sched_yield
@@ -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+
diff --git a/modules/threads-h b/modules/threads-h
index b9f4561a10..927a057967 100644
--- a/modules/threads-h
+++ b/modules/threads-h
@@ -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: