summaryrefslogtreecommitdiff
path: root/lib/pthread_sigmask.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-07-24 15:15:47 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-07-24 15:15:47 -0700
commit24e0f6b1dc721a919814b226834a4d027e9f90d0 (patch)
treeeb3edef13fd2275ab655eba6b83983b2e5513b0d /lib/pthread_sigmask.c
parentf25e39b45a5960f8f2bff6c43f88833bc04540a9 (diff)
Merge from gnulib, using build-aux to remove clutter.
* m4/largefile.m4: New file, so that Emacs does not mess up when accessing files with large inode numbers in MacOS X 10.5 and later. * m4/nocrash.m4: New file, to avoid triggering background debugger and/or create core dumps during 'configure'. * build-aux/move-if-change: Renamed from move-if-change. * build-aux/snippet/arg-nonnull.h: Renamed from arg-nonnull.h. * build-aux/snippet/c++defs.h: Renamed from c++defs.h. * build-aux/snippet/warn-on-use.h: Renamed from warn-on-use.h. * build-aux/snippet/_Noreturn.h: New file, for draft C1X _Noreturn. * .bzrignore: The autogenerated files compile, config.guess, config.sub, depcomp, install-sh, and missing are now in build-aux. * Makefile.in (epaths-force, sync-from-gnulib): move-if-change is now in build-aux. (GNULIB_TOOL_FLAGS): Avoid threadlib; this is now a prerequisite of gnulib's pthread_sigmask module, but Emacs doesn't need it. (mkdir): install-sh is now in build-aux. * config.bat: c++defs.h is now in build-aux/snippets. * configure.in: Specify AC_CONFIG_AUX_DIR with build-aux (the usual parameter). * lib/gnulib.mk, m4/gl-comp.m4: Regenerate. * lib/makefile.w32-in (ARG_NONNULL_H): arg-nonnull.h moved to build-aux/snippet. * lib/pthread_sigmask.c, lib/stdlib.in.h, m4/extensions.m4: * m4/getopt.m4, m4/gnulib-common.m4, m4/pthread_sigmask.m4: Merge from gnuilib. This fixes porting bugs on Cygwin, Irix, and Solaris, enables MacOS extensions, and enables nocrash during 'configure'. * make-dist: Adjust to new build-aux and build-aux/snippit dirs. * admin/notes/copyright: The files compile, config.guess, config.sub, depcomp, install-sh, missing, and move-if-change are now in the new build-aux subdirectory. The files arg-nonnull.h, c++defs.h, and warn-on-use.h are now in build-aux/snippets. New file build-aux/snippets/_Noreturn.h. * leim/Makefile.in (install): install-sh is now in build-aux. * lib-src/Makefile.in ($(DESTDIR)${archlibdir}): install-sh moved to build-aux. * msdos/sedlibmk.inp (CONFIG_CLEAN_VPATH_FILES): Adjust to snippet moves from top level to build-aux/snippet. * src/Makefile.in (gl-stamp): move-if-change is now in build-aux.
Diffstat (limited to 'lib/pthread_sigmask.c')
-rw-r--r--lib/pthread_sigmask.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/pthread_sigmask.c b/lib/pthread_sigmask.c
index 1f460f13c4..11d549cad4 100644
--- a/lib/pthread_sigmask.c
+++ b/lib/pthread_sigmask.c
@@ -20,10 +20,50 @@
#include <signal.h>
#include <errno.h>
+#include <stddef.h>
+
+#if PTHREAD_SIGMASK_UNBLOCK_BUG
+# include <unistd.h>
+#endif
int
pthread_sigmask (int how, const sigset_t *new_mask, sigset_t *old_mask)
+#undef pthread_sigmask
{
+#if HAVE_PTHREAD_SIGMASK
+ int ret = pthread_sigmask (how, new_mask, old_mask);
+# if PTHREAD_SIGMASK_INEFFECTIVE
+ if (ret == 0)
+ {
+ /* Detect whether pthread_sigmask is currently ineffective.
+ Don't cache the information: libpthread.so could be dynamically
+ loaded after the program started and after pthread_sigmask was
+ called for the first time. */
+ if (pthread_sigmask (1729, NULL, NULL) == 0)
+ {
+ /* pthread_sigmask is currently ineffective. The program is not
+ linked to -lpthread. So use sigprocmask instead. */
+ return (sigprocmask (how, new_mask, old_mask) < 0 ? errno : 0);
+ }
+ }
+# endif
+# if PTHREAD_SIGMASK_FAILS_WITH_ERRNO
+ if (ret == -1)
+ return errno;
+# endif
+# if PTHREAD_SIGMASK_UNBLOCK_BUG
+ if (ret == 0
+ && new_mask != NULL
+ && (how == SIG_UNBLOCK || how == SIG_SETMASK))
+ {
+ /* Give the OS the opportunity to raise signals that were pending before
+ the pthread_sigmask call and have now been unblocked. */
+ usleep (1);
+ }
+# endif
+ return ret;
+#else
int ret = sigprocmask (how, new_mask, old_mask);
return (ret < 0 ? errno : 0);
+#endif
}