gen-num-limits.cc (set_signals_handler): New function.

* src/gen-num-limits.cc (set_signals_handler): New function.
        Factor out signals setting.  Set signal handler for SIGILL.

Co-Authored-By: Bert De Knuydt <Bert.Deknuydt@esat.kuleuven.ac.be>

From-SVN: r44139
This commit is contained in:
Gabriel Dos Reis 2001-07-19 03:06:01 +00:00 committed by Gabriel Dos Reis
parent 27ffc806c4
commit b2a4c43c0d
2 changed files with 19 additions and 6 deletions

View File

@ -1,3 +1,9 @@
2001-07-19 Gabriel Dos Reis <gdr@merlin.codesourcery.com>
Bert De Knuydt <Bert.Deknuydt@esat.kuleuven.ac.be>
* src/gen-num-limits.cc (set_signals_handler): New function.
Factor out signals setting. Set signal handler for SIGILL.
2001-07-18 Phil Edwards <pme@sources.redhat.com>
* docs/html/27_io/howto.html: Fix typo.

View File

@ -157,15 +157,23 @@ template<typename T>
template<typename T> struct underflow { };
// Set various signals handler for trapping aritmetic ops.
void set_signals_handler()
{
signal_adapter(signal, SIGFPE, signal_handler);
signal_adapter(signal, SIGTRAP, signal_handler);
// This is necessary for Linux/SPARC.
signal_adapter(signal, SIGILL, signal_handler);
}
// traps
template<typename T> void traps()
{
fflush(NULL);
signal_adapter (signal, SIGFPE, signal_handler);
signal_adapter (signal, SIGTRAP, signal_handler);
set_signals_handler();
bool trap_flag = trapping(division_by_zero<T>());
signal_adapter (signal, SIGFPE, signal_handler);
signal_adapter (signal, SIGTRAP, signal_handler);
set_signals_handler();
trap_flag = trap_flag || trapping(overflow<T>());
const char* p = bool_alpha[trap_flag];
printf("%s%s = %s;\n", tab2, "static const bool traps", p);
@ -175,8 +183,7 @@ template<typename T> void traps()
template<> void traps< T >() \
{ \
fflush(NULL); \
signal_adapter (signal, SIGFPE, signal_handler); \
signal_adapter (signal, SIGTRAP, signal_handler); \
set_signals_handler(); \
const char* p = bool_alpha[trapping(division_by_zero<T>())]; \
printf("%s%s = %s;\n", tab2, "static const bool traps", p); \
}