[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lock, tls, and single-threaded applications
From: |
Bruno Haible |
Subject: |
Re: lock, tls, and single-threaded applications |
Date: |
Wed, 18 Jun 2008 02:33:59 +0200 |
User-agent: |
KMail/1.5.4 |
Hi Eric,
> The strsignal module is rather heavy-handed when used for a single-threaded
> app, since thread-local storage is not really necessary in that case. What
> is
> the recommended way to git a single-thread-friendly strsignal? Maybe it is
> worth creating a strsignal-simple module that avoids pulling in lock and tls?
>
> Or is it as simple as using './gnulib-tool --avoid lock'?
Just avoiding the 'lock' and 'tls' modules will not work, because they export
some header files, and source code won't compile if these header files are not
present.
But these header files are already providing no-op code if the user has
chosen to configure with --disable-threads. The default for this option is in
m4/lock.m4, lines 49..55. lock.m4 can export a macro gl_DISABLE_THREADS
that would set the default to "no threads"; the user could then still use
--enable-threads. Implemented as follows:
2008-06-17 Bruno Haible <address@hidden>
New macro gl_DISABLE_THREADS.
* m4/lock.m4 (gl_LOCK_EARLY_BODY): Use value gl_use_threads_default
if the user did not pass --enable-threads or --disable-threads option.
(gl_DISABLE_THREADS): New macro.
Reported by Eric Blake <address@hidden>.
*** m4/lock.m4.orig 2008-06-18 02:29:23.000000000 +0200
--- m4/lock.m4 2008-06-18 02:22:32.000000000 +0200
***************
*** 1,11 ****
! # lock.m4 serial 7 (gettext-0.17)
! dnl Copyright (C) 2005-2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
dnl Tests for a multithreading library to be used.
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
dnl USE_PTH_THREADS, USE_WIN32_THREADS
--- 1,13 ----
! # lock.m4 serial 8 (gettext-0.18)
! dnl Copyright (C) 2005-2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Bruno Haible.
+ dnl gl_LOCK
+ dnl -------
dnl Tests for a multithreading library to be used.
dnl Defines at most one of the macros USE_POSIX_THREADS, USE_SOLARIS_THREADS,
dnl USE_PTH_THREADS, USE_WIN32_THREADS
***************
*** 42,58 ****
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
[AC_REQUIRE([AC_GNU_SOURCE])])
dnl Check for multithreading.
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify
multithreading API])
AC_HELP_STRING([--disable-threads], [build without multithread safety]),
[gl_use_threads=$enableval],
! [case "$host_os" in
! dnl Disable multithreading by default on OSF/1, because it interferes
! dnl with fork()/exec(): When msgexec is linked with -lpthread, its
child
! dnl process gets an endless segmentation fault inside execvp().
! osf*) gl_use_threads=no ;;
! *) gl_use_threads=yes ;;
! esac
])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# For using <pthread.h>:
--- 44,65 ----
[AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])],
[AC_REQUIRE([AC_GNU_SOURCE])])
dnl Check for multithreading.
+ m4_divert_text([DEFAULTS], [gl_use_threads_default=])
AC_ARG_ENABLE(threads,
AC_HELP_STRING([--enable-threads={posix|solaris|pth|win32}], [specify
multithreading API])
AC_HELP_STRING([--disable-threads], [build without multithread safety]),
[gl_use_threads=$enableval],
! [if test -n "$gl_use_threads_default"; then
! gl_use_threads="$gl_use_threads_default"
! else
! case "$host_os" in
! dnl Disable multithreading by default on OSF/1, because it interferes
! dnl with fork()/exec(): When msgexec is linked with -lpthread, its
! dnl child process gets an endless segmentation fault inside execvp().
! osf*) gl_use_threads=no ;;
! *) gl_use_threads=yes ;;
! esac
! fi
])
if test "$gl_use_threads" = yes || test "$gl_use_threads" = posix; then
# For using <pthread.h>:
***************
*** 262,267 ****
--- 269,286 ----
AC_REQUIRE([AC_C_INLINE])
])
+
+ dnl gl_DISABLE_THREADS
+ dnl ------------------
+ dnl Sets the gl_LOCK default so that threads are not used by default.
+ dnl The user can still override it at installation time, by using the
+ dnl configure option '--enable-threads'.
+
+ AC_DEFUN([gl_DISABLE_THREADS], [
+ m4_divert_text([INIT_PREPARE], [gl_use_threads_default=no])
+ ])
+
+
dnl Survey of platforms:
dnl
dnl Platform Available Compiler Supports test-lock
- strsignal on mingw, Eric Blake, 2008/06/17
- Re: lock, tls, and single-threaded applications,
Bruno Haible <=
- Re: lock, tls, and single-threaded applications, Eric Blake, 2008/06/17
- Re: lock, tls, and single-threaded applications, Bruno Haible, 2008/06/18
- Re: lock, tls, and single-threaded applications, Jim Meyering, 2008/06/18
- Re: lock, tls, and single-threaded applications, Bruno Haible, 2008/06/18
Re: tls license, Bruno Haible, 2008/06/17
Re: lock warnings on mingw, Bruno Haible, 2008/06/17
Re: tls warnings on mingw, Bruno Haible, 2008/06/17