bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] regex: trim module dependencies


From: Bruno Haible
Subject: Re: [PATCH] regex: trim module dependencies
Date: Sun, 01 Jul 2018 14:24:46 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-128-generic; KDE/5.18.0; x86_64; ; )

Hi Paul,

> * modules/regex (Depends-on): Remove gettext-h and lock,
> since the regex code should work OK without these modules,
> and Emacs uses it that way.

The removal of the gettext-h dependency is fine; regex_internal.h
tests ENABLE_NLS and includes <libintl.h>.

But I object against the removal of the 'lock' dependency. This change
transforms a module that is by default multithread-safe into a module
that by default will crash in multithreaded situations. There is logic
in regex_internal.h (lines 61..97):

#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
# include "glthread/lock.h"
#  define lock_define(name)
# ...
#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
# include <pthread.h>
# define lock_define(name) pthread_mutex_t name;
# ...
#else
# define lock_define(name)
# ...
#endif

It implements the following (desired and perfectly correct) behaviour:
  - If the 'lock' module is present, use it to achieve MT-safety on
    all platforms.
  - Otherwise, if the 'pthread' module is present, use it to achieve
    MT-safety on POSIX-like platforms.
  - Otherwise, give up on MT-safety.

Gnulib users should *not* need to know "regex is not MT-safe by default,
therefore I need to include the 'lock' module". Rather, Gnulib users
should get an MT-safe module by default, and if they don't like the
complexities of 'lock' or 'pthread' modules, they can use the --avoid
option IF THEY KNOW that their application is single-threaded.

The coreutils maintainers should not have to check whether 'sort' and
other multithreaded programs use regex.
Likewise, the gettext maintainers should not have to check whether
'msgmerge' and libgettextpo (and possibly other multithreaded parts of
gettext) use regex.
And so on.

That's easy for you to achieve in Emacs (assuming you know that Emacs
uses regex only from a single thread):

diff --git a/admin/merge-gnulib b/admin/merge-gnulib
index 9a5ad54..f55908c 100755
--- a/admin/merge-gnulib
+++ b/admin/merge-gnulib
@@ -47,8 +47,9 @@ GNULIB_MODULES='
 
 AVOIDED_MODULES='
   close dup fchdir fstat
+  lock
   malloc-posix msvc-inval msvc-nothrow
-  openat-die opendir raise
+  openat-die opendir pthread raise
   save-cwd select setenv sigprocmask stat stdarg stdbool
   threadlib tzset unsetenv utime utime-h
 '

> Also remove memcmp, memmove,
> and wctype, as these modules are obsolete and should not be
> needed any more.

It is not needed to avoid dependencies to obsolete modules. See the
Gnulib documentation [1]:

  "Depends-on

    This field contains a newline separated list of the modules that are
    required for the proper working of this module. gnulib-tool includes
    each required module automatically, unless it is specified with option
    --avoid or it is marked as obsolete and the option --with-obsolete
    is not given."

Maybe this sentence is too long to be understood, and I should reword it?

Bruno

[1] https://www.gnu.org/software/gnulib/manual/html_node/Module-description.html




reply via email to

[Prev in Thread] Current Thread [Next in Thread]