diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8df53e58caa..6610d3d40f5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,10 @@ +2001-01-09 Alexandre Oliva + + * src/gen-num-limits.cc (signal_adapter): New template function. + (signal_handler): Use it, instead of signal. + (traps): Likewise. Install SIGTRAP handler too. Don't + require both tests to trap to set trap_flag. + 2001-01-08 Benjamin Kosnik * include/bits/fpos.h (fpos:::fpos(streamoff __pos)): Explicitly diff --git a/libstdc++-v3/src/gen-num-limits.cc b/libstdc++-v3/src/gen-num-limits.cc index 10c5336b7d5..8106c903275 100644 --- a/libstdc++-v3/src/gen-num-limits.cc +++ b/libstdc++-v3/src/gen-num-limits.cc @@ -1,4 +1,4 @@ -// Copyright (C) 1999, 2000 Free Software Foundation, Inc. +// Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -92,11 +92,23 @@ const int integer_base_rep = 2; jmp_buf env; +/* The prototype of signal() may vary. Accomodate variations such as + void(*)(int) and void(*)(...). */ +template +inline void (*signal_adapter (signal_handler_type + (*signal_func)(signal_number_type, + signal_handler_type), + signal_number_type arg, + void (*handler)(int)))(int) +{ + return (void (*)(int))(*signal_func)(arg, (signal_handler_type)handler); +} + void signal_handler(int sig) { #ifdef __CYGWIN__ static sigset_t x; - signal (sig, signal_handler); + signal_adapter (signal, sig, signal_handler); sigemptyset (&x); sigprocmask(SIG_SETMASK, &x, NULL); #endif /* __CYGWIN__ */ @@ -137,10 +149,12 @@ template struct underflow {}; // traps template void traps() { - signal(SIGFPE, signal_handler); + signal_adapter (signal, SIGFPE, signal_handler); + signal_adapter (signal, SIGTRAP, signal_handler); bool trap_flag = trapping(division_by_zero()); - signal(SIGFPE, signal_handler); - trap_flag = trap_flag && trapping(overflow()); + signal_adapter (signal, SIGFPE, signal_handler); + signal_adapter (signal, SIGTRAP, signal_handler); + trap_flag = trap_flag || trapping(overflow()); const char* p = bool_alpha[trap_flag]; printf("%s%s = %s;\n", tab2, "static const bool traps", p); } @@ -148,7 +162,8 @@ template void traps() #define SPECIALIZE_TRAPPING(T) \ template<> void traps< T >() \ { \ - signal(SIGFPE, signal_handler); \ + signal_adapter (signal, SIGFPE, signal_handler); \ + signal_adapter (signal, SIGTRAP, signal_handler); \ const char* p = bool_alpha[trapping(division_by_zero())]; \ printf("%s%s = %s;\n", tab2, "static const bool traps", p); \ }