From e6ff97b1c4f478ca3565810aa4bc81cc3aa114ae Mon Sep 17 00:00:00 2001 From: Rodney Brown Date: Mon, 12 Mar 2001 19:21:29 +0000 Subject: [PATCH] gen-num-limits.cc (traps): Add fflush prior to trapping signal (UnixWare 7 workaround). 2001-03-12 Rodney Brown * src/gen-num-limits.cc (traps) [SPECIALIZE_TRAPPING]: Add fflush prior to trapping signal (UnixWare 7 workaround). From-SVN: r40422 --- libstdc++-v3/ChangeLog | 5 + libstdc++-v3/src/gen-num-limits.cc | 378 +++++++++++++++-------------- 2 files changed, 200 insertions(+), 183 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index f2229d93932..e871a658837 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2001-03-12 Rodney Brown + + * src/gen-num-limits.cc (traps) [SPECIALIZE_TRAPPING]: Add fflush + prior to trapping signal (UnixWare 7 workaround). + 2001-03-12 Craig Rodrigues * include/backward/hashtable.h: Same. diff --git a/libstdc++-v3/src/gen-num-limits.cc b/libstdc++-v3/src/gen-num-limits.cc index 7a1416cd768..1a9df6fdd3c 100644 --- a/libstdc++-v3/src/gen-num-limits.cc +++ b/libstdc++-v3/src/gen-num-limits.cc @@ -139,49 +139,55 @@ bool trapping(const Operation& op) return false; } -template struct division_by_zero { +template + struct division_by_zero + { void operator() () const { - volatile T zero = T(); - volatile T one = T(1); - volatile T infinity = one / zero; + volatile T zero = T(); + volatile T one = T(1); + volatile T infinity = one / zero; } -}; + }; -template struct overflow { +template + struct overflow + { void operator() () const { - T i = T(1); - T j = T(); - while (i>j) { - j = i; - i = i * 2 + 1; - } + T i = T(1); + T j = T(); + while (i>j) { + j = i; + i = i * 2 + 1; + } } -}; + }; -template struct underflow {}; +template struct underflow { }; // traps template void traps() { - signal_adapter (signal, SIGFPE, signal_handler); - signal_adapter (signal, SIGTRAP, signal_handler); - bool trap_flag = trapping(division_by_zero()); - 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); + fflush(NULL); + signal_adapter (signal, SIGFPE, signal_handler); + signal_adapter (signal, SIGTRAP, signal_handler); + bool trap_flag = trapping(division_by_zero()); + 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); } #define SPECIALIZE_TRAPPING(T) \ template<> void traps< T >() \ -{ \ - 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); \ +{ \ + fflush(NULL); \ + 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); \ } SPECIALIZE_TRAPPING(unsigned char); @@ -194,10 +200,12 @@ SPECIALIZE_TRAPPING(unsigned long long); #undef SPECIALIZE_TRAPPING -template struct type_name_trait { +template + struct type_name_trait + { static const char type_name[]; static const char trait_name[]; -}; + }; #define DEFINED_TYPE_NAME(T) \ const char type_name_trait< T >::type_name[] = #T; \ @@ -225,40 +233,41 @@ DEFINED_TYPE_NAME(long double); #undef DEFINED_TYPE_NAME // declarator -template struct declarator : type_name_trait { +template + struct declarator : type_name_trait + { typedef type_name_trait base; static void start() - { - printf("%s%s %s %s\n", tab, "template<> struct", - base::trait_name, "{"); + { + printf("%s%s %s %s\n", tab, "template<> struct", base::trait_name, "{"); } - + static void end() - { - printf("%s};\n\n", tab); - } -}; + { printf("%s};\n\n", tab); } + }; // // Predicates // -template struct predicate { +template + struct predicate + { static const bool is_signed; static const bool is_integer; static const bool is_exact; - + static const bool has_infinity; static const bool has_quiet_nan; static const bool has_signaling_nan; static const bool has_denorm; static const bool has_denorm_loss; - + static const bool is_iec559; static const bool is_bounded; - + static const bool traps; -}; + }; template const bool predicate::is_signed = T(-1) < 0; @@ -321,23 +330,24 @@ SPECIALIZE_IEC559(unsigned long long); // // Values // - -template struct value { +template + struct value + { static const char min[]; static const char max[]; - + static const int digits; static const int digits10; static const int radix; static const char epsilon[]; static const char round_error[]; - + static const int min_exponent; static const int min_exponent10; static const int max_exponent; static const int max_exponent10; -}; + }; #define DEFINE_EXTREMA(T, m, M) DO_DEFINE_EXTREMA(T, m, M) #define DO_DEFINE_EXTREMA(T, m, M) \ @@ -507,283 +517,285 @@ SPECIALIZE_EXPONENTS(long double, LDBL_MIN_EXP, LDBL_MIN_10_EXP, template void is_signed() { - printf("%s%s = %s;\n", tab2, "static const bool is_signed", - bool_alpha[predicate::is_signed]); + printf("%s%s = %s;\n", tab2, "static const bool is_signed", + bool_alpha[predicate::is_signed]); } // a fundamental type is modulo iff it isn't signed template void is_modulo() { - printf("%s%s = %s;\n", tab2, "static const bool is_modulo", - bool_alpha[! predicate::is_signed]); + printf("%s%s = %s;\n", tab2, "static const bool is_modulo", + bool_alpha[! predicate::is_signed]); } template void min() { - printf("%s%s%s%s\n%s%s%s%s\n", tab2, "static ", declarator::type_name, - " min() throw()", tab2, "{ return ", value::min, "; }"); + printf("%s%s%s%s\n%s%s%s%s\n", tab2, "static ", declarator::type_name, + " min() throw()", tab2, "{ return ", value::min, "; }"); } template void max() { - printf("%s%s%s%s\n%s%s%s%s\n", tab2, "static ", declarator::type_name, - " max() throw()", tab2, "{ return ", value::max, "; }"); + printf("%s%s%s%s\n%s%s%s%s\n", tab2, "static ", declarator::type_name, + " max() throw()", tab2, "{ return ", value::max, "; }"); } template void is_integer() { - printf("%s%s = %s;\n", tab2, "static const bool is_integer", - bool_alpha[predicate::is_integer]); + printf("%s%s = %s;\n", tab2, "static const bool is_integer", + bool_alpha[predicate::is_integer]); } template void is_exact() { - printf("%s%s = %s;\n", tab2, "static const bool is_exact", - bool_alpha[predicate::is_exact]); + printf("%s%s = %s;\n", tab2, "static const bool is_exact", + bool_alpha[predicate::is_exact]); } template void digits() { - printf("%s%s = %d;\n", tab2, "static const int digits", - value::digits); + printf("%s%s = %d;\n", tab2, "static const int digits", + value::digits); } template void digits10() { - printf("%s%s = %d;\n", tab2, "static const int digits10", - int(log10_of_two * value::digits)); + printf("%s%s = %d;\n", tab2, "static const int digits10", + int(log10_of_two * value::digits)); } template void radix() { - printf("%s%s = %d;\n", tab2, "static const int radix", - value::radix); + printf("%s%s = %d;\n", tab2, "static const int radix", + value::radix); } template void epsilon() { - printf("%s%s %s %s\n%s%s %s%s\n", tab2, "static", - declarator::type_name, "epsilon() throw()", - tab2, "{ return", value::epsilon, "; }"); + printf("%s%s %s %s\n%s%s %s%s\n", tab2, "static", + declarator::type_name, "epsilon() throw()", + tab2, "{ return", value::epsilon, "; }"); } template void round_error() { - printf("%s%s %s %s\n%s%s %s%s\n", tab2, "static", - declarator::type_name, "round_error() throw()", - tab2, "{ return", value::round_error, "; }"); + printf("%s%s %s %s\n%s%s %s%s\n", tab2, "static", + declarator::type_name, "round_error() throw()", + tab2, "{ return", value::round_error, "; }"); } template void min_exponent() { - printf("%s%s = %d;\n", tab2, "static const int min_exponent", - value::min_exponent); + printf("%s%s = %d;\n", tab2, "static const int min_exponent", + value::min_exponent); } template void min_exponent10() { - printf("%s%s = %d;\n", tab2, "static const int min_exponent10", - value::min_exponent10); + printf("%s%s = %d;\n", tab2, "static const int min_exponent10", + value::min_exponent10); } template void max_exponent() { - printf("%s%s = %d;\n", tab2, "static const int max_exponent", - value::max_exponent); + printf("%s%s = %d;\n", tab2, "static const int max_exponent", + value::max_exponent); } template void max_exponent10() { - printf("%s%s = %d;\n", tab2, "static const int max_exponent10", - value::max_exponent10); + printf("%s%s = %d;\n", tab2, "static const int max_exponent10", + value::max_exponent10); } template void has_infinity() { - printf("%s%s = %s;\n", tab2, "static const bool has_infinity", - bool_alpha[predicate::has_infinity]); + printf("%s%s = %s;\n", tab2, "static const bool has_infinity", + bool_alpha[predicate::has_infinity]); } template void has_quiet_nan() { - printf("%s%s = %s;\n", tab2, "static const bool has_quiet_NaN", - bool_alpha[predicate::has_quiet_nan]); + printf("%s%s = %s;\n", tab2, "static const bool has_quiet_NaN", + bool_alpha[predicate::has_quiet_nan]); } template void has_signaling_nan() { - printf("%s%s = %s;\n", tab2, "static const bool has_signaling_NaN", - bool_alpha[predicate::has_signaling_nan]); + printf("%s%s = %s;\n", tab2, "static const bool has_signaling_NaN", + bool_alpha[predicate::has_signaling_nan]); } template void has_denorm_loss() { - printf("%s%s = %s;\n", tab2, "static const bool has_denorm_loss", - bool_alpha[predicate::has_denorm_loss]); + printf("%s%s = %s;\n", tab2, "static const bool has_denorm_loss", + bool_alpha[predicate::has_denorm_loss]); } -template struct infinity_trait { +template + struct infinity_trait + { static void has_denorm() { - printf("%s%s;\n", tab2, "static const float_denorm_style " - "has_denorm = denorm_absent"); + printf("%s%s;\n", tab2, "static const float_denorm_style " + "has_denorm = denorm_absent"); } - + static void infinity() { - printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", - declarator::type_name, "infinity() throw()", - tab2, "{ return static_cast<", declarator::type_name, - ">(0); }"); + printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", + declarator::type_name, "infinity() throw()", tab2, + "{ return static_cast<", declarator::type_name, ">(0); }"); } static void quiet_NaN() { - printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", - declarator::type_name, "quiet_NaN() throw()", - tab2, "{ return static_cast<", declarator::type_name, - ">(0); }"); + printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", + declarator::type_name, "quiet_NaN() throw()", + tab2, "{ return static_cast<", declarator::type_name, + ">(0); }"); } - + static void signaling_NaN() { - printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", - declarator::type_name, "signaling_NaN() throw()", - tab2, "{ return static_cast<", declarator::type_name, - ">(0); }"); + printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", + declarator::type_name, "signaling_NaN() throw()", + tab2, "{ return static_cast<", declarator::type_name, + ">(0); }"); } static void denorm_min() { - printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", - declarator::type_name, "denorm_min() throw()", - tab2, "{ return static_cast<", declarator::type_name, - ">(0); }"); + printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static", + declarator::type_name, "denorm_min() throw()", + tab2, "{ return static_cast<", declarator::type_name, + ">(0); }"); } -}; + }; template void is_iec559() { - printf("%s%s = %s;\n", tab2, "static const bool is_iec559", - bool_alpha[predicate::is_iec559]); + printf("%s%s = %s;\n", tab2, "static const bool is_iec559", + bool_alpha[predicate::is_iec559]); } // tinyness_before template void tinyness_before() { - printf("%s%s;\n", tab2, "static const bool tinyness_before = false"); + printf("%s%s;\n", tab2, "static const bool tinyness_before = false"); } // round style template void round_style() { - printf("%s%s;\n", tab2, "static const float_round_style " - "round_style = round_toward_zero"); + printf("%s%s;\n", tab2, "static const float_round_style " + "round_style = round_toward_zero"); } // type traits -template struct type_trait { - +template + struct type_trait + { type_trait() { - declarator::start(); - printf("%s%s;\n\n", tab2, "static const bool is_specialized = true"); - min(); - max(); - printf("\n"); - digits(); - digits10(); - is_signed(); - is_integer(); - is_exact(); - radix(); - epsilon(); - round_error(); - printf("\n"); - min_exponent(); - min_exponent10(); - max_exponent(); - max_exponent10(); - printf("\n"); - has_infinity(); - has_quiet_nan(); - has_signaling_nan(); - infinity_trait::has_denorm(); - has_denorm_loss(); - printf("\n"); - infinity_trait::infinity(); - infinity_trait::quiet_NaN(); - infinity_trait::signaling_NaN(); - infinity_trait::denorm_min(); - printf("\n"); - is_iec559(); - printf("%s%s;\n", tab2, "static const bool is_bounded = true"); - is_modulo(); - printf("\n"); - traps(); - tinyness_before(); - round_style(); - declarator::end(); + declarator::start(); + printf("%s%s;\n\n", tab2, "static const bool is_specialized = true"); + min(); + max(); + printf("\n"); + digits(); + digits10(); + is_signed(); + is_integer(); + is_exact(); + radix(); + epsilon(); + round_error(); + printf("\n"); + min_exponent(); + min_exponent10(); + max_exponent(); + max_exponent10(); + printf("\n"); + has_infinity(); + has_quiet_nan(); + has_signaling_nan(); + infinity_trait::has_denorm(); + has_denorm_loss(); + printf("\n"); + infinity_trait::infinity(); + infinity_trait::quiet_NaN(); + infinity_trait::signaling_NaN(); + infinity_trait::denorm_min(); + printf("\n"); + is_iec559(); + printf("%s%s;\n", tab2, "static const bool is_bounded = true"); + is_modulo(); + printf("\n"); + traps(); + tinyness_before(); + round_style(); + declarator::end(); } -}; + }; int main() { - type_trait(); - - type_trait(); - type_trait(); - type_trait(); + type_trait(); + + type_trait(); + type_trait(); + type_trait(); #if defined( _GLIBCPP_USE_WCHAR_T) - type_trait(); + type_trait(); #endif - - type_trait(); - type_trait(); - - type_trait(); - type_trait(); - - type_trait(); - type_trait(); - + + type_trait(); + type_trait(); + + type_trait(); + type_trait(); + + type_trait(); + type_trait(); + #ifdef _GLIBCPP_USE_LONG_LONG - type_trait(); - type_trait(); + type_trait(); + type_trait(); #endif - type_trait(); - type_trait(); - type_trait(); - - // x86/linux gets this weirdness for the min/max functions: - // static long double min() throw() - // { return (__extension__ ((union __convert_long_double) - // {__convert_long_double_i: {0x0, 0x80000000, 0x1, 0x0}}) - // .__convert_long_double_d); } + type_trait(); + type_trait(); + type_trait(); + + // x86/linux gets this weirdness for the min/max functions: + // static long double min() throw() + // { return (__extension__ ((union __convert_long_double) + // {__convert_long_double_i: {0x0, 0x80000000, 0x1, 0x0}}) + // .__convert_long_double_d); } } // G++ doesn't have support for automatic instantiation of static data -- 2.30.2