Commit 478535b0 authored by Bruno Haible's avatar Bruno Haible
Browse files

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.
parent 44524a48
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.
# 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
......
# 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
])
......
# 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
......
# 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])
])
......@@ -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@
......@@ -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@
......@@ -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@
......@@ -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@
......@@ -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@
......@@ -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+
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment