+2026-04-10 Bruno Haible <bruno@clisp.org>
+
+ sigprocmask: Allow single-thread optimization again.
+ * lib/sigprocmask.c (glwthread_spin_lock, glwthread_spin_unlock): Define
+ to empty if GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
+ (overrides_mt_lock, overrides_handler_lock): Don't define if
+ GNULIB_SIGPROCMASK_SINGLE_THREAD is defined.
+ * doc/multithread.texi (Multithreading Optimizations): Document
+ GNULIB_SIGPROCMASK_SINGLE_THREAD instead of
+ GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD.
+
2026-04-10 Bruno Haible <bruno@clisp.org>
sigprocmask: Fix a signal-handler hang in case of a race condition.
You can get this macro defined by including the Gnulib module
@code{wchar-single}.
@item
-You may define the C macro @code{GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD}
-if all the programs in your package invoke @code{pthread_sigmask} only
-from a single thread.
+You may define the C macro @code{GNULIB_SIGPROCMASK_SINGLE_THREAD}, if all the
+programs in your package invoke the functions of the @code{sigprocmask} module
+(in particular, @code{sigprocmask}, @code{pthread_sigmask}, @code{signal}, and
+@code{sigaction}) only from a single thread.
@item
You may define the C macro @code{GNULIB_EXCLUDE_SINGLE_THREAD}, if all the
programs in your package invoke the functions of the @code{exclude} module
# include "msvc-inval.h"
#endif
-#include "windows-spin.h"
+#if GNULIB_SIGPROCMASK_SINGLE_THREAD
+# define glwthread_spin_lock(lock)
+# define glwthread_spin_unlock(lock)
+#else
+# include "windows-spin.h"
+#endif
/* We assume that a platform without POSIX signal blocking functions
also does not have the POSIX sigaction() function, only the
};
static struct override overrides[NSIG] /* = { { 0, NULL }, ... } */;
+#if !GNULIB_SIGPROCMASK_SINGLE_THREAD
/* A spin lock that protects overrides against simultaneous use from
different threads, outside signal handlers. */
static glwthread_spinlock_t overrides_mt_lock = GLWTHREAD_SPIN_INIT;
/* A spin lock that protects overrides against simultaneous use from
a signal handler and a pthread_sigmask invocation. */
static glwthread_spinlock_t overrides_handler_lock = GLWTHREAD_SPIN_INIT;
+#endif
/* Signal handler that overrides an original one. */
static void