Mercurial > hg > octave-jordi > gnulib-hg
changeset 15383:2fb7d8364951
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.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 09 Jul 2011 01:01:36 +0200 |
parents | 16995a7f1514 |
children | 2187b5650eca |
files | ChangeLog doc/posix-functions/pthread_sigmask.texi lib/pthread_sigmask.c m4/pthread_sigmask.m4 |
diffstat | 4 files changed, 57 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2011-07-08 Bruno Haible <bruno@clisp.org> + + 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. + 2011-07-08 Bruno Haible <bruno@clisp.org> pthread_sigmask: Work around bug in single-threaded implementation.
--- a/doc/posix-functions/pthread_sigmask.texi +++ b/doc/posix-functions/pthread_sigmask.texi @@ -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. +@item +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:
--- a/lib/pthread_sigmask.c +++ b/lib/pthread_sigmask.c @@ -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);
--- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 @@ -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 ])