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: Sat, 16 Jul 2011 03:11:21 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10

Here are two proposed patches to get Emacs to work with gnulib
pthread_sigmask.  The idea is that GNU Emacs will use --avoid=threadlib.

The first patch is for gnulib-tool, the second for pthread_sigmask;
the second depends on the first.  The second patch is intended to
change the behavior of the pthread_sigmask module only when threadlib is
avoided.

>From c1a4cc57601f5942316e624c58495750cc207b1f Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sat, 16 Jul 2011 02:59:43 -0700
Subject: [PATCH 1/2] 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.
---
 ChangeLog   |    4 ++++
 gnulib-tool |    7 +++++++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 97a28f0..0fe213b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-07-16  Paul Eggert  <address@hidden>
 
+       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/gnulib-tool b/gnulib-tool
index 2235cf9..a0a3234 100755
--- a/gnulib-tool
+++ b/gnulib-tool
@@ -5116,6 +5116,13 @@ s,//*$,/,'
     echo "# In projects that use version control, this file can be treated 
like"
     echo "# other built files."
     echo
+    if test -n "$avoidlist"; then
+      echo
+      echo "# Record modules that were avoided."
+      for avoid in $avoidlist; do
+        echo "AC_DEFUN([gl_AVOID_MODULE_$avoid])"
+      done
+    fi
     echo
     echo "# This macro should be invoked from $configure_ac, in the section"
     echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly 
before"
-- 
1.7.4.4


>From 1a7ddbd5614947510d8856a7451ffa9e7b334e6c Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Sat, 16 Jul 2011 03:03:45 -0700
Subject: [PATCH 2/2] 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.
---
 ChangeLog             |    6 +++
 m4/pthread_sigmask.m4 |  106 ++++++++++++++++++++++++++++--------------------
 2 files changed, 68 insertions(+), 44 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0fe213b..0a6da93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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.
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
index 3803988..53f7c83 100644
--- a/m4/pthread_sigmask.m4
+++ b/m4/pthread_sigmask.m4
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 10
+# pthread_sigmask.m4 serial 11
 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,74 @@ 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
+
+  m4_ifdef([gl_AVOID_MODULE_threadlib], [
+    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
-      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
-        fi
-      else
-        dnl pthread_sigmask is not available at all.
-        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
-  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
+  ],[
+    dnl Assume threadlib.
+    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
+      fi
     else
-      HAVE_PTHREAD_SIGMASK=0
+      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
-  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
-- 
1.7.4.4




reply via email to

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