]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
sigprocmask: Allow single-thread optimization again. master
authorBruno Haible <bruno@clisp.org>
Fri, 10 Apr 2026 21:11:40 +0000 (23:11 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 10 Apr 2026 21:11:40 +0000 (23:11 +0200)
* 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.

ChangeLog
doc/multithread.texi
lib/sigprocmask.c

index e89c273e1d55efa68aa71ef19ed5b8b4ecc8e4c2..4b627f3ea29ce58da3edf0c03e51709529e20335 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index d86da6d340fdc9883aea409b97be245cecc99ba1..f53f5d6a77ca20270367c0121ebbd27f1e33c611 100644 (file)
@@ -323,9 +323,10 @@ This macro optimizes the functions @code{mbrtowc}, @code{mbrtoc32}, and
 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
index 92b774f3b0317cc00cda9bd99b16f73c1c6d0989..25b698d869ba40c759be0627f7cfd7c1b004d5ff 100644 (file)
 # 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
@@ -222,12 +227,14 @@ struct override
 };
 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