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

* Re: pthread: new set of modules
  2019-07-15  1:05 pthread: new set of modules Bruno Haible
@ 2019-07-25  1:23 ` Bruno Haible
  0 siblings, 0 replies; 2+ messages in thread
From: Bruno Haible @ 2019-07-25  1:23 UTC (permalink / raw)
  To: bug-gnulib

Here's a fix, to make it compile on mingw when module 'pthread-h' is used
*without* the modules 'pthread-thread', ..., 'pthread-spin'.


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

	pthread-h: Fix definitions of types and macros on mingw.
	* lib/pthread.in.h (pthread_t, pthread_attr_t, PTHREAD_CREATE_JOINABLE,
	PTHREAD_CREATE_DETACHED): Define also when module 'pthread-thread' is
	not in use.
	(pthread_once_t, PTHREAD_ONCE_INIT): Define also when module
	'pthread-once' is not in use.
	(pthread_mutex_t, pthread_mutexattr_t, PTHREAD_MUTEX_INITIALIZER,
	PTHREAD_MUTEX_DEFAULT, PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK,
	PTHREAD_MUTEX_RECURSIVE): Define also when module 'pthread-mutex' is not
	in use.
	(pthread_rwlock_t, pthread_rwlockattr_t, PTHREAD_RWLOCK_INITIALIZER):
	Define also when module 'pthread-rwlock' is not in use.
	(pthread_cond_t, pthread_condattr_t, PTHREAD_COND_INITIALIZER): Define
	also when module 'pthread-cond' is not in use.
	(pthread_key_t, PTHREAD_DESTRUCTOR_ITERATIONS): Define also when module
	'pthread-tss' is not in use.
	(pthread_spinlock_t): Define also when module 'pthread-spin' is not in
	use.

diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index c8963c8..4fc22bf 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -79,16 +79,28 @@
 
 /* =========== Thread types and macros =========== */
 
-#if @GNULIB_PTHREAD_THREAD@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-thread.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_t rpl_pthread_t
-#  define pthread_attr_t rpl_pthread_attr_t
-# endif
-# if !GNULIB_defined_pthread_thread_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_THREAD@
+#  include "windows-thread.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_t rpl_pthread_t
+#   define pthread_attr_t rpl_pthread_attr_t
+#  endif
+#  if !GNULIB_defined_pthread_thread_types
 typedef glwthread_thread_t pthread_t;
 typedef unsigned int pthread_attr_t;
-#  define GNULIB_defined_pthread_thread_types 1
+#   define GNULIB_defined_pthread_thread_types 1
+#  endif
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_t rpl_pthread_t
+#   define pthread_attr_t rpl_pthread_attr_t
+#  endif
+#  if !GNULIB_defined_pthread_thread_types
+typedef int pthread_t;
+typedef unsigned int pthread_attr_t;
+#   define GNULIB_defined_pthread_thread_types 1
+#  endif
 # endif
 # undef PTHREAD_CREATE_JOINABLE
 # undef PTHREAD_CREATE_DETACHED
@@ -110,17 +122,29 @@ typedef unsigned int pthread_attr_t;
 
 /* =========== Once-only control (initialization) types and macros ========== */
 
-#if @GNULIB_PTHREAD_ONCE@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-once.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_once_t rpl_pthread_once_t
-# endif
-# if !GNULIB_defined_pthread_once_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_ONCE@
+#  include "windows-once.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_once_t rpl_pthread_once_t
+#  endif
+#  if !GNULIB_defined_pthread_once_types
 typedef glwthread_once_t pthread_once_t;
-#  define GNULIB_defined_pthread_once_types 1
+#   define GNULIB_defined_pthread_once_types 1
+#  endif
+#  undef PTHREAD_ONCE_INIT
+#  define PTHREAD_ONCE_INIT GLWTHREAD_ONCE_INIT
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_once_t rpl_pthread_once_t
+#  endif
+#  if !GNULIB_defined_pthread_once_types
+typedef int pthread_once_t;
+#   define GNULIB_defined_pthread_once_types 1
+#  endif
+#  undef PTHREAD_ONCE_INIT
+#  define PTHREAD_ONCE_INIT { 0 }
 # endif
-# undef PTHREAD_ONCE_INIT
-# define PTHREAD_ONCE_INIT GLWTHREAD_ONCE_INIT
 #else
 # if !@HAVE_PTHREAD_T@
 #  if !GNULIB_defined_pthread_once_types
@@ -134,14 +158,15 @@ typedef int pthread_once_t;
 
 /* =========== Mutex types and macros =========== */
 
-#if @GNULIB_PTHREAD_MUTEX@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-timedmutex.h"
-# include "windows-timedrecmutex.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_mutex_t rpl_pthread_mutex_t
-#  define pthread_mutexattr_t rpl_pthread_mutexattr_t
-# endif
-# if !GNULIB_defined_pthread_mutex_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_MUTEX@
+#  include "windows-timedmutex.h"
+#  include "windows-timedrecmutex.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_mutex_t rpl_pthread_mutex_t
+#   define pthread_mutexattr_t rpl_pthread_mutexattr_t
+#  endif
+#  if !GNULIB_defined_pthread_mutex_types
 typedef struct
         {
           int type;
@@ -154,10 +179,23 @@ typedef struct
         }
         pthread_mutex_t;
 typedef unsigned int pthread_mutexattr_t;
-#  define GNULIB_defined_pthread_mutex_types 1
+#   define GNULIB_defined_pthread_mutex_types 1
+#  endif
+#  undef PTHREAD_MUTEX_INITIALIZER
+#  define PTHREAD_MUTEX_INITIALIZER { 1, { GLWTHREAD_TIMEDMUTEX_INIT } }
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_mutex_t rpl_pthread_mutex_t
+#   define pthread_mutexattr_t rpl_pthread_mutexattr_t
+#  endif
+#  if !GNULIB_defined_pthread_mutex_types
+typedef int pthread_mutex_t;
+typedef unsigned int pthread_mutexattr_t;
+#   define GNULIB_defined_pthread_mutex_types 1
+#  endif
+#  undef PTHREAD_MUTEX_INITIALIZER
+#  define PTHREAD_MUTEX_INITIALIZER { 0 }
 # endif
-# undef PTHREAD_MUTEX_INITIALIZER
-# define PTHREAD_MUTEX_INITIALIZER { 1, { GLWTHREAD_TIMEDMUTEX_INIT } }
 # undef PTHREAD_MUTEX_DEFAULT
 # undef PTHREAD_MUTEX_NORMAL
 # undef PTHREAD_MUTEX_ERRORCHECK
@@ -194,19 +232,33 @@ typedef unsigned int pthread_mutexattr_t;
 
 /* =========== Read-write lock types and macros =========== */
 
-#if @GNULIB_PTHREAD_RWLOCK@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-timedrwlock.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_rwlock_t rpl_pthread_rwlock_t
-#  define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
-# endif
-# if !GNULIB_defined_pthread_rwlock_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_RWLOCK@
+#  include "windows-timedrwlock.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_rwlock_t rpl_pthread_rwlock_t
+#   define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
+#  endif
+#  if !GNULIB_defined_pthread_rwlock_types
 typedef glwthread_timedrwlock_t pthread_rwlock_t;
 typedef unsigned int pthread_rwlockattr_t;
-#  define GNULIB_defined_pthread_rwlock_types 1
+#   define GNULIB_defined_pthread_rwlock_types 1
+#  endif
+#  undef PTHREAD_RWLOCK_INITIALIZER
+#  define PTHREAD_RWLOCK_INITIALIZER GLWTHREAD_TIMEDRWLOCK_INIT
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_rwlock_t rpl_pthread_rwlock_t
+#   define pthread_rwlockattr_t rpl_pthread_rwlockattr_t
+#  endif
+#  if !GNULIB_defined_pthread_rwlock_types
+typedef int pthread_rwlock_t;
+typedef unsigned int pthread_rwlockattr_t;
+#   define GNULIB_defined_pthread_rwlock_types 1
+#  endif
+#  undef PTHREAD_RWLOCK_INITIALIZER
+#  define PTHREAD_RWLOCK_INITIALIZER { 0 }
 # endif
-# undef PTHREAD_RWLOCK_INITIALIZER
-# define PTHREAD_RWLOCK_INITIALIZER GLWTHREAD_TIMEDRWLOCK_INIT
 #elif @GNULIB_PTHREAD_RWLOCK@ && @REPLACE_PTHREAD_RWLOCK_INIT@ /* i.e. PTHREAD_RWLOCK_UNIMPLEMENTED */
 # if @HAVE_PTHREAD_T@
 #  define pthread_rwlock_t rpl_pthread_rwlock_t
@@ -242,19 +294,33 @@ typedef unsigned int pthread_rwlockattr_t;
 
 /* =========== Condition variable types and macros =========== */
 
-#if @GNULIB_PTHREAD_COND@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-cond.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_cond_t rpl_pthread_cond_t
-#  define pthread_condattr_t rpl_pthread_condattr_t
-# endif
-# if !GNULIB_defined_pthread_cond_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_COND@
+#  include "windows-cond.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_cond_t rpl_pthread_cond_t
+#   define pthread_condattr_t rpl_pthread_condattr_t
+#  endif
+#  if !GNULIB_defined_pthread_cond_types
 typedef glwthread_cond_t pthread_cond_t;
 typedef unsigned int pthread_condattr_t;
-#  define GNULIB_defined_pthread_cond_types 1
+#   define GNULIB_defined_pthread_cond_types 1
+#  endif
+#  undef PTHREAD_COND_INITIALIZER
+#  define PTHREAD_COND_INITIALIZER GLWTHREAD_COND_INIT
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_cond_t rpl_pthread_cond_t
+#   define pthread_condattr_t rpl_pthread_condattr_t
+#  endif
+#  if !GNULIB_defined_pthread_cond_types
+typedef int pthread_cond_t;
+typedef unsigned int pthread_condattr_t;
+#   define GNULIB_defined_pthread_cond_types 1
+#  endif
+#  undef PTHREAD_COND_INITIALIZER
+#  define PTHREAD_COND_INITIALIZER { 0 }
 # endif
-# undef PTHREAD_COND_INITIALIZER
-# define PTHREAD_COND_INITIALIZER GLWTHREAD_COND_INIT
 #else
 # if !@HAVE_PTHREAD_T@
 #  if !GNULIB_defined_pthread_cond_types
@@ -269,17 +335,29 @@ typedef unsigned int pthread_condattr_t;
 
 /* =========== Thread-specific storage types and macros =========== */
 
-#if @GNULIB_PTHREAD_TSS@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-tls.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_key_t rpl_pthread_key_t
-# endif
-# if !GNULIB_defined_pthread_tss_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_TSS@
+#  include "windows-tls.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_key_t rpl_pthread_key_t
+#  endif
+#  if !GNULIB_defined_pthread_tss_types
 typedef glwthread_tls_key_t pthread_key_t;
-#  define GNULIB_defined_pthread_tss_types 1
+#   define GNULIB_defined_pthread_tss_types 1
+#  endif
+#  undef PTHREAD_DESTRUCTOR_ITERATIONS
+#  define PTHREAD_DESTRUCTOR_ITERATIONS GLWTHREAD_DESTRUCTOR_ITERATIONS
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_key_t rpl_pthread_key_t
+#  endif
+#  if !GNULIB_defined_pthread_tss_types
+typedef void ** pthread_key_t;
+#   define GNULIB_defined_pthread_tss_types 1
+#  endif
+#  undef PTHREAD_DESTRUCTOR_ITERATIONS
+#  define PTHREAD_DESTRUCTOR_ITERATIONS 0
 # endif
-# undef PTHREAD_DESTRUCTOR_ITERATIONS
-# define PTHREAD_DESTRUCTOR_ITERATIONS GLWTHREAD_DESTRUCTOR_ITERATIONS
 #else
 # if !@HAVE_PTHREAD_T@
 #  if !GNULIB_defined_pthread_tss_types
@@ -293,14 +371,24 @@ typedef void ** pthread_key_t;
 
 /* =========== Spinlock types and macros =========== */
 
-#if @GNULIB_PTHREAD_SPIN@ && (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
-# include "windows-spin.h"
-# if @HAVE_PTHREAD_T@
-#  define pthread_spinlock_t rpl_pthread_spinlock_t
-# endif
-# if !GNULIB_defined_pthread_spin_types
+#if (defined _WIN32 && ! defined __CYGWIN__) && USE_WINDOWS_THREADS
+# if @GNULIB_PTHREAD_SPIN@
+#  include "windows-spin.h"
+#  if @HAVE_PTHREAD_T@
+#   define pthread_spinlock_t rpl_pthread_spinlock_t
+#  endif
+#  if !GNULIB_defined_pthread_spin_types
 typedef glwthread_spinlock_t pthread_spinlock_t;
-#  define GNULIB_defined_pthread_spin_types 1
+#   define GNULIB_defined_pthread_spin_types 1
+#  endif
+# else
+#  if @HAVE_PTHREAD_T@
+#   define pthread_spinlock_t rpl_pthread_spinlock_t
+#  endif
+#  if !GNULIB_defined_pthread_spin_types
+typedef pthread_mutex_t pthread_spinlock_t;
+#   define GNULIB_defined_pthread_spin_types 1
+#  endif
 # endif
 # undef PTHREAD_PROCESS_PRIVATE
 # undef PTHREAD_PROCESS_SHARED



^ permalink raw reply related	[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).