diff options
| author | Paul Eggert | 2011-07-08 13:20:19 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-07-08 13:20:19 -0700 |
| commit | 2a84b02da8b20138fad7fafdea92d7c8f0564ee0 (patch) | |
| tree | da64c1fd303aa85b53ad485779b05fbdd2685a28 | |
| parent | 1692ae2dd5ff8f6f1fc6f6f62b9a44ab7e615615 (diff) | |
| download | emacs-2a84b02da8b20138fad7fafdea92d7c8f0564ee0.tar.gz emacs-2a84b02da8b20138fad7fafdea92d7c8f0564ee0.zip | |
Simplify Emacs part of pthread_sigmask support.
* Makefile.in (GNULIB_TOOL_FLAGS): Do not avoid sigprocmask.
* configure.in (AC_TYPE_UID_T): New dummy macro.
Configure gnulib after adjusting LIBS,
so that gnulib can assume the libraries in LIBS.
* lib/pthread_sigmask.c, lib/sigprocmask.c, m4/signalblocking.m4:
New files, automatically imported from gnulib.
* lib/gnulib.mk, m4/gl-comp.m4: Regenerate.
* src/Makefile.in (LIB_PTHREAD_SIGMASK): New macro.
(LIBES): Use it.
| -rw-r--r-- | ChangeLog | 10 | ||||
| -rw-r--r-- | Makefile.in | 1 | ||||
| -rw-r--r-- | configure.in | 11 | ||||
| -rw-r--r-- | lib/getopt.c | 11 | ||||
| -rw-r--r-- | lib/gnulib.mk | 23 | ||||
| -rw-r--r-- | lib/pthread_sigmask.c | 29 | ||||
| -rw-r--r-- | lib/signal.in.h | 44 | ||||
| -rw-r--r-- | lib/sigprocmask.c | 329 | ||||
| -rw-r--r-- | lib/unistd.in.h | 141 | ||||
| -rw-r--r-- | m4/getopt.m4 | 83 | ||||
| -rw-r--r-- | m4/gl-comp.m4 | 25 | ||||
| -rw-r--r-- | m4/pthread_sigmask.m4 | 77 | ||||
| -rw-r--r-- | m4/signal_h.m4 | 3 | ||||
| -rw-r--r-- | m4/signalblocking.m4 | 25 | ||||
| -rw-r--r-- | src/Makefile.in | 4 |
15 files changed, 677 insertions, 139 deletions
| @@ -2,15 +2,17 @@ | |||
| 2 | 2 | ||
| 3 | Add gnulib support for pthread_sigmask (Bug#9010). | 3 | Add gnulib support for pthread_sigmask (Bug#9010). |
| 4 | * Makefile.in (GNULIB_MODULES): Add pthread_sigmask. | 4 | * Makefile.in (GNULIB_MODULES): Add pthread_sigmask. |
| 5 | (GNULIB_TOOL_FLAGS): Avoid sigprocmask. Emacs does its own | 5 | * configure.in (AC_TYPE_UID_T): New dummy macro. |
| 6 | implementation of 'sigprocmask' on Windows, and it assumes | 6 | Configure gnulib after adjusting LIBS, |
| 7 | 'sigprocmask' on non-Windows hosts, so it doesn't need the | 7 | so that gnulib can assume the libraries in LIBS. |
| 8 | sigprocmask module. | ||
| 9 | * lib/signal.in.h, m4/pthread_sigmask.m4, m4/signal_h.m4: | 8 | * lib/signal.in.h, m4/pthread_sigmask.m4, m4/signal_h.m4: |
| 9 | * lib/pthread_sigprocmask.c, lib/sigprocmask.c, m4/signalblocking.m4: | ||
| 10 | New files, automatically imported from gnulib. | 10 | New files, automatically imported from gnulib. |
| 11 | * lib/gnulib.mk, m4/gl-comp.m4: Automatically-imported update | 11 | * lib/gnulib.mk, m4/gl-comp.m4: Automatically-imported update |
| 12 | due to the above changes. | 12 | due to the above changes. |
| 13 | * .bzrignore: Add lib/signal.h. | 13 | * .bzrignore: Add lib/signal.h. |
| 14 | * src/Makefile.in (LIB_PTHREAD_SIGMASK): New macro. | ||
| 15 | (LIBES): Use it. | ||
| 14 | 16 | ||
| 15 | 2011-07-07 Andreas Schwab <schwab@linux-m68k.org> | 17 | 2011-07-07 Andreas Schwab <schwab@linux-m68k.org> |
| 16 | 18 | ||
diff --git a/Makefile.in b/Makefile.in index 07a2c6a017d..a3d85bad22a 100644 --- a/Makefile.in +++ b/Makefile.in | |||
| @@ -339,7 +339,6 @@ GNULIB_MODULES = \ | |||
| 339 | mktime pthread_sigmask readlink \ | 339 | mktime pthread_sigmask readlink \ |
| 340 | socklen stdarg stdio strftime strtoumax symlink sys_stat | 340 | socklen stdarg stdio strftime strtoumax symlink sys_stat |
| 341 | GNULIB_TOOL_FLAGS = \ | 341 | GNULIB_TOOL_FLAGS = \ |
| 342 | --avoid=sigprocmask \ | ||
| 343 | --conditional-dependencies --import --no-changelog --no-vc-files \ | 342 | --conditional-dependencies --import --no-changelog --no-vc-files \ |
| 344 | --makefile-name=gnulib.mk | 343 | --makefile-name=gnulib.mk |
| 345 | sync-from-gnulib: $(gnulib_srcdir) | 344 | sync-from-gnulib: $(gnulib_srcdir) |
diff --git a/configure.in b/configure.in index 5014a793a85..3dd1f035d2b 100644 --- a/configure.in +++ b/configure.in | |||
| @@ -984,6 +984,8 @@ fi | |||
| 984 | 984 | ||
| 985 | # Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better. | 985 | # Suppress obsolescent Autoconf test for size_t; Emacs assumes C89 or better. |
| 986 | AC_DEFUN([AC_TYPE_SIZE_T]) | 986 | AC_DEFUN([AC_TYPE_SIZE_T]) |
| 987 | # Likewise for obsolescent test for uid_t, gid_t; Emacs assumes them. | ||
| 988 | AC_DEFUN([AC_TYPE_UID_T]) | ||
| 987 | 989 | ||
| 988 | dnl Do this early because it can frob feature test macros for Unix-98 &c. | 990 | dnl Do this early because it can frob feature test macros for Unix-98 &c. |
| 989 | AC_SYS_LARGEFILE | 991 | AC_SYS_LARGEFILE |
| @@ -2725,11 +2727,6 @@ AC_FUNC_FSEEKO | |||
| 2725 | 2727 | ||
| 2726 | AC_FUNC_GETPGRP | 2728 | AC_FUNC_GETPGRP |
| 2727 | 2729 | ||
| 2728 | # Configure gnulib. | ||
| 2729 | gl_ASSERT_NO_GNULIB_POSIXCHECK | ||
| 2730 | gl_ASSERT_NO_GNULIB_TESTS | ||
| 2731 | gl_INIT | ||
| 2732 | |||
| 2733 | # UNIX98 PTYs. | 2730 | # UNIX98 PTYs. |
| 2734 | AC_CHECK_FUNCS(grantpt) | 2731 | AC_CHECK_FUNCS(grantpt) |
| 2735 | 2732 | ||
| @@ -3333,6 +3330,10 @@ AC_SUBST(CYGWIN_OBJ) | |||
| 3333 | AC_SUBST(PRE_ALLOC_OBJ) | 3330 | AC_SUBST(PRE_ALLOC_OBJ) |
| 3334 | AC_SUBST(POST_ALLOC_OBJ) | 3331 | AC_SUBST(POST_ALLOC_OBJ) |
| 3335 | 3332 | ||
| 3333 | # Configure gnulib here, now that we know LIBS. | ||
| 3334 | gl_ASSERT_NO_GNULIB_POSIXCHECK | ||
| 3335 | gl_ASSERT_NO_GNULIB_TESTS | ||
| 3336 | gl_INIT | ||
| 3336 | 3337 | ||
| 3337 | case "$opsys" in | 3338 | case "$opsys" in |
| 3338 | aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;; | 3339 | aix4-2) LD_SWITCH_SYSTEM_TEMACS="-Wl,-bnodelcsect" ;; |
diff --git a/lib/getopt.c b/lib/getopt.c index 2af8352ee9c..7c9f7040612 100644 --- a/lib/getopt.c +++ b/lib/getopt.c | |||
| @@ -829,7 +829,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 829 | return '?'; | 829 | return '?'; |
| 830 | } | 830 | } |
| 831 | /* Convenience. Treat POSIX -W foo same as long option --foo */ | 831 | /* Convenience. Treat POSIX -W foo same as long option --foo */ |
| 832 | if (temp[0] == 'W' && temp[1] == ';' && longopts) | 832 | if (temp[0] == 'W' && temp[1] == ';') |
| 833 | { | 833 | { |
| 834 | char *nameend; | 834 | char *nameend; |
| 835 | const struct option *p; | 835 | const struct option *p; |
| @@ -839,6 +839,9 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 839 | int indfound = 0; | 839 | int indfound = 0; |
| 840 | int option_index; | 840 | int option_index; |
| 841 | 841 | ||
| 842 | if (longopts == NULL) | ||
| 843 | goto no_longs; | ||
| 844 | |||
| 842 | /* This is an option that requires an argument. */ | 845 | /* This is an option that requires an argument. */ |
| 843 | if (*d->__nextchar != '\0') | 846 | if (*d->__nextchar != '\0') |
| 844 | { | 847 | { |
| @@ -1046,8 +1049,10 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, | |||
| 1046 | } | 1049 | } |
| 1047 | return pfound->val; | 1050 | return pfound->val; |
| 1048 | } | 1051 | } |
| 1049 | d->__nextchar = NULL; | 1052 | |
| 1050 | return 'W'; /* Let the application handle it. */ | 1053 | no_longs: |
| 1054 | d->__nextchar = NULL; | ||
| 1055 | return 'W'; /* Let the application handle it. */ | ||
| 1051 | } | 1056 | } |
| 1052 | if (temp[1] == ':') | 1057 | if (temp[1] == ':') |
| 1053 | { | 1058 | { |
diff --git a/lib/gnulib.mk b/lib/gnulib.mk index 88a7919b7af..25647f0399c 100644 --- a/lib/gnulib.mk +++ b/lib/gnulib.mk | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | # the same distribution terms as the rest of that program. | 9 | # the same distribution terms as the rest of that program. |
| 10 | # | 10 | # |
| 11 | # Generated by gnulib-tool. | 11 | # Generated by gnulib-tool. |
| 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --avoid=sigprocmask --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoumax symlink sys_stat | 12 | # Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt careadlinkat crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dup2 filemode getloadavg getopt-gnu ignore-value intprops lstat mktime pthread_sigmask readlink socklen stdarg stdio strftime strtoumax symlink sys_stat |
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | MOSTLYCLEANFILES += core *.stackdump | 15 | MOSTLYCLEANFILES += core *.stackdump |
| @@ -294,6 +294,15 @@ EXTRA_libgnu_a_SOURCES += mktime.c | |||
| 294 | 294 | ||
| 295 | ## end gnulib module mktime | 295 | ## end gnulib module mktime |
| 296 | 296 | ||
| 297 | ## begin gnulib module pthread_sigmask | ||
| 298 | |||
| 299 | |||
| 300 | EXTRA_DIST += pthread_sigmask.c | ||
| 301 | |||
| 302 | EXTRA_libgnu_a_SOURCES += pthread_sigmask.c | ||
| 303 | |||
| 304 | ## end gnulib module pthread_sigmask | ||
| 305 | |||
| 297 | ## begin gnulib module readlink | 306 | ## begin gnulib module readlink |
| 298 | 307 | ||
| 299 | 308 | ||
| @@ -322,6 +331,7 @@ signal.h: signal.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H | |||
| 322 | -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ | 331 | -e 's/@''GNULIB_SIGPROCMASK''@/$(GNULIB_SIGPROCMASK)/g' \ |
| 323 | -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ | 332 | -e 's/@''GNULIB_SIGACTION''@/$(GNULIB_SIGACTION)/g' \ |
| 324 | -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ | 333 | -e 's|@''HAVE_POSIX_SIGNALBLOCKING''@|$(HAVE_POSIX_SIGNALBLOCKING)|g' \ |
| 334 | -e 's|@''HAVE_PTHREAD_SIGMASK''@|$(HAVE_PTHREAD_SIGMASK)|g' \ | ||
| 325 | -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ | 335 | -e 's|@''HAVE_SIGSET_T''@|$(HAVE_SIGSET_T)|g' \ |
| 326 | -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ | 336 | -e 's|@''HAVE_SIGINFO_T''@|$(HAVE_SIGINFO_T)|g' \ |
| 327 | -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ | 337 | -e 's|@''HAVE_SIGACTION''@|$(HAVE_SIGACTION)|g' \ |
| @@ -341,6 +351,17 @@ EXTRA_DIST += signal.in.h | |||
| 341 | 351 | ||
| 342 | ## end gnulib module signal | 352 | ## end gnulib module signal |
| 343 | 353 | ||
| 354 | ## begin gnulib module sigprocmask | ||
| 355 | |||
| 356 | if gl_GNULIB_ENABLED_sigprocmask | ||
| 357 | |||
| 358 | endif | ||
| 359 | EXTRA_DIST += sigprocmask.c | ||
| 360 | |||
| 361 | EXTRA_libgnu_a_SOURCES += sigprocmask.c | ||
| 362 | |||
| 363 | ## end gnulib module sigprocmask | ||
| 364 | |||
| 344 | ## begin gnulib module stat | 365 | ## begin gnulib module stat |
| 345 | 366 | ||
| 346 | if gl_GNULIB_ENABLED_stat | 367 | if gl_GNULIB_ENABLED_stat |
diff --git a/lib/pthread_sigmask.c b/lib/pthread_sigmask.c new file mode 100644 index 00000000000..1f460f13c48 --- /dev/null +++ b/lib/pthread_sigmask.c | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | /* POSIX compatible signal blocking for threads. | ||
| 2 | Copyright (C) 2011 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation; either version 3 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 16 | |||
| 17 | #include <config.h> | ||
| 18 | |||
| 19 | /* Specification. */ | ||
| 20 | #include <signal.h> | ||
| 21 | |||
| 22 | #include <errno.h> | ||
| 23 | |||
| 24 | int | ||
| 25 | pthread_sigmask (int how, const sigset_t *new_mask, sigset_t *old_mask) | ||
| 26 | { | ||
| 27 | int ret = sigprocmask (how, new_mask, old_mask); | ||
| 28 | return (ret < 0 ? errno : 0); | ||
| 29 | } | ||
diff --git a/lib/signal.in.h b/lib/signal.in.h index 01987a7aff1..93787f753fa 100644 --- a/lib/signal.in.h +++ b/lib/signal.in.h | |||
| @@ -20,8 +20,17 @@ | |||
| 20 | #endif | 20 | #endif |
| 21 | @PRAGMA_COLUMNS@ | 21 | @PRAGMA_COLUMNS@ |
| 22 | 22 | ||
| 23 | #if defined __need_sig_atomic_t || defined __need_sigset_t | 23 | #if defined __need_sig_atomic_t || defined __need_sigset_t || defined _GL_ALREADY_INCLUDING_SIGNAL_H || (defined _SIGNAL_H && !defined __SIZEOF_PTHREAD_MUTEX_T) |
| 24 | /* Special invocation convention inside glibc header files. */ | 24 | /* Special invocation convention: |
| 25 | - Inside glibc header files. | ||
| 26 | - On glibc systems we have a sequence of nested includes | ||
| 27 | <signal.h> -> <ucontext.h> -> <signal.h>. | ||
| 28 | In this situation, the functions are not yet declared, therefore we cannot | ||
| 29 | provide the C++ aliases. | ||
| 30 | - On glibc systems with GCC 4.3 we have a sequence of nested includes | ||
| 31 | <csignal> -> </usr/include/signal.h> -> <sys/ucontext.h> -> <signal.h>. | ||
| 32 | In this situation, some of the functions are not yet declared, therefore | ||
| 33 | we cannot provide the C++ aliases. */ | ||
| 25 | 34 | ||
| 26 | # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@ | 35 | # @INCLUDE_NEXT@ @NEXT_SIGNAL_H@ |
| 27 | 36 | ||
| @@ -30,6 +39,8 @@ | |||
| 30 | 39 | ||
| 31 | #ifndef _@GUARD_PREFIX@_SIGNAL_H | 40 | #ifndef _@GUARD_PREFIX@_SIGNAL_H |
| 32 | 41 | ||
| 42 | #define _GL_ALREADY_INCLUDING_SIGNAL_H | ||
| 43 | |||
| 33 | /* Define pid_t, uid_t. | 44 | /* Define pid_t, uid_t. |
| 34 | Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. | 45 | Also, mingw defines sigset_t not in <signal.h>, but in <sys/types.h>. |
| 35 | On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes | 46 | On Solaris 10, <signal.h> includes <sys/types.h>, which eventually includes |
| @@ -39,9 +50,20 @@ | |||
| 39 | /* The include_next requires a split double-inclusion guard. */ | 50 | /* The include_next requires a split double-inclusion guard. */ |
| 40 | #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ | 51 | #@INCLUDE_NEXT@ @NEXT_SIGNAL_H@ |
| 41 | 52 | ||
| 53 | #undef _GL_ALREADY_INCLUDING_SIGNAL_H | ||
| 54 | |||
| 42 | #ifndef _@GUARD_PREFIX@_SIGNAL_H | 55 | #ifndef _@GUARD_PREFIX@_SIGNAL_H |
| 43 | #define _@GUARD_PREFIX@_SIGNAL_H | 56 | #define _@GUARD_PREFIX@_SIGNAL_H |
| 44 | 57 | ||
| 58 | /* MacOS X 10.3, FreeBSD 6.4, OpenBSD 3.8, OSF/1 4.0, Solaris 2.6 declare | ||
| 59 | pthread_sigmask in <pthread.h>, not in <signal.h>. | ||
| 60 | But avoid namespace pollution on glibc systems.*/ | ||
| 61 | #if (@GNULIB_PTHREAD_SIGMASK@ || defined GNULIB_POSIXCHECK) \ | ||
| 62 | && ((defined __APPLE__ && defined __MACH__) || defined __FreeBSD__ || defined __OpenBSD__ || defined __osf__ || defined __sun) \ | ||
| 63 | && ! defined __GLIBC__ | ||
| 64 | # include <pthread.h> | ||
| 65 | #endif | ||
| 66 | |||
| 45 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | 67 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
| 46 | 68 | ||
| 47 | /* The definition of _GL_ARG_NONNULL is copied here. */ | 69 | /* The definition of _GL_ARG_NONNULL is copied here. */ |
| @@ -104,9 +126,23 @@ typedef void (*sighandler_t) (int); | |||
| 104 | 126 | ||
| 105 | #if @GNULIB_PTHREAD_SIGMASK@ | 127 | #if @GNULIB_PTHREAD_SIGMASK@ |
| 106 | # if @REPLACE_PTHREAD_SIGMASK@ | 128 | # if @REPLACE_PTHREAD_SIGMASK@ |
| 107 | # undef pthread_sigmask | 129 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 108 | # define pthread_sigmask sigprocmask | 130 | # undef pthread_sigmask |
| 131 | # define pthread_sigmask rpl_pthread_sigmask | ||
| 132 | # endif | ||
| 133 | _GL_FUNCDECL_RPL (pthread_sigmask, int, | ||
| 134 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); | ||
| 135 | _GL_CXXALIAS_RPL (pthread_sigmask, int, | ||
| 136 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); | ||
| 137 | # else | ||
| 138 | # if !@HAVE_PTHREAD_SIGMASK@ | ||
| 139 | _GL_FUNCDECL_SYS (pthread_sigmask, int, | ||
| 140 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); | ||
| 141 | # endif | ||
| 142 | _GL_CXXALIAS_SYS (pthread_sigmask, int, | ||
| 143 | (int how, const sigset_t *new_mask, sigset_t *old_mask)); | ||
| 109 | # endif | 144 | # endif |
| 145 | _GL_CXXALIASWARN (pthread_sigmask); | ||
| 110 | #elif defined GNULIB_POSIXCHECK | 146 | #elif defined GNULIB_POSIXCHECK |
| 111 | # undef pthread_sigmask | 147 | # undef pthread_sigmask |
| 112 | # if HAVE_RAW_DECL_PTHREAD_SIGMASK | 148 | # if HAVE_RAW_DECL_PTHREAD_SIGMASK |
diff --git a/lib/sigprocmask.c b/lib/sigprocmask.c new file mode 100644 index 00000000000..6780a37b14f --- /dev/null +++ b/lib/sigprocmask.c | |||
| @@ -0,0 +1,329 @@ | |||
| 1 | /* POSIX compatible signal blocking. | ||
| 2 | Copyright (C) 2006-2011 Free Software Foundation, Inc. | ||
| 3 | Written by Bruno Haible <bruno@clisp.org>, 2006. | ||
| 4 | |||
| 5 | This program is free software: you can redistribute it and/or modify | ||
| 6 | it under the terms of the GNU General Public License as published by | ||
| 7 | the Free Software Foundation; either version 3 of the License, or | ||
| 8 | (at your option) any later version. | ||
| 9 | |||
| 10 | This program is distributed in the hope that it will be useful, | ||
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | GNU General Public License for more details. | ||
| 14 | |||
| 15 | You should have received a copy of the GNU General Public License | ||
| 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 17 | |||
| 18 | #include <config.h> | ||
| 19 | |||
| 20 | /* Specification. */ | ||
| 21 | #include <signal.h> | ||
| 22 | |||
| 23 | #include <errno.h> | ||
| 24 | #include <stdint.h> | ||
| 25 | #include <stdlib.h> | ||
| 26 | |||
| 27 | /* We assume that a platform without POSIX signal blocking functions | ||
| 28 | also does not have the POSIX sigaction() function, only the | ||
| 29 | signal() function. We also assume signal() has SysV semantics, | ||
| 30 | where any handler is uninstalled prior to being invoked. This is | ||
| 31 | true for Woe32 platforms. */ | ||
| 32 | |||
| 33 | /* We use raw signal(), but also provide a wrapper rpl_signal() so | ||
| 34 | that applications can query or change a blocked signal. */ | ||
| 35 | #undef signal | ||
| 36 | |||
| 37 | /* Provide invalid signal numbers as fallbacks if the uncatchable | ||
| 38 | signals are not defined. */ | ||
| 39 | #ifndef SIGKILL | ||
| 40 | # define SIGKILL (-1) | ||
| 41 | #endif | ||
| 42 | #ifndef SIGSTOP | ||
| 43 | # define SIGSTOP (-1) | ||
| 44 | #endif | ||
| 45 | |||
| 46 | /* On native Windows, as of 2008, the signal SIGABRT_COMPAT is an alias | ||
| 47 | for the signal SIGABRT. Only one signal handler is stored for both | ||
| 48 | SIGABRT and SIGABRT_COMPAT. SIGABRT_COMPAT is not a signal of its own. */ | ||
| 49 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ | ||
| 50 | # undef SIGABRT_COMPAT | ||
| 51 | # define SIGABRT_COMPAT 6 | ||
| 52 | #endif | ||
| 53 | #ifdef SIGABRT_COMPAT | ||
| 54 | # define SIGABRT_COMPAT_MASK (1U << SIGABRT_COMPAT) | ||
| 55 | #else | ||
| 56 | # define SIGABRT_COMPAT_MASK 0 | ||
| 57 | #endif | ||
| 58 | |||
| 59 | typedef void (*handler_t) (int); | ||
| 60 | |||
| 61 | /* Handling of gnulib defined signals. */ | ||
| 62 | |||
| 63 | #if GNULIB_defined_SIGPIPE | ||
| 64 | static handler_t SIGPIPE_handler = SIG_DFL; | ||
| 65 | #endif | ||
| 66 | |||
| 67 | #if GNULIB_defined_SIGPIPE | ||
| 68 | static handler_t | ||
| 69 | ext_signal (int sig, handler_t handler) | ||
| 70 | { | ||
| 71 | switch (sig) | ||
| 72 | { | ||
| 73 | case SIGPIPE: | ||
| 74 | { | ||
| 75 | handler_t old_handler = SIGPIPE_handler; | ||
| 76 | SIGPIPE_handler = handler; | ||
| 77 | return old_handler; | ||
| 78 | } | ||
| 79 | default: /* System defined signal */ | ||
| 80 | return signal (sig, handler); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | # define signal ext_signal | ||
| 84 | #endif | ||
| 85 | |||
| 86 | int | ||
| 87 | sigismember (const sigset_t *set, int sig) | ||
| 88 | { | ||
| 89 | if (sig >= 0 && sig < NSIG) | ||
| 90 | { | ||
| 91 | #ifdef SIGABRT_COMPAT | ||
| 92 | if (sig == SIGABRT_COMPAT) | ||
| 93 | sig = SIGABRT; | ||
| 94 | #endif | ||
| 95 | |||
| 96 | return (*set >> sig) & 1; | ||
| 97 | } | ||
| 98 | else | ||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | int | ||
| 103 | sigemptyset (sigset_t *set) | ||
| 104 | { | ||
| 105 | *set = 0; | ||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | int | ||
| 110 | sigaddset (sigset_t *set, int sig) | ||
| 111 | { | ||
| 112 | if (sig >= 0 && sig < NSIG) | ||
| 113 | { | ||
| 114 | #ifdef SIGABRT_COMPAT | ||
| 115 | if (sig == SIGABRT_COMPAT) | ||
| 116 | sig = SIGABRT; | ||
| 117 | #endif | ||
| 118 | |||
| 119 | *set |= 1U << sig; | ||
| 120 | return 0; | ||
| 121 | } | ||
| 122 | else | ||
| 123 | { | ||
| 124 | errno = EINVAL; | ||
| 125 | return -1; | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | int | ||
| 130 | sigdelset (sigset_t *set, int sig) | ||
| 131 | { | ||
| 132 | if (sig >= 0 && sig < NSIG) | ||
| 133 | { | ||
| 134 | #ifdef SIGABRT_COMPAT | ||
| 135 | if (sig == SIGABRT_COMPAT) | ||
| 136 | sig = SIGABRT; | ||
| 137 | #endif | ||
| 138 | |||
| 139 | *set &= ~(1U << sig); | ||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | else | ||
| 143 | { | ||
| 144 | errno = EINVAL; | ||
| 145 | return -1; | ||
| 146 | } | ||
| 147 | } | ||
| 148 | |||
| 149 | |||
| 150 | int | ||
| 151 | sigfillset (sigset_t *set) | ||
| 152 | { | ||
| 153 | *set = ((2U << (NSIG - 1)) - 1) & ~ SIGABRT_COMPAT_MASK; | ||
| 154 | return 0; | ||
| 155 | } | ||
| 156 | |||
| 157 | /* Set of currently blocked signals. */ | ||
| 158 | static volatile sigset_t blocked_set /* = 0 */; | ||
| 159 | |||
| 160 | /* Set of currently blocked and pending signals. */ | ||
| 161 | static volatile sig_atomic_t pending_array[NSIG] /* = { 0 } */; | ||
| 162 | |||
| 163 | /* Signal handler that is installed for blocked signals. */ | ||
| 164 | static void | ||
| 165 | blocked_handler (int sig) | ||
| 166 | { | ||
| 167 | /* Reinstall the handler, in case the signal occurs multiple times | ||
| 168 | while blocked. There is an inherent race where an asynchronous | ||
| 169 | signal in between when the kernel uninstalled the handler and | ||
| 170 | when we reinstall it will trigger the default handler; oh | ||
| 171 | well. */ | ||
| 172 | signal (sig, blocked_handler); | ||
| 173 | if (sig >= 0 && sig < NSIG) | ||
| 174 | pending_array[sig] = 1; | ||
| 175 | } | ||
| 176 | |||
| 177 | int | ||
| 178 | sigpending (sigset_t *set) | ||
| 179 | { | ||
| 180 | sigset_t pending = 0; | ||
| 181 | int sig; | ||
| 182 | |||
| 183 | for (sig = 0; sig < NSIG; sig++) | ||
| 184 | if (pending_array[sig]) | ||
| 185 | pending |= 1U << sig; | ||
| 186 | *set = pending; | ||
| 187 | return 0; | ||
| 188 | } | ||
| 189 | |||
| 190 | /* The previous signal handlers. | ||
| 191 | Only the array elements corresponding to blocked signals are relevant. */ | ||
| 192 | static volatile handler_t old_handlers[NSIG]; | ||
| 193 | |||
| 194 | int | ||
| 195 | sigprocmask (int operation, const sigset_t *set, sigset_t *old_set) | ||
| 196 | { | ||
| 197 | if (old_set != NULL) | ||
| 198 | *old_set = blocked_set; | ||
| 199 | |||
| 200 | if (set != NULL) | ||
| 201 | { | ||
| 202 | sigset_t new_blocked_set; | ||
| 203 | sigset_t to_unblock; | ||
| 204 | sigset_t to_block; | ||
| 205 | |||
| 206 | switch (operation) | ||
| 207 | { | ||
| 208 | case SIG_BLOCK: | ||
| 209 | new_blocked_set = blocked_set | *set; | ||
| 210 | break; | ||
| 211 | case SIG_SETMASK: | ||
| 212 | new_blocked_set = *set; | ||
| 213 | break; | ||
| 214 | case SIG_UNBLOCK: | ||
| 215 | new_blocked_set = blocked_set & ~*set; | ||
| 216 | break; | ||
| 217 | default: | ||
| 218 | errno = EINVAL; | ||
| 219 | return -1; | ||
| 220 | } | ||
| 221 | to_unblock = blocked_set & ~new_blocked_set; | ||
| 222 | to_block = new_blocked_set & ~blocked_set; | ||
| 223 | |||
| 224 | if (to_block != 0) | ||
| 225 | { | ||
| 226 | int sig; | ||
| 227 | |||
| 228 | for (sig = 0; sig < NSIG; sig++) | ||
| 229 | if ((to_block >> sig) & 1) | ||
| 230 | { | ||
| 231 | pending_array[sig] = 0; | ||
| 232 | if ((old_handlers[sig] = signal (sig, blocked_handler)) != SIG_ERR) | ||
| 233 | blocked_set |= 1U << sig; | ||
| 234 | } | ||
| 235 | } | ||
| 236 | |||
| 237 | if (to_unblock != 0) | ||
| 238 | { | ||
| 239 | sig_atomic_t received[NSIG]; | ||
| 240 | int sig; | ||
| 241 | |||
| 242 | for (sig = 0; sig < NSIG; sig++) | ||
| 243 | if ((to_unblock >> sig) & 1) | ||
| 244 | { | ||
| 245 | if (signal (sig, old_handlers[sig]) != blocked_handler) | ||
| 246 | /* The application changed a signal handler while the signal | ||
| 247 | was blocked, bypassing our rpl_signal replacement. | ||
| 248 | We don't support this. */ | ||
| 249 | abort (); | ||
| 250 | received[sig] = pending_array[sig]; | ||
| 251 | blocked_set &= ~(1U << sig); | ||
| 252 | pending_array[sig] = 0; | ||
| 253 | } | ||
| 254 | else | ||
| 255 | received[sig] = 0; | ||
| 256 | |||
| 257 | for (sig = 0; sig < NSIG; sig++) | ||
| 258 | if (received[sig]) | ||
| 259 | raise (sig); | ||
| 260 | } | ||
| 261 | } | ||
| 262 | return 0; | ||
| 263 | } | ||
| 264 | |||
| 265 | /* Install the handler FUNC for signal SIG, and return the previous | ||
| 266 | handler. */ | ||
| 267 | handler_t | ||
| 268 | rpl_signal (int sig, handler_t handler) | ||
| 269 | { | ||
| 270 | /* We must provide a wrapper, so that a user can query what handler | ||
| 271 | they installed even if that signal is currently blocked. */ | ||
| 272 | if (sig >= 0 && sig < NSIG && sig != SIGKILL && sig != SIGSTOP | ||
| 273 | && handler != SIG_ERR) | ||
| 274 | { | ||
| 275 | #ifdef SIGABRT_COMPAT | ||
| 276 | if (sig == SIGABRT_COMPAT) | ||
| 277 | sig = SIGABRT; | ||
| 278 | #endif | ||
| 279 | |||
| 280 | if (blocked_set & (1U << sig)) | ||
| 281 | { | ||
| 282 | /* POSIX states that sigprocmask and signal are both | ||
| 283 | async-signal-safe. This is not true of our | ||
| 284 | implementation - there is a slight data race where an | ||
| 285 | asynchronous interrupt on signal A can occur after we | ||
| 286 | install blocked_handler but before we have updated | ||
| 287 | old_handlers for signal B, such that handler A can see | ||
| 288 | stale information if it calls signal(B). Oh well - | ||
| 289 | signal handlers really shouldn't try to manipulate the | ||
| 290 | installed handlers of unrelated signals. */ | ||
| 291 | handler_t result = old_handlers[sig]; | ||
| 292 | old_handlers[sig] = handler; | ||
| 293 | return result; | ||
| 294 | } | ||
| 295 | else | ||
| 296 | return signal (sig, handler); | ||
| 297 | } | ||
| 298 | else | ||
| 299 | { | ||
| 300 | errno = EINVAL; | ||
| 301 | return SIG_ERR; | ||
| 302 | } | ||
| 303 | } | ||
| 304 | |||
| 305 | #if GNULIB_defined_SIGPIPE | ||
| 306 | /* Raise the signal SIG. */ | ||
| 307 | int | ||
| 308 | rpl_raise (int sig) | ||
| 309 | # undef raise | ||
| 310 | { | ||
| 311 | switch (sig) | ||
| 312 | { | ||
| 313 | case SIGPIPE: | ||
| 314 | if (blocked_set & (1U << sig)) | ||
| 315 | pending_array[sig] = 1; | ||
| 316 | else | ||
| 317 | { | ||
| 318 | handler_t handler = SIGPIPE_handler; | ||
| 319 | if (handler == SIG_DFL) | ||
| 320 | exit (128 + SIGPIPE); | ||
| 321 | else if (handler != SIG_IGN) | ||
| 322 | (*handler) (sig); | ||
| 323 | } | ||
| 324 | return 0; | ||
| 325 | default: /* System defined signal */ | ||
| 326 | return raise (sig); | ||
| 327 | } | ||
| 328 | } | ||
| 329 | #endif | ||
diff --git a/lib/unistd.in.h b/lib/unistd.in.h index fdf0fca54e9..769ecf0d43f 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h | |||
| @@ -117,78 +117,77 @@ | |||
| 117 | /* The definition of _GL_WARN_ON_USE is copied here. */ | 117 | /* The definition of _GL_WARN_ON_USE is copied here. */ |
| 118 | 118 | ||
| 119 | 119 | ||
| 120 | #if @GNULIB_GETHOSTNAME@ | 120 | /* Hide some function declarations from <winsock2.h>. */ |
| 121 | /* Get all possible declarations of gethostname(). */ | 121 | |
| 122 | # if @UNISTD_H_HAVE_WINSOCK2_H@ | 122 | #if @GNULIB_GETHOSTNAME@ && @UNISTD_H_HAVE_WINSOCK2_H@ |
| 123 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H | 123 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H |
| 124 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 124 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 125 | # undef socket | 125 | # undef socket |
| 126 | # define socket socket_used_without_including_sys_socket_h | 126 | # define socket socket_used_without_including_sys_socket_h |
| 127 | # undef connect | 127 | # undef connect |
| 128 | # define connect connect_used_without_including_sys_socket_h | 128 | # define connect connect_used_without_including_sys_socket_h |
| 129 | # undef accept | 129 | # undef accept |
| 130 | # define accept accept_used_without_including_sys_socket_h | 130 | # define accept accept_used_without_including_sys_socket_h |
| 131 | # undef bind | 131 | # undef bind |
| 132 | # define bind bind_used_without_including_sys_socket_h | 132 | # define bind bind_used_without_including_sys_socket_h |
| 133 | # undef getpeername | 133 | # undef getpeername |
| 134 | # define getpeername getpeername_used_without_including_sys_socket_h | 134 | # define getpeername getpeername_used_without_including_sys_socket_h |
| 135 | # undef getsockname | 135 | # undef getsockname |
| 136 | # define getsockname getsockname_used_without_including_sys_socket_h | 136 | # define getsockname getsockname_used_without_including_sys_socket_h |
| 137 | # undef getsockopt | 137 | # undef getsockopt |
| 138 | # define getsockopt getsockopt_used_without_including_sys_socket_h | 138 | # define getsockopt getsockopt_used_without_including_sys_socket_h |
| 139 | # undef listen | 139 | # undef listen |
| 140 | # define listen listen_used_without_including_sys_socket_h | 140 | # define listen listen_used_without_including_sys_socket_h |
| 141 | # undef recv | 141 | # undef recv |
| 142 | # define recv recv_used_without_including_sys_socket_h | 142 | # define recv recv_used_without_including_sys_socket_h |
| 143 | # undef send | 143 | # undef send |
| 144 | # define send send_used_without_including_sys_socket_h | 144 | # define send send_used_without_including_sys_socket_h |
| 145 | # undef recvfrom | 145 | # undef recvfrom |
| 146 | # define recvfrom recvfrom_used_without_including_sys_socket_h | 146 | # define recvfrom recvfrom_used_without_including_sys_socket_h |
| 147 | # undef sendto | 147 | # undef sendto |
| 148 | # define sendto sendto_used_without_including_sys_socket_h | 148 | # define sendto sendto_used_without_including_sys_socket_h |
| 149 | # undef setsockopt | 149 | # undef setsockopt |
| 150 | # define setsockopt setsockopt_used_without_including_sys_socket_h | 150 | # define setsockopt setsockopt_used_without_including_sys_socket_h |
| 151 | # undef shutdown | 151 | # undef shutdown |
| 152 | # define shutdown shutdown_used_without_including_sys_socket_h | 152 | # define shutdown shutdown_used_without_including_sys_socket_h |
| 153 | # else | 153 | # else |
| 154 | _GL_WARN_ON_USE (socket, | 154 | _GL_WARN_ON_USE (socket, |
| 155 | "socket() used without including <sys/socket.h>"); | 155 | "socket() used without including <sys/socket.h>"); |
| 156 | _GL_WARN_ON_USE (connect, | 156 | _GL_WARN_ON_USE (connect, |
| 157 | "connect() used without including <sys/socket.h>"); | 157 | "connect() used without including <sys/socket.h>"); |
| 158 | _GL_WARN_ON_USE (accept, | 158 | _GL_WARN_ON_USE (accept, |
| 159 | "accept() used without including <sys/socket.h>"); | 159 | "accept() used without including <sys/socket.h>"); |
| 160 | _GL_WARN_ON_USE (bind, | 160 | _GL_WARN_ON_USE (bind, |
| 161 | "bind() used without including <sys/socket.h>"); | 161 | "bind() used without including <sys/socket.h>"); |
| 162 | _GL_WARN_ON_USE (getpeername, | 162 | _GL_WARN_ON_USE (getpeername, |
| 163 | "getpeername() used without including <sys/socket.h>"); | 163 | "getpeername() used without including <sys/socket.h>"); |
| 164 | _GL_WARN_ON_USE (getsockname, | 164 | _GL_WARN_ON_USE (getsockname, |
| 165 | "getsockname() used without including <sys/socket.h>"); | 165 | "getsockname() used without including <sys/socket.h>"); |
| 166 | _GL_WARN_ON_USE (getsockopt, | 166 | _GL_WARN_ON_USE (getsockopt, |
| 167 | "getsockopt() used without including <sys/socket.h>"); | 167 | "getsockopt() used without including <sys/socket.h>"); |
| 168 | _GL_WARN_ON_USE (listen, | 168 | _GL_WARN_ON_USE (listen, |
| 169 | "listen() used without including <sys/socket.h>"); | 169 | "listen() used without including <sys/socket.h>"); |
| 170 | _GL_WARN_ON_USE (recv, | 170 | _GL_WARN_ON_USE (recv, |
| 171 | "recv() used without including <sys/socket.h>"); | 171 | "recv() used without including <sys/socket.h>"); |
| 172 | _GL_WARN_ON_USE (send, | 172 | _GL_WARN_ON_USE (send, |
| 173 | "send() used without including <sys/socket.h>"); | 173 | "send() used without including <sys/socket.h>"); |
| 174 | _GL_WARN_ON_USE (recvfrom, | 174 | _GL_WARN_ON_USE (recvfrom, |
| 175 | "recvfrom() used without including <sys/socket.h>"); | 175 | "recvfrom() used without including <sys/socket.h>"); |
| 176 | _GL_WARN_ON_USE (sendto, | 176 | _GL_WARN_ON_USE (sendto, |
| 177 | "sendto() used without including <sys/socket.h>"); | 177 | "sendto() used without including <sys/socket.h>"); |
| 178 | _GL_WARN_ON_USE (setsockopt, | 178 | _GL_WARN_ON_USE (setsockopt, |
| 179 | "setsockopt() used without including <sys/socket.h>"); | 179 | "setsockopt() used without including <sys/socket.h>"); |
| 180 | _GL_WARN_ON_USE (shutdown, | 180 | _GL_WARN_ON_USE (shutdown, |
| 181 | "shutdown() used without including <sys/socket.h>"); | 181 | "shutdown() used without including <sys/socket.h>"); |
| 182 | # endif | ||
| 183 | # endif | 182 | # endif |
| 184 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H | 183 | # endif |
| 185 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | 184 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H |
| 186 | # undef select | 185 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) |
| 187 | # define select select_used_without_including_sys_select_h | 186 | # undef select |
| 188 | # else | 187 | # define select select_used_without_including_sys_select_h |
| 189 | _GL_WARN_ON_USE (select, | 188 | # else |
| 190 | "select() used without including <sys/select.h>"); | 189 | _GL_WARN_ON_USE (select, |
| 191 | # endif | 190 | "select() used without including <sys/select.h>"); |
| 192 | # endif | 191 | # endif |
| 193 | # endif | 192 | # endif |
| 194 | #endif | 193 | #endif |
diff --git a/m4/getopt.m4 b/m4/getopt.m4 index 4d8450ff907..7e49ddde9f6 100644 --- a/m4/getopt.m4 +++ b/m4/getopt.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # getopt.m4 serial 35 | 1 | # getopt.m4 serial 38 |
| 2 | dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2002-2006, 2008-2011 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -89,15 +89,15 @@ AC_DEFUN([gl_GETOPT_CHECK_HEADERS], | |||
| 89 | AC_CACHE_CHECK([whether getopt is POSIX compatible], | 89 | AC_CACHE_CHECK([whether getopt is POSIX compatible], |
| 90 | [gl_cv_func_getopt_posix], | 90 | [gl_cv_func_getopt_posix], |
| 91 | [ | 91 | [ |
| 92 | dnl BSD getopt_long uses an incompatible method to reset | 92 | dnl BSD getopt_long uses an incompatible method to reset option |
| 93 | dnl option processing. Existence of the variable, in and of | 93 | dnl processing. Existence of the optreset variable, in and of |
| 94 | dnl itself, is not a reason to replace getopt, but knowledge | 94 | dnl itself, is not a reason to replace getopt, but knowledge |
| 95 | dnl of the variable is needed to determine how to reset and | 95 | dnl of the variable is needed to determine how to reset and |
| 96 | dnl whether a reset reparses the environment. Solaris | 96 | dnl whether a reset reparses the environment. Solaris |
| 97 | dnl supports neither optreset nor optind=0, but keeps no state | 97 | dnl supports neither optreset nor optind=0, but keeps no state |
| 98 | dnl that needs a reset beyond setting optind=1; detect Solaris | 98 | dnl that needs a reset beyond setting optind=1; detect Solaris |
| 99 | dnl by getopt_clip. | 99 | dnl by getopt_clip. |
| 100 | AC_COMPILE_IFELSE( | 100 | AC_LINK_IFELSE( |
| 101 | [AC_LANG_PROGRAM( | 101 | [AC_LANG_PROGRAM( |
| 102 | [[#include <unistd.h>]], | 102 | [[#include <unistd.h>]], |
| 103 | [[int *p = &optreset; return optreset;]])], | 103 | [[int *p = &optreset; return optreset;]])], |
| @@ -121,22 +121,20 @@ int | |||
| 121 | main () | 121 | main () |
| 122 | { | 122 | { |
| 123 | { | 123 | { |
| 124 | int argc = 0; | 124 | static char program[] = "program"; |
| 125 | char *argv[10]; | 125 | static char a[] = "-a"; |
| 126 | static char foo[] = "foo"; | ||
| 127 | static char bar[] = "bar"; | ||
| 128 | char *argv[] = { program, a, foo, bar, NULL }; | ||
| 126 | int c; | 129 | int c; |
| 127 | 130 | ||
| 128 | argv[argc++] = "program"; | ||
| 129 | argv[argc++] = "-a"; | ||
| 130 | argv[argc++] = "foo"; | ||
| 131 | argv[argc++] = "bar"; | ||
| 132 | argv[argc] = NULL; | ||
| 133 | optind = OPTIND_MIN; | 131 | optind = OPTIND_MIN; |
| 134 | opterr = 0; | 132 | opterr = 0; |
| 135 | 133 | ||
| 136 | c = getopt (argc, argv, "ab"); | 134 | c = getopt (4, argv, "ab"); |
| 137 | if (!(c == 'a')) | 135 | if (!(c == 'a')) |
| 138 | return 1; | 136 | return 1; |
| 139 | c = getopt (argc, argv, "ab"); | 137 | c = getopt (4, argv, "ab"); |
| 140 | if (!(c == -1)) | 138 | if (!(c == -1)) |
| 141 | return 2; | 139 | return 2; |
| 142 | if (!(optind == 2)) | 140 | if (!(optind == 2)) |
| @@ -144,22 +142,20 @@ main () | |||
| 144 | } | 142 | } |
| 145 | /* Some internal state exists at this point. */ | 143 | /* Some internal state exists at this point. */ |
| 146 | { | 144 | { |
| 147 | int argc = 0; | 145 | static char program[] = "program"; |
| 148 | char *argv[10]; | 146 | static char donald[] = "donald"; |
| 147 | static char p[] = "-p"; | ||
| 148 | static char billy[] = "billy"; | ||
| 149 | static char duck[] = "duck"; | ||
| 150 | static char a[] = "-a"; | ||
| 151 | static char bar[] = "bar"; | ||
| 152 | char *argv[] = { program, donald, p, billy, duck, a, bar, NULL }; | ||
| 149 | int c; | 153 | int c; |
| 150 | 154 | ||
| 151 | argv[argc++] = "program"; | ||
| 152 | argv[argc++] = "donald"; | ||
| 153 | argv[argc++] = "-p"; | ||
| 154 | argv[argc++] = "billy"; | ||
| 155 | argv[argc++] = "duck"; | ||
| 156 | argv[argc++] = "-a"; | ||
| 157 | argv[argc++] = "bar"; | ||
| 158 | argv[argc] = NULL; | ||
| 159 | optind = OPTIND_MIN; | 155 | optind = OPTIND_MIN; |
| 160 | opterr = 0; | 156 | opterr = 0; |
| 161 | 157 | ||
| 162 | c = getopt (argc, argv, "+abp:q:"); | 158 | c = getopt (7, argv, "+abp:q:"); |
| 163 | if (!(c == -1)) | 159 | if (!(c == -1)) |
| 164 | return 4; | 160 | return 4; |
| 165 | if (!(strcmp (argv[0], "program") == 0)) | 161 | if (!(strcmp (argv[0], "program") == 0)) |
| @@ -181,7 +177,9 @@ main () | |||
| 181 | } | 177 | } |
| 182 | /* Detect MacOS 10.5, AIX 7.1 bug. */ | 178 | /* Detect MacOS 10.5, AIX 7.1 bug. */ |
| 183 | { | 179 | { |
| 184 | char *argv[3] = { "program", "-ab", NULL }; | 180 | static char program[] = "program"; |
| 181 | static char ab[] = "-ab"; | ||
| 182 | char *argv[3] = { program, ab, NULL }; | ||
| 185 | optind = OPTIND_MIN; | 183 | optind = OPTIND_MIN; |
| 186 | opterr = 0; | 184 | opterr = 0; |
| 187 | if (getopt (2, argv, "ab:") != 'a') | 185 | if (getopt (2, argv, "ab:") != 'a') |
| @@ -239,19 +237,22 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 239 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, | 237 | and fails on MacOS X 10.5, AIX 5.2, HP-UX 11, IRIX 6.5, |
| 240 | OSF/1 5.1, Solaris 10. */ | 238 | OSF/1 5.1, Solaris 10. */ |
| 241 | { | 239 | { |
| 242 | char *myargv[3]; | 240 | static char conftest[] = "conftest"; |
| 243 | myargv[0] = "conftest"; | 241 | static char plus[] = "-+"; |
| 244 | myargv[1] = "-+"; | 242 | char *argv[3] = { conftest, plus, NULL }; |
| 245 | myargv[2] = 0; | ||
| 246 | opterr = 0; | 243 | opterr = 0; |
| 247 | if (getopt (2, myargv, "+a") != '?') | 244 | if (getopt (2, argv, "+a") != '?') |
| 248 | result |= 1; | 245 | result |= 1; |
| 249 | } | 246 | } |
| 250 | /* This code succeeds on glibc 2.8, mingw, | 247 | /* This code succeeds on glibc 2.8, mingw, |
| 251 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, | 248 | and fails on MacOS X 10.5, OpenBSD 4.0, AIX 5.2, HP-UX 11, |
| 252 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ | 249 | IRIX 6.5, OSF/1 5.1, Solaris 10, Cygwin 1.5.x. */ |
| 253 | { | 250 | { |
| 254 | char *argv[] = { "program", "-p", "foo", "bar", NULL }; | 251 | static char program[] = "program"; |
| 252 | static char p[] = "-p"; | ||
| 253 | static char foo[] = "foo"; | ||
| 254 | static char bar[] = "bar"; | ||
| 255 | char *argv[] = { program, p, foo, bar, NULL }; | ||
| 255 | 256 | ||
| 256 | optind = 1; | 257 | optind = 1; |
| 257 | if (getopt (4, argv, "p::") != 'p') | 258 | if (getopt (4, argv, "p::") != 'p') |
| @@ -265,7 +266,10 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 265 | } | 266 | } |
| 266 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ | 267 | /* This code succeeds on glibc 2.8 and fails on Cygwin 1.7.0. */ |
| 267 | { | 268 | { |
| 268 | char *argv[] = { "program", "foo", "-p", NULL }; | 269 | static char program[] = "program"; |
| 270 | static char foo[] = "foo"; | ||
| 271 | static char p[] = "-p"; | ||
| 272 | char *argv[] = { program, foo, p, NULL }; | ||
| 269 | optind = 0; | 273 | optind = 0; |
| 270 | if (getopt (3, argv, "-p") != 1) | 274 | if (getopt (3, argv, "-p") != 1) |
| 271 | result |= 16; | 275 | result |= 16; |
| @@ -274,13 +278,26 @@ dnl is ambiguous with environment values that contain newlines. | |||
| 274 | } | 278 | } |
| 275 | /* This code fails on glibc 2.11. */ | 279 | /* This code fails on glibc 2.11. */ |
| 276 | { | 280 | { |
| 277 | char *argv[] = { "program", "-b", "-a", NULL }; | 281 | static char program[] = "program"; |
| 282 | static char b[] = "-b"; | ||
| 283 | static char a[] = "-a"; | ||
| 284 | char *argv[] = { program, b, a, NULL }; | ||
| 278 | optind = opterr = 0; | 285 | optind = opterr = 0; |
| 279 | if (getopt (3, argv, "+:a:b") != 'b') | 286 | if (getopt (3, argv, "+:a:b") != 'b') |
| 280 | result |= 64; | 287 | result |= 64; |
| 281 | else if (getopt (3, argv, "+:a:b") != ':') | 288 | else if (getopt (3, argv, "+:a:b") != ':') |
| 282 | result |= 64; | 289 | result |= 64; |
| 283 | } | 290 | } |
| 291 | /* This code dumps core on glibc 2.14. */ | ||
| 292 | { | ||
| 293 | static char program[] = "program"; | ||
| 294 | static char w[] = "-W"; | ||
| 295 | static char dummy[] = "dummy"; | ||
| 296 | char *argv[] = { program, w, dummy, NULL }; | ||
| 297 | optind = opterr = 1; | ||
| 298 | if (getopt (3, argv, "W;") != 'W') | ||
| 299 | result |= 128; | ||
| 300 | } | ||
| 284 | return result; | 301 | return result; |
| 285 | ]])], | 302 | ]])], |
| 286 | [gl_cv_func_getopt_gnu=yes], | 303 | [gl_cv_func_getopt_gnu=yes], |
diff --git a/m4/gl-comp.m4 b/m4/gl-comp.m4 index 004c01a10a0..6c94e373871 100644 --- a/m4/gl-comp.m4 +++ b/m4/gl-comp.m4 | |||
| @@ -55,6 +55,7 @@ AC_DEFUN([gl_EARLY], | |||
| 55 | # Code from module pthread_sigmask: | 55 | # Code from module pthread_sigmask: |
| 56 | # Code from module readlink: | 56 | # Code from module readlink: |
| 57 | # Code from module signal: | 57 | # Code from module signal: |
| 58 | # Code from module sigprocmask: | ||
| 58 | # Code from module socklen: | 59 | # Code from module socklen: |
| 59 | # Code from module ssize_t: | 60 | # Code from module ssize_t: |
| 60 | # Code from module stat: | 61 | # Code from module stat: |
| @@ -142,7 +143,10 @@ if test $REPLACE_MKTIME = 1; then | |||
| 142 | fi | 143 | fi |
| 143 | gl_TIME_MODULE_INDICATOR([mktime]) | 144 | gl_TIME_MODULE_INDICATOR([mktime]) |
| 144 | gl_MULTIARCH | 145 | gl_MULTIARCH |
| 145 | gl_PTHREAD_SIGMASK | 146 | gl_FUNC_PTHREAD_SIGMASK |
| 147 | if test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1; then | ||
| 148 | AC_LIBOBJ([pthread_sigmask]) | ||
| 149 | fi | ||
| 146 | gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) | 150 | gl_SIGNAL_MODULE_INDICATOR([pthread_sigmask]) |
| 147 | gl_FUNC_READLINK | 151 | gl_FUNC_READLINK |
| 148 | if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then | 152 | if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then |
| @@ -184,6 +188,7 @@ AC_REQUIRE([AC_C_INLINE]) | |||
| 184 | gl_UNISTD_H | 188 | gl_UNISTD_H |
| 185 | gl_gnulib_enabled_dosname=false | 189 | gl_gnulib_enabled_dosname=false |
| 186 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false | 190 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false |
| 191 | gl_gnulib_enabled_sigprocmask=false | ||
| 187 | gl_gnulib_enabled_stat=false | 192 | gl_gnulib_enabled_stat=false |
| 188 | gl_gnulib_enabled_strtoull=false | 193 | gl_gnulib_enabled_strtoull=false |
| 189 | gl_gnulib_enabled_verify=false | 194 | gl_gnulib_enabled_verify=false |
| @@ -201,6 +206,18 @@ AC_SUBST([LTLIBINTL]) | |||
| 201 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=true | 206 | gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=true |
| 202 | fi | 207 | fi |
| 203 | } | 208 | } |
| 209 | func_gl_gnulib_m4code_sigprocmask () | ||
| 210 | { | ||
| 211 | if ! $gl_gnulib_enabled_sigprocmask; then | ||
| 212 | gl_SIGNALBLOCKING | ||
| 213 | if test $HAVE_POSIX_SIGNALBLOCKING = 0; then | ||
| 214 | AC_LIBOBJ([sigprocmask]) | ||
| 215 | gl_PREREQ_SIGPROCMASK | ||
| 216 | fi | ||
| 217 | gl_SIGNAL_MODULE_INDICATOR([sigprocmask]) | ||
| 218 | gl_gnulib_enabled_sigprocmask=true | ||
| 219 | fi | ||
| 220 | } | ||
| 204 | func_gl_gnulib_m4code_stat () | 221 | func_gl_gnulib_m4code_stat () |
| 205 | { | 222 | { |
| 206 | if ! $gl_gnulib_enabled_stat; then | 223 | if ! $gl_gnulib_enabled_stat; then |
| @@ -246,7 +263,7 @@ gl_STDLIB_MODULE_INDICATOR([strtoull]) | |||
| 246 | if test $REPLACE_LSTAT = 1; then | 263 | if test $REPLACE_LSTAT = 1; then |
| 247 | func_gl_gnulib_m4code_stat | 264 | func_gl_gnulib_m4code_stat |
| 248 | fi | 265 | fi |
| 249 | if test $REPLACE_PTHREAD_SIGMASK = 1; then | 266 | if test $HAVE_PTHREAD_SIGMASK = 0 || test $REPLACE_PTHREAD_SIGMASK = 1; then |
| 250 | func_gl_gnulib_m4code_sigprocmask | 267 | func_gl_gnulib_m4code_sigprocmask |
| 251 | fi | 268 | fi |
| 252 | if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then | 269 | if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then |
| @@ -261,6 +278,7 @@ gl_STDLIB_MODULE_INDICATOR([strtoull]) | |||
| 261 | m4_pattern_allow([^gl_GNULIB_ENABLED_]) | 278 | m4_pattern_allow([^gl_GNULIB_ENABLED_]) |
| 262 | AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) | 279 | AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname]) |
| 263 | AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) | 280 | AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], [$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36]) |
| 281 | AM_CONDITIONAL([gl_GNULIB_ENABLED_sigprocmask], [$gl_gnulib_enabled_sigprocmask]) | ||
| 264 | AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat]) | 282 | AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat]) |
| 265 | AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull]) | 283 | AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull]) |
| 266 | AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify]) | 284 | AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify]) |
| @@ -434,6 +452,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 434 | lib/md5.h | 452 | lib/md5.h |
| 435 | lib/mktime-internal.h | 453 | lib/mktime-internal.h |
| 436 | lib/mktime.c | 454 | lib/mktime.c |
| 455 | lib/pthread_sigmask.c | ||
| 437 | lib/readlink.c | 456 | lib/readlink.c |
| 438 | lib/sha1.c | 457 | lib/sha1.c |
| 439 | lib/sha1.h | 458 | lib/sha1.h |
| @@ -442,6 +461,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 442 | lib/sha512.c | 461 | lib/sha512.c |
| 443 | lib/sha512.h | 462 | lib/sha512.h |
| 444 | lib/signal.in.h | 463 | lib/signal.in.h |
| 464 | lib/sigprocmask.c | ||
| 445 | lib/stat.c | 465 | lib/stat.c |
| 446 | lib/stdarg.in.h | 466 | lib/stdarg.in.h |
| 447 | lib/stdbool.in.h | 467 | lib/stdbool.in.h |
| @@ -485,6 +505,7 @@ AC_DEFUN([gl_FILE_LIST], [ | |||
| 485 | m4/sha256.m4 | 505 | m4/sha256.m4 |
| 486 | m4/sha512.m4 | 506 | m4/sha512.m4 |
| 487 | m4/signal_h.m4 | 507 | m4/signal_h.m4 |
| 508 | m4/signalblocking.m4 | ||
| 488 | m4/socklen.m4 | 509 | m4/socklen.m4 |
| 489 | m4/ssize_t.m4 | 510 | m4/ssize_t.m4 |
| 490 | m4/st_dm_mode.m4 | 511 | m4/st_dm_mode.m4 |
diff --git a/m4/pthread_sigmask.m4 b/m4/pthread_sigmask.m4 index d25e2cc3e70..dfa0f660a75 100644 --- a/m4/pthread_sigmask.m4 +++ b/m4/pthread_sigmask.m4 | |||
| @@ -1,26 +1,77 @@ | |||
| 1 | # pthread_sigmask.m4 serial 2 | 1 | # pthread_sigmask.m4 serial 7 |
| 2 | dnl Copyright (C) 2011 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2011 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| 5 | dnl with or without modifications, as long as this notice is preserved. | 5 | dnl with or without modifications, as long as this notice is preserved. |
| 6 | 6 | ||
| 7 | AC_DEFUN([gl_PTHREAD_SIGMASK], | 7 | AC_DEFUN([gl_FUNC_PTHREAD_SIGMASK], |
| 8 | [ | 8 | [ |
| 9 | AC_CHECK_FUNCS_ONCE([pthread_sigmask]) | ||
| 10 | LIB_PTHREAD_SIGMASK= | ||
| 9 | m4_ifdef([gl_THREADLIB], [ | 11 | m4_ifdef([gl_THREADLIB], [ |
| 10 | AC_REQUIRE([gl_THREADLIB]) | 12 | AC_REQUIRE([gl_THREADLIB]) |
| 11 | if test "$gl_threads_api" = posix; then | 13 | if test "$gl_threads_api" = posix; then |
| 12 | gl_save_LIBS="$LIBS" | 14 | if test $ac_cv_func_pthread_sigmask = yes; then |
| 13 | LIBS="$LIBS $LIBMULTITHREAD" | 15 | dnl pthread_sigmask is available without -lpthread. |
| 14 | AC_CHECK_FUNCS([pthread_sigmask]) | 16 | : |
| 15 | LIBS="$gl_save_LIBS" | 17 | else |
| 18 | if test -n "$LIBMULTITHREAD"; then | ||
| 19 | AC_CACHE_CHECK([for pthread_sigmask in $LIBMULTITHREAD], | ||
| 20 | [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD], | ||
| 21 | [gl_save_LIBS="$LIBS" | ||
| 22 | LIBS="$LIBS $LIBMULTITHREAD" | ||
| 23 | AC_LINK_IFELSE( | ||
| 24 | [AC_LANG_PROGRAM( | ||
| 25 | [[#include <pthread.h> | ||
| 26 | #include <signal.h> | ||
| 27 | ]], | ||
| 28 | [[return pthread_sigmask (0, (sigset_t *) 0, (sigset_t *) 0);]]) | ||
| 29 | ], | ||
| 30 | [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=yes], | ||
| 31 | [gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD=no]) | ||
| 32 | LIBS="$gl_save_LIBS" | ||
| 33 | ]) | ||
| 34 | if test $gl_cv_func_pthread_sigmask_in_LIBMULTITHREAD = yes; then | ||
| 35 | dnl pthread_sigmask is available with -lpthread. | ||
| 36 | LIB_PTHREAD_SIGMASK="$LIBMULTITHREAD" | ||
| 37 | else | ||
| 38 | dnl pthread_sigmask is not available at all. | ||
| 39 | HAVE_PTHREAD_SIGMASK=0 | ||
| 40 | fi | ||
| 41 | else | ||
| 42 | dnl pthread_sigmask is not available at all. | ||
| 43 | HAVE_PTHREAD_SIGMASK=0 | ||
| 44 | fi | ||
| 45 | fi | ||
| 16 | else | 46 | else |
| 17 | ac_cv_func_pthread_sigmask=no | 47 | dnl pthread_sigmask may exist but does not interoperate with the chosen |
| 48 | dnl multithreading facility. | ||
| 49 | dnl If "$gl_threads_api" = pth, we could use the function pth_sigmask, | ||
| 50 | dnl but it is equivalent to sigprocmask, so we choose to emulate | ||
| 51 | dnl pthread_sigmask with sigprocmask also in this case. This yields fewer | ||
| 52 | dnl link dependencies. | ||
| 53 | if test $ac_cv_func_pthread_sigmask = yes; then | ||
| 54 | REPLACE_PTHREAD_SIGMASK=1 | ||
| 55 | else | ||
| 56 | HAVE_PTHREAD_SIGMASK=0 | ||
| 57 | fi | ||
| 58 | fi | ||
| 59 | ] ,[ | ||
| 60 | dnl gl_THREADLIB is not in use. Assume the application wants | ||
| 61 | dnl POSIX semantics. | ||
| 62 | if test $ac_cv_func_pthread_sigmask != yes; then | ||
| 63 | gl_save_LIBS=$LIBS | ||
| 64 | AC_SEARCH_LIBS([pthread_sigmask], [pthread c_r]) | ||
| 65 | LIBS=$gl_save_LIBS | ||
| 66 | if test "$ac_cv_search_pthread_sigmask" = no; then | ||
| 67 | HAVE_PTHREAD_SIGMASK=0 | ||
| 68 | elif test "$ac_cv_search_pthread_sigmask" != 'none required'; then | ||
| 69 | LIB_PTHREAD_SIGMASK=$ac_cv_search_pthread_sigmask | ||
| 70 | fi | ||
| 18 | fi | 71 | fi |
| 19 | ], [ | ||
| 20 | AC_CHECK_FUNCS_ONCE([pthread_sigmask]) | ||
| 21 | ]) | 72 | ]) |
| 22 | 73 | AC_SUBST([LIB_PTHREAD_SIGMASK]) | |
| 23 | if test $ac_cv_func_pthread_sigmask = no; then | 74 | dnl We don't need a variable LTLIB_PTHREAD_SIGMASK, because when |
| 24 | REPLACE_PTHREAD_SIGMASK=1 | 75 | dnl "$gl_threads_api" = posix, $LTLIBMULTITHREAD and $LIBMULTITHREAD are the |
| 25 | fi | 76 | dnl same: either both empty or both "-lpthread". |
| 26 | ]) | 77 | ]) |
diff --git a/m4/signal_h.m4 b/m4/signal_h.m4 index 53972fba54f..b9536fb0e3c 100644 --- a/m4/signal_h.m4 +++ b/m4/signal_h.m4 | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # signal_h.m4 serial 14 | 1 | # signal_h.m4 serial 16 |
| 2 | dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2007-2011 Free Software Foundation, Inc. |
| 3 | dnl This file is free software; the Free Software Foundation | 3 | dnl This file is free software; the Free Software Foundation |
| 4 | dnl gives unlimited permission to copy and/or distribute it, | 4 | dnl gives unlimited permission to copy and/or distribute it, |
| @@ -64,6 +64,7 @@ AC_DEFUN([gl_SIGNAL_H_DEFAULTS], | |||
| 64 | GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) | 64 | GNULIB_SIGACTION=0; AC_SUBST([GNULIB_SIGACTION]) |
| 65 | dnl Assume proper GNU behavior unless another module says otherwise. | 65 | dnl Assume proper GNU behavior unless another module says otherwise. |
| 66 | HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) | 66 | HAVE_POSIX_SIGNALBLOCKING=1; AC_SUBST([HAVE_POSIX_SIGNALBLOCKING]) |
| 67 | HAVE_PTHREAD_SIGMASK=1; AC_SUBST([HAVE_PTHREAD_SIGMASK]) | ||
| 67 | HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) | 68 | HAVE_SIGSET_T=1; AC_SUBST([HAVE_SIGSET_T]) |
| 68 | HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) | 69 | HAVE_SIGINFO_T=1; AC_SUBST([HAVE_SIGINFO_T]) |
| 69 | HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) | 70 | HAVE_SIGACTION=1; AC_SUBST([HAVE_SIGACTION]) |
diff --git a/m4/signalblocking.m4 b/m4/signalblocking.m4 new file mode 100644 index 00000000000..15b74253ba6 --- /dev/null +++ b/m4/signalblocking.m4 | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # signalblocking.m4 serial 12 | ||
| 2 | dnl Copyright (C) 2001-2002, 2006-2011 Free Software Foundation, Inc. | ||
| 3 | dnl This file is free software; the Free Software Foundation | ||
| 4 | dnl gives unlimited permission to copy and/or distribute it, | ||
| 5 | dnl with or without modifications, as long as this notice is preserved. | ||
| 6 | |||
| 7 | # Determine available signal blocking primitives. Three different APIs exist: | ||
| 8 | # 1) POSIX: sigemptyset, sigaddset, sigprocmask | ||
| 9 | # 2) SYSV: sighold, sigrelse | ||
| 10 | # 3) BSD: sigblock, sigsetmask | ||
| 11 | # For simplicity, here we check only for the POSIX signal blocking. | ||
| 12 | AC_DEFUN([gl_SIGNALBLOCKING], | ||
| 13 | [ | ||
| 14 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) | ||
| 15 | AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) | ||
| 16 | if test $gl_cv_type_sigset_t = yes; then | ||
| 17 | AC_CHECK_FUNC([sigprocmask], [gl_cv_func_sigprocmask=1]) | ||
| 18 | fi | ||
| 19 | if test -z "$gl_cv_func_sigprocmask"; then | ||
| 20 | HAVE_POSIX_SIGNALBLOCKING=0 | ||
| 21 | fi | ||
| 22 | ]) | ||
| 23 | |||
| 24 | # Prerequisites of lib/sigprocmask.c. | ||
| 25 | AC_DEFUN([gl_PREREQ_SIGPROCMASK], [:]) | ||
diff --git a/src/Makefile.in b/src/Makefile.in index f628c321f70..f68fa5c2240 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -269,6 +269,8 @@ LIBSELINUX_LIBS = @LIBSELINUX_LIBS@ | |||
| 269 | LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ | 269 | LIBGNUTLS_LIBS = @LIBGNUTLS_LIBS@ |
| 270 | LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ | 270 | LIBGNUTLS_CFLAGS = @LIBGNUTLS_CFLAGS@ |
| 271 | 271 | ||
| 272 | LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@ | ||
| 273 | |||
| 272 | INTERVALS_H = dispextern.h intervals.h composite.h | 274 | INTERVALS_H = dispextern.h intervals.h composite.h |
| 273 | 275 | ||
| 274 | GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ | 276 | GETLOADAVG_LIBS = @GETLOADAVG_LIBS@ |
| @@ -383,7 +385,7 @@ LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ | |||
| 383 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 385 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 384 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 386 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 385 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 387 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
| 386 | $(LIBGNUTLS_LIBS) \ | 388 | $(LIBGNUTLS_LIBS) $(LIB_PTHREAD_SIGMASK) \ |
| 387 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) | 389 | $(LIB_GCC) $(LIB_MATH) $(LIB_STANDARD) $(LIB_GCC) |
| 388 | 390 | ||
| 389 | all: emacs$(EXEEXT) $(OTHER_FILES) | 391 | all: emacs$(EXEEXT) $(OTHER_FILES) |