bug-gnulib
[Top][All Lists]
Advanced

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

Re: threadlib and emacs


From: Paul Eggert
Subject: Re: threadlib and emacs
Date: Sun, 17 Jul 2011 20:28:46 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11

On 07/17/11 18:00, Paul Eggert wrote:
> I suppose another possible hack is to replace the ifdef with
> something like m4_ifdef([gl_[]THREADLIB], ...); I haven't
> investigated that.

I tried that, and it seems to work.  It strikes me that
other gnulib macros play the m4_ifdef trick too, e.g.,
gl_FUNC_WRITE does m4_ifdef([gl_NONBLOCKING_IO], ...).
Perhaps they also need to obfuscate their symbol too?
If not, what's a good rule of thumb for deciding whether
symbols need obfuscating to escape aclocal's attention?

Anyway, getting back to to the main topic, here is a combined
patch that doesn't involve altering gnulib-tool.  This
patch changes behavior only for applications that are not
using threadlib.  Also, since it changes pthread_sigmask to work
even when threadlib is absent, it removes the dependency of
pthread_sigmask on threadlib.  Perhaps there should be a comment
about that in "Depends-on:"? or some more-automated decoration?

diff --git a/ChangeLog b/ChangeLog
index 97a28f0..72c309d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
+2011-07-17  Paul Eggert  <address@hidden>
+
+       pthread_sigmask: assume POSIX if not using threadlib
+       This differs from the previous patch, in that it does not distinguish
+       from gl_THREADLIB being avoided, and it not being used.
+       * gnulib-tool: Undo previous change; no longer needed.
+       * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
+       Assume POSIX if gl_THREADLIB is defined, not if threadlib is avoided.
+       Spell gl_THREADLIB in a funny way so that aclocal doesn't see it.
+       * modules/pthread_sigmask (Depends-on): Remove threadlib,
+       since the module now works without threadlib.
+
 2011-07-16  Paul Eggert  <address@hidden>
 
+       pthread_sigmask: assume POSIX if --avoid=threadlib
+       * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): If threadlib is
+       avoided, do not require it.  Instead, assume the application has
+       already arranged for POSIX threads, if it is multithreaded.
+       GNU Emacs can use this.
+
+       gnulib-tool: Define gl_AVOID_MODULE_x given --avoid=x.
+       * gnulib-tool (func_dest_tmpfilename):
+       Define gl_AVOID_MODULE_x for each avoided module x.
+
        pthread_sigmask: ensure usleep is declared
        * lib/pthread_sigmask.c [PTHREAD_SIGMASK_UNBLOCK_BUG]:
        Include <unistd.h>, to declare usleep.  Needed on Solaris 8,
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
index 3803988..4a4901f 100644
--- a/m4/pthread_sigmask.m4
+++ b/m4/pthread_sigmask.m4
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 10
+# pthread_sigmask.m4 serial 12
 dnl Copyright (C) 2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,56 +6,77 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK],
 [
-  AC_REQUIRE([gl_THREADLIB])
-
   AC_CHECK_FUNCS_ONCE([pthread_sigmask])
+  if test $ac_cv_func_pthread_sigmask != yes; then
+    HAVE_PTHREAD_SIGMASK=0
+  fi
   LIB_PTHREAD_SIGMASK=
-  if test "$gl_threads_api" = posix; then
-    if test $ac_cv_func_pthread_sigmask = yes; then
-      dnl pthread_sigmask is available without -lpthread.
-      :
-    else
-      if test -n "$LIBMULTITHREAD"; then
-        AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD],
-          [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD],
-          [gl_save_LIBS="$LIBS"
-           LIBS="$LIBS $LIBMULTITHREAD"
-           AC_LINK_IFELSE(
-             [AC_LANG_PROGRAM(
-                [[#include <pthread.h>
-                  #include <signal.h>
-                ]],
-                [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 
0);]])
-             ],
-             [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes],
-             [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no])
-           LIBS="$gl_save_LIBS"
-          ])
-        if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then
-          dnl pthread_sigmask is available with -lpthread.
-          LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD"
-        else
-          dnl pthread_sigmask is not available at all.
-          HAVE_PTHREAD_SIGMASK=0
+
+  m4_ifdef([gl_[]THREADLIB], [
+    dnl Assume threadlib is in use if its main symbol is defined.
+    dnl Spell the symbol in a funny way, so that aclocal doesn't see it
+    dnl and define it for us even if we don't want it.
+    AC_REQUIRE([gl_[]THREADLIB])
+    if test "$gl_threads_api" = posix; then
+      if test $ac_cv_func_pthread_sigmask != yes &&
+         test -n "$LIBMULTITHREAD"
+      then
+          AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD],
+            [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD],
+            [gl_save_LIBS="$LIBS"
+             LIBS="$LIBS $LIBMULTITHREAD"
+             AC_LINK_IFELSE(
+               [AC_LANG_PROGRAM(
+                  [[#include <pthread.h>
+                    #include <signal.h>
+                  ]],
+                  [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 
0);]])
+               ],
+               [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes],
+               [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no])
+             LIBS="$gl_save_LIBS"
+            ])
+          if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then
+            dnl pthread_sigmask is available with -lpthread.
+            LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD"
+            HAVE_PTHREAD_SIGMASK=1
+          fi
         fi
-      else
-        dnl pthread_sigmask is not available at all.
-        HAVE_PTHREAD_SIGMASK=0
+      fi
+    else
+      dnl pthread_sigmask may exist but does not interoperate with the chosen
+      dnl multithreading facility.
+      dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask,
+      dnl but it is equivalent to sigprocmask, so we choose to emulate
+      dnl pthread_sigmask with sigprocmask also in this case. This yields fewer
+      dnl link dependencies.
+      if test $ac_cv_func_pthread_sigmask = yes; then
+        REPLACE_PTHREAD_SIGMASK=1
       fi
     fi
-  else
-    dnl pthread_sigmask may exist but does not interoperate with the chosen
-    dnl multithreading facility.
-    dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask,
-    dnl but it is equivalent to sigprocmask, so we choose to emulate
-    dnl pthread_sigmask with sigprocmask also in this case. This yields fewer
-    dnl link dependencies.
+  ],[
+    dnl Assume threadlib is not in use.
+    dnl Assume POSIX.1-2008 (or later) semantics.  Do not fiddle with
+    dnl compiler or linker options, since any application not
+    dnl already properly configured for threads is most likely single
+    dnl threaded and can use gnulib's sigprocmask-based substitute.
     if test $ac_cv_func_pthread_sigmask = yes; then
-      REPLACE_PTHREAD_SIGMASK=1
-    else
-      HAVE_PTHREAD_SIGMASK=0
+      AC_CACHE_CHECK([for pthread_sigmask with POSIX signature],
+        [gl_cv_func_pthread_sigmask_posix_signature],
+        [AC_LINK_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <signal.h>
+              ]],
+              [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 0);]])
+           ],
+           [gl_cv_func_pthread_sigmask_posix_signature=yes],
+           [gl_cv_func_pthread_sigmask_posix_signature=no])])
+      if test "$gl_cv_func_pthread_sigmask_posix_signature" != yes; then
+        REPLACE_PTHREAD_SIGMASK=1
+      fi
     fi
-  fi
+  ])
+
   AC_SUBST([LIB_PTHREAD_SIGMASK])
   dnl We don't need a variable LTLIB_PTHREAD_SIGMASK, because when
   dnl "$gl_threads_api" = posix, $LTLIBMULTITHREAD and $LIBMULTITHREAD are the
diff --git a/modules/pthread_sigmask b/modules/pthread_sigmask
index b9a8f96..9e26e13 100644
--- a/modules/pthread_sigmask
+++ b/modules/pthread_sigmask
@@ -7,7 +7,6 @@ m4/pthread_sigmask.m4
 
 Depends-on:
 signal
-threadlib
 sigprocmask     [test $HAVE_PTHREAD_SIGMASK = 0 || test 
$REPLACE_PTHREAD_SIGMASK = 1]
 
 configure.ac:



reply via email to

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