Paul Eggert wrote: > I attempted to put gzip on a diet by installing the attached Gnulib > patches to remove some unnecessary dependencies
Patch 0003 is very brittle: It assumes that glthread/lock.h can be used without glthread/lock.c. That is, it assumes that glthread/lock.h does not define inline functions. Which is a maintainability pitfall. A better way is to introduce a flag GNULIB_SIGACTION_SINGLE_THREAD, that can be defined in configure.ac. Paul, for 'gzip' it means you will not only need '--avoid=lock', but also need to define GNULIB_SIGACTION_SINGLE_THREAD in configure.ac, like this: AC_DEFINE([GNULIB_SIGACTION_SINGLE_THREAD], [1], [Define to 1 if programs call 'sigaction' functions from a single thread.]) 2026-04-01 Bruno Haible <[email protected]> sigprocmask: Allow single-thread optimization in a more reliable way. * modules/sigprocmask: Revert last change. * lib/sigprocmask.c: Test GNULIB_SIGPROCMASK_SINGLE_THREAD before including glthread/lock.h. * doc/multithread.texi: Document GNULIB_SIGPROCMASK_SINGLE_THREAD. diff --git a/doc/multithread.texi b/doc/multithread.texi index 1316404bef..63387874f7 100644 --- a/doc/multithread.texi +++ b/doc/multithread.texi @@ -323,6 +323,10 @@ You can get this macro defined by including the Gnulib module @code{wchar-single}. @item +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 +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 only from a single thread. diff --git a/lib/sigprocmask.c b/lib/sigprocmask.c index 2399f58ead..9ee0355ce0 100644 --- a/lib/sigprocmask.c +++ b/lib/sigprocmask.c @@ -24,7 +24,13 @@ #include <stdint.h> #include <stdlib.h> -#include "glthread/lock.h" +#if GNULIB_SIGPROCMASK_SINGLE_THREAD +# include "glthread/lock.h" +#else +# define gl_lock_define_initialized(storageclass,name) +# define gl_lock_lock(lock) +# define gl_lock_unlock(lock) +#endif #if HAVE_MSVC_INVALID_PARAMETER_HANDLER # include "msvc-inval.h" diff --git a/modules/sigprocmask b/modules/sigprocmask index ea706bab65..79e7c7302f 100644 --- a/modules/sigprocmask +++ b/modules/sigprocmask @@ -2,7 +2,6 @@ Description: POSIX compatible signal blocking. Files: -lib/glthread/lock.h lib/sigprocmask.c m4/signalblocking.m4
