+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.
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);
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); \
}