bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH 03/10] pthread_sigmask: new module


From: Paul Eggert
Subject: Re: [PATCH 03/10] pthread_sigmask: new module
Date: Fri, 08 Jul 2011 11:00:59 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10

Thanks for that review, and for fixing all those problems.
I noticed a couple of issues.  First, there's what appears
to be a clear typo in the gl_THREADLIB case: it is searching
for pthread_sigmask in a library, but it's using
AC_COMPILE_IFELSE.  Surely that should be AC_LINK_IFELSE.
(I haven't tested this, since Emacs is not using gl_THREADLIB.)

Second, when gl_THREADLIB is not in use, but the application
is using pthread_sigmask, the application is most likely using
POSIX threads, not no threading at all.  This is the case with
Emacs: on GNU/Linux it almost invariably uses threading, due
to the libraries that it employs (e.g., GTK3), even though
Emacs proper is not multithreaded yet.  In this case, Emacs
should be using pthread_sigmask and not sigprocmask, because
it doesn't want its mask settings to affect whatever subthreads
are spun off by its libraries.

I just now pushed the following two patches to try to address
these problems.  Further comments and fixes are welcome.

>From 63e6bc734f194ef125777cfae90b63b4c229c729 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 8 Jul 2011 10:45:41 -0700
Subject: [PATCH 1/2] pthread_sigmask: fix typo when testing for libraries

* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
AC_LINK_IFELSE, not AC_COMPILE_IFELSE.
---
 ChangeLog             |    6 ++++++
 m4/pthread_sigmask.m4 |    4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 39dbe48..cffcb04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2011-07-08  Paul Eggert  <address@hidden>
+
+       pthread_sigmask: fix typo when testing for libraries
+       * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
+       AC_LINK_IFELSE, not AC_COMPILE_IFELSE.
+
 2011-07-08  Eric Blake  <address@hidden>
 
        fts: introduce FTS_NOATIME
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
index 984f69d..80ac4c5 100644
--- a/m4/pthread_sigmask.m4
+++ b/m4/pthread_sigmask.m4
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 5
+# pthread_sigmask.m4 serial 6
 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,
@@ -20,7 +20,7 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK],
             [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD],
             [gl_save_LIBS="$LIBS"
              LIBS="$LIBS $LIBMULTITHREAD"
-             AC_COMPILE_IFELSE(
+             AC_LINK_IFELSE(
                [AC_LANG_PROGRAM(
                   [[#include <pthread.h>
                     #include <signal.h>
-- 
1.7.4.4


>From 494d3aa1577e0fdba61271608af3d79e09a4330c Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 8 Jul 2011 10:49:07 -0700
Subject: [PATCH 2/2] pthread_sigmask: Assume POSIX when not gl_THREADLIB.

* m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
When gl_THREADLIB is not in use, assume that the POSIX sematics
are desired.  This is better for Emacs, which uses POSIX semantics
on GNUish and/or POSIXish platforms, and does not use threads at
all otherwise.
---
 ChangeLog             |    7 +++++++
 m4/pthread_sigmask.m4 |   19 ++++++++++++-------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cffcb04..cd3fce3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-07-08  Paul Eggert  <address@hidden>
 
+       pthread_sigmask: Assume POSIX when not gl_THREADLIB.
+       * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
+       When gl_THREADLIB is not in use, assume that the POSIX sematics
+       are desired.  This is better for Emacs, which uses POSIX semantics
+       on GNUish and/or POSIXish platforms, and does not use threads at
+       all otherwise.
+
        pthread_sigmask: fix typo when testing for libraries
        * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK):
        AC_LINK_IFELSE, not AC_COMPILE_IFELSE.
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4
index 80ac4c5..dfa0f66 100644
--- a/m4/pthread_sigmask.m4
+++ b/m4/pthread_sigmask.m4
@@ -1,4 +1,4 @@
-# pthread_sigmask.m4 serial 6
+# pthread_sigmask.m4 serial 7
 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,
@@ -57,12 +57,17 @@ AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK],
       fi
     fi
   ] ,[
-    dnl If module 'threadlib' is not in use, assume all programs will be
-    dnl single-threaded.
-    if test $ac_cv_func_pthread_sigmask = yes; then
-      REPLACE_PTHREAD_SIGMASK=1
-    else
-      HAVE_PTHREAD_SIGMASK=0
+    dnl gl_THREADLIB is not in use.  Assume the application wants
+    dnl POSIX semantics.
+    if test $ac_cv_func_pthread_sigmask != yes; then
+      gl_save_LIBS=$LIBS
+      AC_SEARCH_LIBS([pthread_sigmask], [pthread c_r])
+      LIBS=$gl_save_LIBS
+      if test "$ac_cv_search_pthread_sigmask" = no; then
+        HAVE_PTHREAD_SIGMASK=0
+      elif test "$ac_cv_search_pthread_sigmask" != 'none required'; then
+        LIB_PTHREAD_SIGMASK=$ac_cv_search_pthread_sigmask
+      fi
     fi
   ])
   AC_SUBST([LIB_PTHREAD_SIGMASK])
-- 
1.7.4.4




reply via email to

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