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: Bruno Haible
Subject: Re: [PATCH 03/10] pthread_sigmask: new module
Date: Sat, 9 Jul 2011 01:02:34 +0200
User-agent: KMail/1.9.9

On Cygwin 1.7.5, the tests fail:

test-pthread_sigmask1.c:56: assertion failed
FAIL: test-pthread_sigmask1.exe
test-pthread_sigmask2.c:63: assertion failed
FAIL: test-pthread_sigmask2.exe

This is because it has the wrong return value convention: pthread_sigmask
returns -1 and sets errno, contrary to what POSIX specifies.

This patch provides a workaround:


2011-07-08  Bruno Haible  <address@hidden>

        pthread_sigmask: Work around Cygwin bug.
        * m4/pthread_sigmask.m4 (gl_FUNC_PTHREAD_SIGMASK): Test for the Cygwin
        bug.
        * lib/pthread_sigmask.c (pthread_sigmask): Fix the return value from
        the system's pthread_sigmask function.
        * doc/posix-functions/pthread_sigmask.texi: Mention the Cygwin bug.

--- doc/posix-functions/pthread_sigmask.texi.orig       Sat Jul  9 00:59:27 2011
+++ doc/posix-functions/pthread_sigmask.texi    Sat Jul  9 00:59:05 2011
@@ -19,6 +19,10 @@
 This function does nothing and always returns 0 in programs that are not
 linked with @code{-lpthread} on some platforms:
 FreeBSD 6.4, HP-UX 11.31, Solaris 9.
address@hidden
+When it fails, this functions returns -1 instead of the error number on
+some platforms:
+Cygwin 1.7.5.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- lib/pthread_sigmask.c.orig  Sat Jul  9 00:59:27 2011
+++ lib/pthread_sigmask.c       Sat Jul  9 00:46:25 2011
@@ -43,6 +43,10 @@
         }
     }
 # endif
+# if PTHREAD_SIGMASK_FAILS_WITH_ERRNO
+  if (ret == -1)
+    return errno;
+# endif
   return ret;
 #else
   int ret = sigprocmask (how, new_mask, old_mask);
--- m4/pthread_sigmask.m4.orig  Sat Jul  9 00:59:27 2011
+++ m4/pthread_sigmask.m4       Sat Jul  9 00:45:45 2011
@@ -119,6 +119,46 @@
           ;;
       esac
     fi
+
+    dnl On Cygwin 1.7.5, the pthread_sigmask() has a wrong return value
+    dnl convention: Upon failure, it returns -1 and sets errno.
+    AC_CACHE_CHECK([whether pthread_sigmask returns error numbers],
+      [gl_cv_func_pthread_sigmask_return_works],
+      [
+        gl_save_LIBS="$LIBS"
+        LIBS="$LIBS $LIB_PTHREAD_SIGMASK"
+        AC_RUN_IFELSE(
+          [AC_LANG_SOURCE([[
+#include <pthread.h>
+#include <signal.h>
+#include <stddef.h>
+int main ()
+{
+  sigset_t set;
+  sigemptyset (&set);
+  if (pthread_sigmask (1729, &set, NULL) == -1)
+    return 1;
+  return 0;
+}]])],
+          [gl_cv_func_pthread_sigmask_return_works=yes],
+          [gl_cv_func_pthread_sigmask_return_works=no],
+          [case "$host_os" in
+             cygwin*)
+               gl_cv_func_pthread_sigmask_return_works="guessing no";;
+             *)
+               gl_cv_func_pthread_sigmask_return_works="guessing yes";;
+           esac
+          ])
+        LIBS="$gl_save_LIBS"
+      ])
+    case "$gl_cv_func_pthread_sigmask_return_works" in
+      *no)
+        REPLACE_PTHREAD_SIGMASK=1
+        AC_DEFINE([PTHREAD_SIGMASK_FAILS_WITH_ERRNO], [1],
+          [Define to 1 if pthread_mask(), when it fails, returns -1 and sets 
errno.])
+        ;;
+    esac
+
   fi
 ])
 
-- 
In memoriam Jean Moulin <http://en.wikipedia.org/wiki/Jean_Moulin>



reply via email to

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