Commit 48dbafe4 by Alexandre Oliva Committed by Alexandre Oliva

gen-num-limits.cc: Use sigsetjmp and siglongjmp if available.

* src/gen-num-limits.cc: Use sigsetjmp and siglongjmp if available.
* mknumeric_limits: Compile it with -DHAVE_CONFIG_H.
* configure.in: Test for sigsetjmp.
* configure, config.h.in: Rebuilt.

From-SVN: r39586
parent 1796dff4
2001-02-11 Alexandre Oliva <aoliva@redhat.com>
* src/gen-num-limits.cc: Use sigsetjmp and siglongjmp if available.
* mknumeric_limits: Compile it with -DHAVE_CONFIG_H.
* configure.in: Test for sigsetjmp.
* configure, config.h.in: Rebuilt.
2001-02-11 Gabriel Dos Reis <gdr@codesourcery.com> 2001-02-11 Gabriel Dos Reis <gdr@codesourcery.com>
* src/valarray-inst.cc (gslice::_Indexer::_Indexer): Don't flip * src/valarray-inst.cc (gslice::_Indexer::_Indexer): Don't flip
......
...@@ -546,6 +546,9 @@ ...@@ -546,6 +546,9 @@
/* Version number of package */ /* Version number of package */
#undef VERSION #undef VERSION
/* Define if sigsetjmp is available. */
#undef HAVE_SIGSETJMP
// //
// Systems that have certain non-standard functions prefixed with an // Systems that have certain non-standard functions prefixed with an
// underscore, we'll handle those here. Must come after config.h.in. // underscore, we'll handle those here. Must come after config.h.in.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -217,6 +217,11 @@ else ...@@ -217,6 +217,11 @@ else
GLIBCPP_CHECK_WCHAR_T_SUPPORT GLIBCPP_CHECK_WCHAR_T_SUPPORT
GLIBCPP_CHECK_STDLIB_SUPPORT GLIBCPP_CHECK_STDLIB_SUPPORT
AC_TRY_COMPILE([
#include <setjmp.h>
], [sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1);],
[AC_DEFINE(HAVE_SIGSETJMP, 1, [Define if sigsetjmp is available. ])])
AC_FUNC_MMAP AC_FUNC_MMAP
fi fi
......
...@@ -178,18 +178,17 @@ namespace std { ...@@ -178,18 +178,17 @@ namespace std {
EOF EOF
echo "$CXX $CPPFLAGS -I$BUILD_DIR/include \ echo "$CXX -I. $CPPFLAGS -I$BUILD_DIR/include -DHAVE_CONFIG_H \
-o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \ -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
$LDFLAGS" $LDFLAGS"
$CXX $CPPFLAGS -I$BUILD_DIR/include \ { $CXX -I. $CPPFLAGS -I$BUILD_DIR/include -DHAVE_CONFIG_H \
-o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \ -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc" \
$LDFLAGS $LDFLAGS
} || {
if [ ! -f "$BUILD_DIR/src/gen-num-limits" ]; then
echo "gen-num-limits failed to build, exiting." echo "gen-num-limits failed to build, exiting."
exit 1 exit 1
fi }
"$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t "$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t
......
...@@ -35,6 +35,10 @@ ...@@ -35,6 +35,10 @@
#include <bits/c++config.h> #include <bits/c++config.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
// //
// Force Linux <limits.h> to define the *LONG_LONG* // Force Linux <limits.h> to define the *LONG_LONG*
// //
...@@ -57,6 +61,18 @@ ...@@ -57,6 +61,18 @@
#include <wchar.h> #include <wchar.h>
#endif #endif
// mknumeric_limits will first try to compile this file with
// HAVE_SIGSETJMP. If it fails, then it will try without it. Some
// systems, such as GNU/Linux/sparc, would remain with the signal
// blocked if the signal handler uses longjmp instead of siglongjmp.
// We assume here setjmp/longjmp will preserve the sigblock mask if
// sigsetjmp is not present.
#if ! HAVE_SIGSETJMP
# define sigjmp_buf jmp_buf
# define sigsetjmp(buf, save) setjmp (buf)
# define siglongjmp(env, ret) longjmp (env, ret)
#endif
const char tab[] = " "; const char tab[] = " ";
const char tab2[] = " "; const char tab2[] = " ";
...@@ -90,7 +106,7 @@ const int integer_base_rep = 2; ...@@ -90,7 +106,7 @@ const int integer_base_rep = 2;
// occur for int, unsigned, long, unsigned long. Furthermore // occur for int, unsigned, long, unsigned long. Furthermore
// overflow cannot happen for unsigned integer types. // overflow cannot happen for unsigned integer types.
jmp_buf env; sigjmp_buf env;
/* The prototype of signal() may vary. Accomodate variations such as /* The prototype of signal() may vary. Accomodate variations such as
void(*)(int) and void(*)(...). */ void(*)(int) and void(*)(...). */
...@@ -112,13 +128,13 @@ void signal_handler(int sig) ...@@ -112,13 +128,13 @@ void signal_handler(int sig)
sigemptyset (&x); sigemptyset (&x);
sigprocmask(SIG_SETMASK, &x, NULL); sigprocmask(SIG_SETMASK, &x, NULL);
#endif /* __CYGWIN__ */ #endif /* __CYGWIN__ */
longjmp(env, sig); siglongjmp(env, sig);
} }
template<typename Operation> template<typename Operation>
bool trapping(const Operation& op) bool trapping(const Operation& op)
{ {
if (setjmp(env) == 0) op(); if (sigsetjmp(env, 1) == 0) op();
else return true; else return true;
return false; return false;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment