bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* pthread: new set of modules
@ 2019-07-15  1:05 Bruno Haible
  2019-07-25  1:23 ` Bruno Haible
  0 siblings, 1 reply; 2+ messages in thread
From: Bruno Haible @ 2019-07-15  1:05 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Michele Locati

[-- Attachment #1: Type: text/plain, Size: 17263 bytes --]

Hi,

I'm committing a set of gnulib modules that support the essential portion of
POSIX <pthread.h> and its functions.

* pthread-h: A POSIX-like <pthread.h>.
* pthread-thread: Creating and controlling POSIX threads.
* pthread-once: POSIX once-only control.
* pthread-mutex: POSIX mutexes (locks).
* pthread-rwlock: POSIX read-write locks.
* pthread-cond: POSIX condition variables.
* pthread-tss: POSIX thread-specific storage.
* pthread-spin: POSIX spin locks.
* pthread: Now merely a convenience wrapper for all of the above.

This has been tested on all customary platforms, from glibc systems up to
native Windows with MSVC, and Android.

Like for the older 'thread', 'lock', 'cond', 'tls' modules, on mingw systems
the installing user can choose among
  --enable-threads=posix       (which uses the mingw winpthreads library)
and
  --enable-threads=windows     (which uses native Windows code, like on MSVC).
The default currently is --enable-threads=posix.
The package developer can change the default by placing an invocation to
gl_AVOID_WINPTHREAD in the configure.ac file.
Why is this useful? Because the pthread-tss test hangs with
  --enable-threads=posix
but works fine with
  --enable-threads=windows

Here's the set of ChangeLog entries, in chronogical order:


2019-07-14  Bruno Haible  <bruno@clisp.org>

	threads-h: Fix generation of threads.h.
	* modules/threads-h (Makefile.am): Insert the required header file
	snippets.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	doc: Fix info about pthread API in HP-UX.
	* doc/posix-functions/pthread_*.texi: Fix info about HP-UX 11.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	windows-*: Rename glwthread_spinlock_t to glwthread_initguard_t.
	* lib/windows-initguard.h: Renamed from lib/windows-spinlock.h.
	(glwthread_initguard_t): Renamed from glwthread_spinlock_t.
	(GLWTHREAD_INITGUARD_INIT): Renamed from GLWTHREAD_SPINLOCK_INIT.
	* lib/windows-mutex.h: Update.
	* lib/windows-recmutex.h: Likewise.
	* lib/windows-timedmutex.h: Likewise.
	* lib/windows-timedrecmutex.h: Likewise.
	* lib/windows-cond.h: Likewise.
	* lib/glthread/lock.h: Likewise.
	* modules/windows-mutex (Files): Add lib/windows-initguard.h. Remove
	lib/windows-spinlock.h.
	* modules/windows-recmutex (Files): Likewise.
	* modules/windows-timedmutex (Files): Likewise.
	* modules/windows-timedrecmutex (Files): Likewise.
	* modules/windows-cond (Files): Likewise.
	* modules/threads-h (Files): Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	windows-thread: Add support for creating a thread in detached state.
	* lib/windows-thread.h (GLWTHREAD_ATTR_DETACHED): New macro.
	(glwthread_thread_create): Add attr argument.
	* lib/windows-thread.c (glwthread_thread_create): Likewise.
	* lib/glthread/thread.h (glthread_create): Update.
	* lib/thrd.c (thrd_create): Update.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	windows-rwlock: New module.
	* lib/windows-rwlock.h: New file, extracted from lib/glthread/lock.h.
	* lib/windows-rwlock.c: New file, extracted from lib/glthread/lock.c.
	* lib/glthread/lock.h: Include windows-rwlock.h. Don't include
	windows-initguard.h.
	(gl_rwlock_t): Define using glwthread_rwlock_t.
	(gl_rwlock_initializer): Define using GLWTHREAD_RWLOCK_INIT.
	(glthread_rwlock_init): Define using glwthread_rwlock_init.
	(glthread_rwlock_rdlock): Define using glwthread_rwlock_rdlock.
	(glthread_rwlock_wrlock): Define using glwthread_rwlock_wrlock.
	(glthread_rwlock_unlock): Define using glwthread_rwlock_unlock.
	(glthread_rwlock_destroy): Define using glwthread_rwlock_destroy.
	(glthread_rwlock_init_func, glthread_rwlock_rdlock_func,
	glthread_rwlock_wrlock_func, glthread_rwlock_unlock_func,
	glthread_rwlock_destroy_func): Remove declarations.
	* lib/glthread/lock.c (gl_waitqueue_t): Remove type.
	(gl_waitqueue_init, gl_waitqueue_add, gl_waitqueue_notify_first,
	gl_waitqueue_notify_all, glthread_rwlock_init_func,
	glthread_rwlock_rdlock_func, glthread_rwlock_wrlock_func,
	glthread_rwlock_unlock_func, glthread_rwlock_destroy_func): Remove
	functions.
	* modules/windows-rwlock: New file.
	* modules/lock (Depends-on): Add windows-rwlock.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	windows-timedrwlock: New module.
	* lib/windows-timedrwlock.h: New file, based on windows-rwlock.h.
	* lib/windows-timedrwlock.c: New file, based on windows-rwlock.c and
	windows-cond.c.
	* lib/windows-cond.h (struct glwthread_waitqueue_link): Protect against
	redefinition conflict with windows-timedrwlock.h.
	* modules/windows-timedrwlock: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	windows-spin: New module.
	* lib/windows-spin.h: New file.
	* lib/windows-spin.c: New file.
	* modules/windows-spin: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	sched_yield: New module.
	* lib/sched.in.h: Add _GL_FUNCDECL_RPL, _GL_WARN_ON_USE placeholders.
	(sched_yield): New declaration.
	* lib/sched_yield.c: New file.
	* m4/sched_yield.m4: New file.
	* m4/sched_h.m4 (gl_SCHED_H): Require gl_SCHED_H_DEFAULTS. Arrange to
	provide a replacement sched.h always. Test whether sched_yield is
	declared.
	(gl_SCHED_MODULE_INDICATOR, gl_SCHED_H_DEFAULTS): New macros.
	* modules/sched (Depends-on): Add snippet/c++defs, snippet/warn-on-use.
	(Makefile.am): Provide a replacement sched.h always. Substitute
	GNULIB_SCHED_YIELD, HAVE_SCHED_YIELD, REPLACE_SCHED_YIELD,
	_GL_FUNCDECL_RPL, _GL_WARN_ON_USE.
	* modules/sched_yield: New file.
	* doc/posix-functions/sched_yield.texi: Mention the new module.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: New module.
	* lib/pthread.in.h: Define replacement functions only if GNULIB_PTHREAD
	is 1.
	* m4/pthread_h.m4: Renamed from m4/pthread.m4.
	(gl_PTHREAD_H): Renamed from gl_PTHREAD_CHECK. Don't test whether
	<pthread.h> pollutes the namespace; instead, prepare for generating a
	pthread.h always. Substitute HAVE_PTHREAD_H here.
	(gl_PTHREAD_H_DEFAULTS): Renamed from gl_PTHREAD_DEFAULTS. Initialize
	GNULIB_PTHREAD. Don't initialize HAVE_PTHREAD_H here.
	* modules/pthread-h: New file, based on modules/pthread.
	* modules/pthread: Rely on 'pthread-h'.
	* m4/pthread_mutex_timedlock.m4 (gl_FUNC_PTHREAD_MUTEX_TIMEDLOCK):
	Update.
	* modules/pthread_mutex_timedlock (Depends-on): Add pthread-h. Remove
	pthread.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: Add tests.
	* tests/test-pthread.c: New file.
	* modules/pthread-h-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: Add C++ tests.
	* tests/test-pthread-c++.cc: New file.
	* modules/pthread-h-c++-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: Respect --enable-threads={posix|windows} option on mingw.
	* m4/pthread_h.m4 (gl_PTHREAD_H): Require gl_THREADLIB. Set
	HAVE_PTHREAD_H if gl_threads_api is 'windows'.
	(LIB_PTHREAD): Rely on $LIBMULTITHREAD from threadlib.m4.
	* modules/pthread (Link): Change to $(LIBMULTITHREAD).
	* modules/pthread-h (Depends-on): Add threadlib.
	(Link): Change to $(LIBTHREAD).
	* modules/pthread-h-c++-tests (test_pthread_c___LDADD): Use
	$(LIBMULTITHREAD) instead of $(LIB_PTHREAD).

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: Add declarations of essential pthread functions.
	* lib/pthread.in.h: Include snippets.
	(pthread_create, pthread_attr_init, pthread_attr_getdetachstate,
	pthread_attr_setdetachstate, pthread_attr_destroy, pthread_self,
	pthread_equal, pthread_detach, pthread_join, pthread_exit, pthread_once,
	pthread_mutex_init, pthread_mutexattr_init, pthread_mutexattr_gettype,
	pthread_mutexattr_settype, pthread_mutexattr_getrobust,
	pthread_mutexattr_setrobust, pthread_mutexattr_destroy,
	pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlock,
	pthread_mutex_destroy, pthread_rwlock_init, pthread_rwlockattr_init,
	pthread_rwlockattr_destroy, pthread_rwlock_rdlock,
	pthread_rwlock_wrlock, pthread_rwlock_tryrdlock,
	pthread_rwlock_trywrlock, pthread_rwlock_timedrdlock,
	pthread_rwlock_timedwrlock, pthread_rwlock_unlock,
	pthread_rwlock_destroy, pthread_cond_init, pthread_condattr_init,
	pthread_condattr_destroy, pthread_cond_wait, pthread_cond_timedwait,
	pthread_cond_signal, pthread_cond_broadcast, pthread_cond_destroy,
	pthread_key_create, pthread_setspecific, pthread_getspecific,
	pthread_key_delete, pthread_spin_init, pthread_spin_lock,
	pthread_spin_trylock, pthread_spin_unlock, pthread_spin_destroy): New
	declarations.
	(pthread_mutex_timedlock): Move declaration.
	* m4/pthread_h.m4 (gl_PTHREAD_H): Check whether the new functions are
	declared.
	(gl_PTHREAD_H_DEFAULTS): Initialize GNULIB_PTHREAD_THREAD,
	GNULIB_PTHREAD_ONCE, GNULIB_PTHREAD_MUTEX, GNULIB_PTHREAD_RWLOCK,
	GNULIB_PTHREAD_COND, GNULIB_PTHREAD_TSS, GNULIB_PTHREAD_SPIN and the
	HAVE_* and REPLACE_* variables for the new functions.
	* modules/pthread-h (Depends-on): Add snippet/c++defs,
	snippet/_Noreturn, snippet/arg-nonnull, snippet/warn-on-use.
	(Makefile.am): Substitute GNULIB_PTHREAD_THREAD, GNULIB_PTHREAD_ONCE,
	GNULIB_PTHREAD_MUTEX, GNULIB_PTHREAD_RWLOCK, GNULIB_PTHREAD_COND,
	GNULIB_PTHREAD_TSS, GNULIB_PTHREAD_SPIN and the HAVE_* and REPLACE_*
	variables for the new functions. Split the sed script, to avoid the
	limit of 99 commands of HP-UX sed.
	* tests/test-pthread-c++.cc: Check the signature of the new functions.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-h: Prepare for adding new modules.
	* lib/pthread.in.h: Define the types and macros for each of the
	facilities separately.
	* m4/pthread_h.m4 (gl_PTHREAD_H): Set HAVE_PTHREAD_CREATE_DETACHED,
	HAVE_PTHREAD_MUTEX_RECURSIVE, HAVE_PTHREAD_MUTEX_ROBUST,
	HAVE_PTHREAD_PROCESS_SHARED.
	(gl_PTHREAD_H_DEFAULTS): Initialize HAVE_PTHREAD_CREATE_DETACHED,
	HAVE_PTHREAD_MUTEX_RECURSIVE, HAVE_PTHREAD_MUTEX_ROBUST,
	HAVE_PTHREAD_PROCESS_SHARED.
	* modules/pthread-h (Makefile.am): Substitute
	HAVE_PTHREAD_CREATE_DETACHED, HAVE_PTHREAD_MUTEX_RECURSIVE,
	HAVE_PTHREAD_MUTEX_ROBUST, HAVE_PTHREAD_PROCESS_SHARED.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-thread: New module.
	* lib/pthread.in.h (pthread_create, pthread_exit, pthread_join): Remove
	inline definitions.
	* lib/pthread-thread.c: New file.
	* m4/pthread-thread.m4: New file.
	* modules/pthread-thread: New file.
	* doc/posix-functions/pthread_create.texi: Mention the new module.
	* doc/posix-functions/pthread_attr_init.texi: Likewise.
	* doc/posix-functions/pthread_attr_getdetachstate.texi: Likewise.
	* doc/posix-functions/pthread_attr_setdetachstate.texi: Likewise.
	* doc/posix-functions/pthread_attr_destroy.texi: Likewise.
	* doc/posix-functions/pthread_self.texi: Likewise.
	* doc/posix-functions/pthread_equal.texi: Likewise.
	* doc/posix-functions/pthread_detach.texi: Likewise.
	* doc/posix-functions/pthread_join.texi: Likewise.
	* doc/posix-functions/pthread_exit.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-once: New module.
	* lib/pthread-once.c: New file.
	* m4/pthread-once.m4: New file.
	* modules/pthread-once: New file.
	* doc/posix-functions/pthread_once.texi: Mention the new module.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-mutex: New module.
	* lib/pthread.in.h (pthread_mutexattr_destroy, pthread_mutexattr_init,
	pthread_mutexattr_settype, pthread_mutex_destroy, pthread_mutex_init,
	pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_timedlock,
	pthread_mutex_unlock): Remove inline definitions.
	* lib/pthread-mutex.c: New file.
	* m4/pthread-mutex.m4: New file.
	* modules/pthread-mutex: New file.
	* doc/posix-functions/pthread_mutex_init.texi: Mention the new module.
	* doc/posix-functions/pthread_mutexattr_init.texi: Likewise.
	* doc/posix-functions/pthread_mutexattr_gettype.texi: Likewise.
	* doc/posix-functions/pthread_mutexattr_settype.texi: Likewise.
	* doc/posix-functions/pthread_mutexattr_getrobust.texi: Likewise.
	* doc/posix-functions/pthread_mutexattr_setrobust.texi: Likewise.
	* doc/posix-functions/pthread_mutexattr_destroy.texi: Likewise.
	* doc/posix-functions/pthread_mutex_lock.texi: Likewise.
	* doc/posix-functions/pthread_mutex_trylock.texi: Likewise.
	* doc/posix-functions/pthread_mutex_timedlock.texi: Likewise.
	* doc/posix-functions/pthread_mutex_unlock.texi: Likewise.
	* doc/posix-functions/pthread_mutex_destroy.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-rwlock: New module.
	* lib/pthread-rwlock.c: New file, based on lib/glthread/lock.c.
	* m4/pthread-rwlock.m4: New file.
	* modules/pthread-rwlock: New file.
	* doc/posix-functions/pthread_rwlock_init.texi: Mention the new module
	and the Android problem.
	* doc/posix-functions/pthread_rwlockattr_init.texi: Likewise.
	* doc/posix-functions/pthread_rwlockattr_destroy.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_rdlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_wrlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_tryrdlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_trywrlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_timedrdlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_timedwrlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_unlock.texi: Likewise.
	* doc/posix-functions/pthread_rwlock_destroy.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-cond: New module.
	* lib/pthread.in.h (pthread_cond_destroy, pthread_cond_init,
	pthread_cond_signal, pthread_cond_wait): Remove inline definitions.
	* lib/pthread-cond.c: New file.
	* m4/pthread-cond.m4: New file.
	* modules/pthread-cond: New file.
	* doc/posix-functions/pthread_cond_init.texi: Mention the new module.
	* doc/posix-functions/pthread_condattr_init.texi: Likewise.
	* doc/posix-functions/pthread_condattr_destroy.texi: Likewise.
	* doc/posix-functions/pthread_cond_wait.texi: Likewise.
	* doc/posix-functions/pthread_cond_timedwait.texi: Likewise.
	* doc/posix-functions/pthread_cond_signal.texi: Likewise.
	* doc/posix-functions/pthread_cond_broadcast.texi: Likewise.
	* doc/posix-functions/pthread_cond_destroy.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-tss: New module.
	* lib/pthread-tss.c: New file.
	* m4/pthread-tss.m4: New file.
	* modules/pthread-tss: New file.
	* doc/posix-functions/pthread_key_create.texi: Mention the new module.
	* doc/posix-functions/pthread_setspecific.texi: Likewise.
	* doc/posix-functions/pthread_getspecific.texi: Likewise.
	* doc/posix-functions/pthread_key_delete.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-spin: New module.
	* lib/pthread.in.h (pthread_spin_init, pthread_spin_destroy,
	pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock): Remove
	inline definitions.
	* lib/pthread-spin.c: New file.
	* m4/pthread-spin.m4: New file.
	* modules/pthread-spin: New file.
	* doc/posix-functions/pthread_spin_init.texi: Mention the new module.
	* doc/posix-functions/pthread_spin_lock.texi: Likewise.
	* doc/posix-functions/pthread_spin_trylock.texi: Likewise.
	* doc/posix-functions/pthread_spin_unlock.texi: Likewise.
	* doc/posix-functions/pthread_spin_destroy.texi: Likewise.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread: Turn into a convenience module.
	* lib/pthread.in.h: Remove declarations for extern inline functions.
	* lib/pthread.c: Remove file.
	* modules/pthread (Files): Remove it.
	(Depends-on): Add pthread-thread, pthread-once, pthread-mutex,
	pthread-rwlock, pthread-cond, pthread-tss, pthread-spin.
	(configure.ac): Don't compile lib/pthread.c. Don't set GNULIB_PTHREAD.
	* m4/pthread_h.m4 (gl_PTHREAD_H_DEFAULTS): Don't initialize
	GNULIB_PTHREAD.
	* modules/pthread-h (Makefile.am): Don't substitute GNULIB_PTHREAD.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-thread: Add tests.
	* tests/test-pthread-thread.c: New file, based on
	tests/test-thread_create.c and tests/test-thrd_create.c.
	* modules/pthread-thread-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-once: Add tests.
	* tests/test-pthread-once1.c: New file, based on tests/test-once.c and
	tests/test-call_once.c.
	* tests/test-pthread-once2.c: New file, based on tests/test-lock.c and
	tests/test-mtx.c.
	* modules/pthread-once-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-mutex: Add tests.
	* tests/test-pthread-mutex.c: New file, based on tests/test-lock.c and
	tests/test-mtx.c.
	* modules/pthread-mutex-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-rwlock: Add tests.
	* tests/test-pthread-rwlock.c: New file, based on tests/test-lock.c.
	* modules/pthread-rwlock-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-cond: Add tests.
	* tests/test-pthread-cond.c: New file, based on tests/test-cond.c and
	tests/test-cnd.c.
	* modules/pthread-cond-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread-tss: Add tests.
	* tests/test-pthread-tss.c: New file, based on tests/test-tls.c and
	tests/test-tss.c.
	* modules/pthread-tss-tests: New file.

2019-07-14  Bruno Haible  <bruno@clisp.org>

	pthread_sigmask tests: Use new multithread modules.
	* tests/test-pthread_sigmask2.c: Include <pthread.h> instead of
	glthread/thread.h.
	(main_thread, killer_thread): Change type to pthread_t.
	(main): Update accordingly.
	* modules/pthread_sigmask-tests (Depends-on): Add pthread-thread. Remove
	thread.


[-- Attachment #2: 30-commits.zip --]
[-- Type: application/zip, Size: 100295 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-25  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-15  1:05 pthread: new set of modules Bruno Haible
2019-07-25  1:23 ` Bruno Haible

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).