GNU Pth saw its last release in 2006. I don't think it will be revived, nor will it have real use any more, because new operating systems come with <pthread.h> already implemented. (For example, this was the case with Haiku and is the case with Fuchsia OS.)
The option --enable-threads=pth and <threads.h>/<pthread.h> are incompatible, because Pth is based on cooperative multithreading, i.e. every thread has to call yield() every now and then, to give the other threads a chance to become active. I'm starting to implement the functionality of module 'lock' in a module 'pthread-mutex', and will then use this module in many places. So, more and more code of gnulib will become incompatible with --enable-threads=pth. For this reason, the option --enable-threads=pth has no future. I'm removing it right away. 2019-07-05 Bruno Haible <br...@clisp.org> thread, lock, cond, tls: Remove support for Pth threads. * m4/threadlib.m4 (gl_THREADLIB_EARLY_BODY): Don't document --enable-threads=pth any more. (gl_THREADLIB_BODY): Don't set USE_PTH_THREADS any more. * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Update comment. * m4/threads.m4 (gl_THREADS_H): Remove test for conflict between Pth threads and ISO C11 threads. * lib/glthread/thread.h: Remove code for USE_PTH_THREADS. * lib/glthread/lock.h: Likewise. * lib/glthread/lock.c: Likewise. * lib/glthread/cond.h: Likewise. * lib/glthread/cond.c: Likewise. * lib/glthread/tls.h: Likewise. * lib/glthread/tls.c: Likewise. * lib/glthread/yield.h: Likewise. * lib/regex_internal.h: Likewise. * tests/test-thread_create.c: Likewise. * tests/test-lock.c: Likewise. * tests/test-cond.c: Likewise. * tests/test-tls.c: Likewise. * tests/test-rwlock1.c: Don't include glthread/yield.h. (main): Sleep without calling gl_thread_yield. diff --git a/lib/glthread/cond.c b/lib/glthread/cond.c index 72aeca4..f6a06cc 100644 --- a/lib/glthread/cond.c +++ b/lib/glthread/cond.c @@ -24,34 +24,6 @@ /* ========================================================================= */ -#if USE_PTH_THREADS - -/* -------------------------- gl_cond_t datatype -------------------------- */ - -int -glthread_cond_timedwait_multithreaded (gl_cond_t *cond, - gl_lock_t *lock, - struct timespec *abstime) -{ - int ret, status; - pth_event_t ev; - - ev = pth_event (PTH_EVENT_TIME, pth_time (abstime->tv_sec, abstime->tv_nsec / 1000)); - ret = pth_cond_await (cond, lock, ev); - - status = pth_event_status (ev); - pth_event_free (ev, PTH_FREE_THIS); - - if (status == PTH_STATUS_OCCURRED) - return ETIMEDOUT; - - return ret; -} - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS #endif diff --git a/lib/glthread/cond.h b/lib/glthread/cond.h index b03ffe3..4c6f4d9 100644 --- a/lib/glthread/cond.h +++ b/lib/glthread/cond.h @@ -56,7 +56,7 @@ #include "glthread/lock.h" #if !defined c11_threads_in_use -# if HAVE_THREADS_H && (USE_POSIX_THREADS_WEAK || USE_PTH_THREADS_WEAK) +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK # include <threads.h> # pragma weak thrd_exit # define c11_threads_in_use() (thrd_exit != NULL) @@ -168,65 +168,6 @@ typedef pthread_cond_t gl_cond_t; /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_cond_init -# pragma weak pth_cond_await -# pragma weak pth_cond_notify -# pragma weak pth_event -# pragma weak pth_timeout - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL || c11_threads_in_use ()) - -# else - -# define pth_in_use() 1 - -# endif - -/* -------------------------- gl_cond_t datatype -------------------------- */ - -typedef pth_cond_t gl_cond_t; -# define gl_cond_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_cond_t NAME; -# define gl_cond_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_cond_t NAME = gl_cond_initializer; -# define gl_cond_initializer \ - PTH_COND_INIT -# define glthread_cond_init(COND) \ - (pth_in_use () && !pth_cond_init (COND) ? errno : 0) -# define glthread_cond_wait(COND, LOCK) \ - (pth_in_use () && !pth_cond_await (COND, LOCK, NULL) ? errno : 0) -# define glthread_cond_timedwait(COND, LOCK, ABSTIME) \ - (pth_in_use () ? glthread_cond_timedwait_multithreaded (COND, LOCK, ABSTIME) : 0) -# define glthread_cond_signal(COND) \ - (pth_in_use () && !pth_cond_notify (COND, FALSE) ? errno : 0) -# define glthread_cond_broadcast(COND) \ - (pth_in_use () && !pth_cond_notify (COND, TRUE) ? errno : 0) -# define glthread_cond_destroy(COND) 0 -extern int glthread_cond_timedwait_multithreaded (gl_cond_t *cond, gl_lock_t *lock, struct timespec *abstime); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ @@ -273,7 +214,7 @@ typedef glwthread_cond_t gl_cond_t; /* ========================================================================= */ -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS) +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ diff --git a/lib/glthread/lock.c b/lib/glthread/lock.c index e7fa3f8..89f1f50 100644 --- a/lib/glthread/lock.c +++ b/lib/glthread/lock.c @@ -499,186 +499,6 @@ glthread_once_singlethreaded (pthread_once_t *once_control) /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -# if !HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER - -int -glthread_rwlock_init_multithreaded (gl_rwlock_t *lock) -{ - if (!pth_mutex_init (&lock->lock)) - return errno; - if (!pth_cond_init (&lock->waiting_readers)) - return errno; - if (!pth_cond_init (&lock->waiting_writers)) - return errno; - lock->waiting_writers_count = 0; - lock->runcount = 0; - lock->initialized = 1; - return 0; -} - -int -glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - glthread_rwlock_init_multithreaded (lock); - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - /* Test whether only readers are currently running, and whether the runcount - field will not overflow, and whether no writer is waiting. The latter - condition is because POSIX recommends that "write locks shall take - precedence over read locks", to avoid "writer starvation". */ - while (!(lock->runcount + 1 > 0 && lock->waiting_writers_count == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_readers. */ - if (!pth_cond_await (&lock->waiting_readers, &lock->lock, NULL)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - lock->runcount++; - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock) -{ - if (!lock->initialized) - glthread_rwlock_init_multithreaded (lock); - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - /* Test whether no readers or writers are currently running. */ - while (!(lock->runcount == 0)) - { - /* This thread has to wait for a while. Enqueue it among the - waiting_writers. */ - lock->waiting_writers_count++; - if (!pth_cond_await (&lock->waiting_writers, &lock->lock, NULL)) - { - int err = errno; - lock->waiting_writers_count--; - pth_mutex_release (&lock->lock); - return err; - } - lock->waiting_writers_count--; - } - lock->runcount--; /* runcount becomes -1 */ - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock) -{ - int err; - - if (!lock->initialized) - return EINVAL; - if (!pth_mutex_acquire (&lock->lock, 0, NULL)) - return errno; - if (lock->runcount < 0) - { - /* Drop a writer lock. */ - if (!(lock->runcount == -1)) - { - pth_mutex_release (&lock->lock); - return EINVAL; - } - lock->runcount = 0; - } - else - { - /* Drop a reader lock. */ - if (!(lock->runcount > 0)) - { - pth_mutex_release (&lock->lock); - return EINVAL; - } - lock->runcount--; - } - if (lock->runcount == 0) - { - /* POSIX recommends that "write locks shall take precedence over read - locks", to avoid "writer starvation". */ - if (lock->waiting_writers_count > 0) - { - /* Wake up one of the waiting writers. */ - if (!pth_cond_notify (&lock->waiting_writers, FALSE)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - else - { - /* Wake up all waiting readers. */ - if (!pth_cond_notify (&lock->waiting_readers, TRUE)) - { - int err = errno; - pth_mutex_release (&lock->lock); - return err; - } - } - } - return (!pth_mutex_release (&lock->lock) ? errno : 0); -} - -int -glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock) -{ - lock->initialized = 0; - return 0; -} - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* -------------------------- gl_once_t datatype -------------------------- */ - -static void -glthread_once_call (void *arg) -{ - void (**gl_once_temp_addr) (void) = (void (**) (void)) arg; - void (*initfunction) (void) = *gl_once_temp_addr; - initfunction (); -} - -int -glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)) -{ - void (*temp) (void) = initfunction; - return (!pth_once (once_control, glthread_once_call, &temp) ? errno : 0); -} - -int -glthread_once_singlethreaded (pth_once_t *once_control) -{ - /* We know that pth_once_t is an integer type. */ - if (*once_control == PTH_ONCE_INIT) - { - /* First time use of once_control. Invert the marker. */ - *once_control = ~ PTH_ONCE_INIT; - return 1; - } - else - return 0; -} - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS /* ------------------------- gl_rwlock_t datatype ------------------------- */ diff --git a/lib/glthread/lock.h b/lib/glthread/lock.h index 2db8b7e..bc3a4de 100644 --- a/lib/glthread/lock.h +++ b/lib/glthread/lock.h @@ -81,7 +81,7 @@ #include <stdlib.h> #if !defined c11_threads_in_use -# if HAVE_THREADS_H && (USE_POSIX_THREADS_WEAK || USE_PTH_THREADS_WEAK) +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK # include <threads.h> # pragma weak thrd_exit # define c11_threads_in_use() (thrd_exit != NULL) @@ -405,156 +405,6 @@ extern int glthread_once_singlethreaded (pthread_once_t *once_control); /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_mutex_init -# pragma weak pth_mutex_acquire -# pragma weak pth_mutex_release -# pragma weak pth_rwlock_init -# pragma weak pth_rwlock_acquire -# pragma weak pth_rwlock_release -# pragma weak pth_once -# pragma weak pth_cond_init -# pragma weak pth_cond_await -# pragma weak pth_cond_notify - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL || c11_threads_in_use ()) - -# else - -# define pth_in_use() 1 - -# endif - -/* -------------------------- gl_lock_t datatype -------------------------- */ - -typedef pth_mutex_t gl_lock_t; -# define gl_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_lock_initializer; -# define gl_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* ------------------------- gl_rwlock_t datatype ------------------------- */ - -/* Pth pth_rwlock_acquire always prefers readers. No autoconf test so far. */ -# if HAVE_PTH_RWLOCK_ACQUIRE_PREFER_WRITER - -typedef pth_rwlock_t gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - PTH_RWLOCK_INIT -# define glthread_rwlock_init(LOCK) \ - (pth_in_use () && !pth_rwlock_init (LOCK) ? errno : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RD, 0, NULL) ? errno : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pth_in_use () && !pth_rwlock_acquire (LOCK, PTH_RWLOCK_RW, 0, NULL) ? errno : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pth_in_use () && !pth_rwlock_release (LOCK) ? errno : 0) -# define glthread_rwlock_destroy(LOCK) \ - ((void)(LOCK), 0) - -# else - -typedef struct - { - int initialized; - pth_mutex_t lock; /* protects the remaining fields */ - pth_cond_t waiting_readers; /* waiting readers */ - pth_cond_t waiting_writers; /* waiting writers */ - unsigned int waiting_writers_count; /* number of waiting writers */ - int runcount; /* number of readers running, or -1 when a writer runs */ - } - gl_rwlock_t; -# define gl_rwlock_define(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME; -# define gl_rwlock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS gl_rwlock_t NAME = gl_rwlock_initializer; -# define gl_rwlock_initializer \ - { 0 } -# define glthread_rwlock_init(LOCK) \ - (pth_in_use () ? glthread_rwlock_init_multithreaded (LOCK) : 0) -# define glthread_rwlock_rdlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_rdlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_wrlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_wrlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_unlock(LOCK) \ - (pth_in_use () ? glthread_rwlock_unlock_multithreaded (LOCK) : 0) -# define glthread_rwlock_destroy(LOCK) \ - (pth_in_use () ? glthread_rwlock_destroy_multithreaded (LOCK) : 0) -extern int glthread_rwlock_init_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_rdlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_wrlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_unlock_multithreaded (gl_rwlock_t *lock); -extern int glthread_rwlock_destroy_multithreaded (gl_rwlock_t *lock); - -# endif - -/* --------------------- gl_recursive_lock_t datatype --------------------- */ - -/* In Pth, mutexes are recursive by default. */ -typedef pth_mutex_t gl_recursive_lock_t; -# define gl_recursive_lock_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME; -# define gl_recursive_lock_define_initialized(STORAGECLASS, NAME) \ - STORAGECLASS pth_mutex_t NAME = gl_recursive_lock_initializer; -# define gl_recursive_lock_initializer \ - PTH_MUTEX_INIT -# define glthread_recursive_lock_init(LOCK) \ - (pth_in_use () && !pth_mutex_init (LOCK) ? errno : 0) -# define glthread_recursive_lock_lock(LOCK) \ - (pth_in_use () && !pth_mutex_acquire (LOCK, 0, NULL) ? errno : 0) -# define glthread_recursive_lock_unlock(LOCK) \ - (pth_in_use () && !pth_mutex_release (LOCK) ? errno : 0) -# define glthread_recursive_lock_destroy(LOCK) \ - ((void)(LOCK), 0) - -/* -------------------------- gl_once_t datatype -------------------------- */ - -typedef pth_once_t gl_once_t; -# define gl_once_define(STORAGECLASS, NAME) \ - STORAGECLASS pth_once_t NAME = PTH_ONCE_INIT; -# define glthread_once(ONCE_CONTROL, INITFUNCTION) \ - (pth_in_use () \ - ? glthread_once_multithreaded (ONCE_CONTROL, INITFUNCTION) \ - : (glthread_once_singlethreaded (ONCE_CONTROL) ? (INITFUNCTION (), 0) : 0)) -extern int glthread_once_multithreaded (pth_once_t *once_control, void (*initfunction) (void)); -extern int glthread_once_singlethreaded (pth_once_t *once_control); - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ @@ -677,7 +527,7 @@ typedef glwthread_once_t gl_once_t; /* ========================================================================= */ -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS) +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ diff --git a/lib/glthread/thread.h b/lib/glthread/thread.h index eed2eb6..eef9a46 100644 --- a/lib/glthread/thread.h +++ b/lib/glthread/thread.h @@ -74,7 +74,7 @@ #include <stdlib.h> #if !defined c11_threads_in_use -# if HAVE_THREADS_H && (USE_POSIX_THREADS_WEAK || USE_PTH_THREADS_WEAK) +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK # include <threads.h> # pragma weak thrd_exit # define c11_threads_in_use() (thrd_exit != NULL) @@ -222,60 +222,6 @@ extern const gl_thread_t gl_null_thread; /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_init -# pragma weak pth_spawn -# pragma weak pth_sigmask -# pragma weak pth_join -# pragma weak pth_self -# pragma weak pth_exit - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL || c11_threads_in_use ()) - -# else - -# define pth_in_use() 1 - -# endif -/* -------------------------- gl_thread_t datatype -------------------------- */ - -typedef pth_t gl_thread_t; -# define glthread_create(THREADP, FUNC, ARG) \ - (pth_in_use () ? (pth_init (), ((*(THREADP) = pth_spawn (NULL, FUNC, ARG)) ? 0 : errno)) : 0) -# define glthread_sigmask(HOW, SET, OSET) \ - (pth_in_use () ? (pth_init (), (pth_sigmask (HOW, SET, OSET) ? 0 : errno)) : 0) -# define glthread_join(THREAD, RETVALP) \ - (pth_in_use () ? (pth_init (), (pth_join (THREAD, RETVALP) ? 0 : errno)) : 0) -# define gl_thread_self() \ - (pth_in_use () ? (pth_init (), (void *) pth_self ()) : NULL) -# define gl_thread_self_pointer() \ - gl_thread_self () -# define gl_thread_exit(RETVAL) \ - (pth_in_use () ? (pth_init (), pth_exit (RETVAL)) : 0) -# define glthread_atfork(PREPARE_FUNC, PARENT_FUNC, CHILD_FUNC) 0 - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ @@ -312,7 +258,7 @@ typedef glwthread_thread_t gl_thread_t; /* ========================================================================= */ -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS) +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ diff --git a/lib/glthread/tls.c b/lib/glthread/tls.c index cc6d4e1..d182266 100644 --- a/lib/glthread/tls.c +++ b/lib/glthread/tls.c @@ -28,12 +28,6 @@ /* ========================================================================= */ -#if USE_PTH_THREADS - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS #endif diff --git a/lib/glthread/tls.h b/lib/glthread/tls.h index a86dcd4..cfc9606 100644 --- a/lib/glthread/tls.h +++ b/lib/glthread/tls.h @@ -47,7 +47,7 @@ #include <stdlib.h> #if !defined c11_threads_in_use -# if HAVE_THREADS_H && (USE_POSIX_THREADS_WEAK || USE_PTH_THREADS_WEAK) +# if HAVE_THREADS_H && USE_POSIX_THREADS_WEAK # include <threads.h> # pragma weak thrd_exit # define c11_threads_in_use() (thrd_exit != NULL) @@ -126,59 +126,6 @@ typedef union /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# if USE_PTH_THREADS_WEAK - -/* Use weak references to the GNU Pth threads library. */ - -# pragma weak pth_key_create -# pragma weak pth_key_getdata -# pragma weak pth_key_setdata -# pragma weak pth_key_delete - -# pragma weak pth_cancel -# define pth_in_use() (pth_cancel != NULL || c11_threads_in_use ()) - -# else - -# define pth_in_use() 1 - -# endif - -/* ------------------------- gl_tls_key_t datatype ------------------------- */ - -typedef union - { - void *singlethread_value; - pth_key_t key; - } - gl_tls_key_t; -# define glthread_tls_key_init(KEY, DESTRUCTOR) \ - (pth_in_use () \ - ? (!pth_key_create (&(KEY)->key, DESTRUCTOR) ? errno : 0) \ - : ((KEY)->singlethread_value = NULL, 0)) -# define gl_tls_get(NAME) \ - (pth_in_use () \ - ? pth_key_getdata ((NAME).key) \ - : (NAME).singlethread_value) -# define glthread_tls_set(KEY, POINTER) \ - (pth_in_use () \ - ? (!pth_key_setdata ((KEY)->key, (POINTER)) ? errno : 0) \ - : ((KEY)->singlethread_value = (POINTER), 0)) -# define glthread_tls_key_destroy(KEY) \ - (pth_in_use () \ - ? (!pth_key_delete ((KEY)->key) ? errno : 0) \ - : 0) - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ @@ -202,7 +149,7 @@ typedef glwthread_tls_key_t gl_tls_key_t; /* ========================================================================= */ -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS) +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ diff --git a/lib/glthread/yield.h b/lib/glthread/yield.h index 3a2877b..27bca55 100644 --- a/lib/glthread/yield.h +++ b/lib/glthread/yield.h @@ -46,27 +46,6 @@ extern "C" { /* ========================================================================= */ -#if USE_PTH_THREADS - -/* Use the GNU Pth threads library. */ - -# include <pth.h> - -# ifdef __cplusplus -extern "C" { -# endif - -# define gl_thread_yield() \ - pth_yield (NULL) - -# ifdef __cplusplus -} -# endif - -#endif - -/* ========================================================================= */ - #if USE_WINDOWS_THREADS # define WIN32_LEAN_AND_MEAN /* avoid including junk */ @@ -87,7 +66,7 @@ extern "C" { /* ========================================================================= */ -#if !(USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS) +#if !(USE_POSIX_THREADS || USE_WINDOWS_THREADS) /* Provide dummy implementation if threads are not supported. */ diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 16e18ca..ec4bf30 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -51,8 +51,6 @@ # define lock_define(name) gl_lock_define (, name) # elif USE_POSIX_THREADS # define lock_define(name) pthread_mutex_t name; -# elif USE_PTH_THREADS -# define lock_define(name) pth_mutex_t name; # elif USE_WINDOWS_THREADS # define lock_define(name) gl_lock_t name; # else diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index 648edf9..d788cf6 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -1,4 +1,4 @@ -# pthread_sigmask.m4 serial 17 +# pthread_sigmask.m4 serial 18 dnl Copyright (C) 2011-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, @@ -75,10 +75,6 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], else dnl pthread_sigmask may exist but does not interoperate with the chosen dnl multithreading facility. - dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask, - dnl but it is equivalent to sigprocmask, so we choose to emulate - dnl pthread_sigmask with sigprocmask also in this case. This yields - dnl fewer link dependencies. if test $ac_cv_func_pthread_sigmask = yes; then REPLACE_PTHREAD_SIGMASK=1 else diff --git a/m4/threadlib.m4 b/m4/threadlib.m4 index 74b95b6..045d9da 100644 --- a/m4/threadlib.m4 +++ b/m4/threadlib.m4 @@ -1,4 +1,4 @@ -# threadlib.m4 serial 19 +# threadlib.m4 serial 20 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,8 +16,7 @@ dnl (it must be placed before the invocation of gl_THREADLIB_EARLY!), then the dnl default is 'no', otherwise it is system dependent. In both cases, the user dnl can change the choice through the options --enable-threads=choice or dnl --disable-threads. -dnl Defines at most one of the macros USE_POSIX_THREADS, USE_PTH_THREADS, -dnl USE_WINDOWS_THREADS. +dnl Defines at most one of the macros USE_POSIX_THREADS, USE_WINDOWS_THREADS. dnl Sets the variables LIBTHREAD and LTLIBTHREAD to the linker options for use dnl in a Makefile (LIBTHREAD for use without libtool, LTLIBTHREAD for use with dnl libtool). @@ -27,6 +26,9 @@ dnl between LIBTHREAD and LIBMULTITHREAD is that on platforms supporting weak dnl symbols, typically LIBTHREAD is empty whereas LIBMULTITHREAD is not. dnl Adds to CPPFLAGS the flag -D_REENTRANT or -D_THREAD_SAFE if needed for dnl multithread-safe programs. +dnl Since support for GNU pth was removed, $LTLIBTHREAD and $LIBTHREAD have the +dnl same value, and similarly $LTLIBMULTITHREAD and $LIBMULTITHREAD have the +dnl same value. Only system libraries are needed. AC_DEFUN([gl_THREADLIB_EARLY], [ @@ -52,7 +54,7 @@ AC_DEFUN([gl_THREADLIB_EARLY_BODY], [m4_divert_text([DEFAULTS], [gl_use_threads_default=])]) m4_divert_text([DEFAULTS], [gl_use_winpthreads_default=]) AC_ARG_ENABLE([threads], -AC_HELP_STRING([--enable-threads={posix|pth|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ +AC_HELP_STRING([--enable-threads={posix|windows}], [specify multithreading API])m4_ifdef([gl_THREADLIB_DEFAULT_NO], [], [ AC_HELP_STRING([--disable-threads], [build without multithread safety])]), [gl_use_threads=$enableval], [if test -n "$gl_use_threads_default"; then @@ -250,36 +252,6 @@ int main () fi fi fi - if test "$gl_use_threads" = pth; then - gl_save_CPPFLAGS="$CPPFLAGS" - AC_LIB_LINKFLAGS([pth]) - gl_have_pth= - gl_save_LIBS="$LIBS" - LIBS="$LIBS $LIBPTH" - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[#include <pth.h>]], [[pth_self();]])], - [gl_have_pth=yes]) - LIBS="$gl_save_LIBS" - if test -n "$gl_have_pth"; then - gl_threads_api=pth - LIBTHREAD="$LIBPTH" - LTLIBTHREAD="$LTLIBPTH" - LIBMULTITHREAD="$LIBTHREAD" - LTLIBMULTITHREAD="$LTLIBTHREAD" - AC_DEFINE([USE_PTH_THREADS], [1], - [Define if the GNU Pth multithreading library can be used.]) - if test -n "$LIBMULTITHREAD" || test -n "$LTLIBMULTITHREAD"; then - if case "$gl_cv_have_weak" in *yes) true;; *) false;; esac; then - AC_DEFINE([USE_PTH_THREADS_WEAK], [1], - [Define if references to the GNU Pth multithreading library should be made weak.]) - LIBTHREAD= - LTLIBTHREAD= - fi - fi - else - CPPFLAGS="$gl_save_CPPFLAGS" - fi - fi if test -z "$gl_have_pthread"; then case "$gl_use_threads" in yes | windows | win32) # The 'win32' is for backward compatibility. @@ -376,8 +348,6 @@ dnl -lpthread (gcc) Y dnl dnl Cygwin posix -lpthread Y OK dnl -dnl Any of the above pth -lpth 0.0 -dnl dnl Mingw windows N OK dnl dnl BeOS 5 -- diff --git a/m4/threads.m4 b/m4/threads.m4 index 1aebb0a..f5f587c 100644 --- a/m4/threads.m4 +++ b/m4/threads.m4 @@ -1,4 +1,4 @@ -# threads.m4 serial 4 +# threads.m4 serial 5 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, @@ -16,12 +16,6 @@ AC_DEFUN([gl_THREADS_H], AC_REQUIRE([gl_THREADLIB_BODY]) AC_REQUIRE([gl_YIELD]) - if test "$gl_use_threads" = pth; then - AC_MSG_ERROR([You cannot use --enable-threads=pth with the gnulib module 'threads-h'.]) - fi - dnl Now, since $gl_use_threads is not 'pth', $LTLIBMULTITHREAD and - dnl $LIBMULTITHREAD have the same value. Only system libraries are needed. - gl_CHECK_NEXT_HEADERS([threads.h]) if test $ac_cv_header_threads_h = yes; then HAVE_THREADS_H=1 diff --git a/tests/test-cond.c b/tests/test-cond.c index d8f76c6..e8bd472 100644 --- a/tests/test-cond.c +++ b/tests/test-cond.c @@ -16,7 +16,7 @@ #include <config.h> -#if USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS +#if USE_POSIX_THREADS || USE_WINDOWS_THREADS /* Which tests to perform. Uncomment some of these, to verify that all tests crash if no locking @@ -173,11 +173,6 @@ test_timedcond (void) int main () { -#if TEST_PTH_THREADS - if (!pth_init ()) - abort (); -#endif - #if DO_TEST_COND printf ("Starting test_cond ..."); fflush (stdout); test_cond (); diff --git a/tests/test-lock.c b/tests/test-lock.c index e3b4ce9..844e5d5 100644 --- a/tests/test-lock.c +++ b/tests/test-lock.c @@ -18,14 +18,11 @@ #include <config.h> -#if USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS +#if USE_POSIX_THREADS || USE_WINDOWS_THREADS #if USE_POSIX_THREADS # define TEST_POSIX_THREADS 1 #endif -#if USE_PTH_THREADS -# define TEST_PTH_THREADS 1 -#endif #if USE_WINDOWS_THREADS # define TEST_WINDOWS_THREADS 1 #endif @@ -87,7 +84,6 @@ #if !ENABLE_LOCKING # undef USE_POSIX_THREADS -# undef USE_PTH_THREADS # undef USE_WINDOWS_THREADS #endif #include "glthread/lock.h" @@ -96,9 +92,6 @@ # if TEST_POSIX_THREADS # define USE_POSIX_THREADS 1 # endif -# if TEST_PTH_THREADS -# define USE_PTH_THREADS 1 -# endif # if TEST_WINDOWS_THREADS # define USE_WINDOWS_THREADS 1 # endif @@ -723,11 +716,6 @@ main () alarm (alarm_value); #endif -#if TEST_PTH_THREADS - if (!pth_init ()) - abort (); -#endif - #if DO_TEST_LOCK printf ("Starting test_lock ..."); fflush (stdout); test_lock (); diff --git a/tests/test-rwlock1.c b/tests/test-rwlock1.c index 7180436..fbb54aa 100644 --- a/tests/test-rwlock1.c +++ b/tests/test-rwlock1.c @@ -29,7 +29,6 @@ #include <unistd.h> #include "glthread/thread.h" -#include "glthread/yield.h" /* Verify that in a situation where - an rwlock is taken by a reader and has a writer waiting, @@ -149,9 +148,6 @@ main () /* Job done. Go to sleep. */ for (;;) { - /* In cooperative threads implementations (Pth), give other threads - a chance to run. */ - gl_thread_yield (); sleep (1); } } diff --git a/tests/test-thread_create.c b/tests/test-thread_create.c index fbfc561..0465b2b 100644 --- a/tests/test-thread_create.c +++ b/tests/test-thread_create.c @@ -67,7 +67,7 @@ main () } else { -#if USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS +#if USE_POSIX_THREADS || USE_WINDOWS_THREADS fputs ("glthread_create failed\n", stderr); return 1; #else diff --git a/tests/test-tls.c b/tests/test-tls.c index 302ca18..9babfe6 100644 --- a/tests/test-tls.c +++ b/tests/test-tls.c @@ -18,14 +18,11 @@ #include <config.h> -#if USE_POSIX_THREADS || USE_PTH_THREADS || USE_WINDOWS_THREADS +#if USE_POSIX_THREADS || USE_WINDOWS_THREADS #if USE_POSIX_THREADS # define TEST_POSIX_THREADS 1 #endif -#if USE_PTH_THREADS -# define TEST_PTH_THREADS 1 -#endif #if USE_WINDOWS_THREADS # define TEST_WINDOWS_THREADS 1 #endif @@ -67,8 +64,7 @@ static void perhaps_yield (void) { - /* Call yield () only with a certain probability, otherwise with GNU Pth - the sequence of thread activations is too predictable. */ + /* This helps making the sequence of thread activations less predictable. */ if ((((unsigned int) rand () >> 3) % 4) == 0) yield (); } @@ -497,11 +493,6 @@ main () alarm (alarm_value); #endif -#if TEST_PTH_THREADS - if (!pth_init ()) - abort (); -#endif - printf ("Starting test_tls ..."); fflush (stdout); test_tls (); printf (" OK\n"); fflush (stdout);