Commit e6ff97b1 by Rodney Brown Committed by Benjamin Kosnik

gen-num-limits.cc (traps): Add fflush prior to trapping signal (UnixWare 7 workaround).


2001-03-12  Rodney Brown  <RodneyBrown@mynd.com>

        * src/gen-num-limits.cc (traps) [SPECIALIZE_TRAPPING]: Add fflush
        prior to trapping signal (UnixWare 7 workaround).

From-SVN: r40422
parent 23712c11
2001-03-12 Rodney Brown <RodneyBrown@mynd.com>
* src/gen-num-limits.cc (traps) [SPECIALIZE_TRAPPING]: Add fflush
prior to trapping signal (UnixWare 7 workaround).
2001-03-12 Craig Rodrigues <rodrigc@mediaone.net>
* include/backward/hashtable.h: Same.
......
......@@ -139,16 +139,20 @@ bool trapping(const Operation& op)
return false;
}
template<typename T> struct division_by_zero {
template<typename T>
struct division_by_zero
{
void operator() () const
{
volatile T zero = T();
volatile T one = T(1);
volatile T infinity = one / zero;
}
};
};
template<typename T> struct overflow {
template<typename T>
struct overflow
{
void operator() () const
{
T i = T(1);
......@@ -158,13 +162,14 @@ template<typename T> struct overflow {
i = i * 2 + 1;
}
}
};
};
template<typename T> struct underflow {};
template<typename T> struct underflow { };
// traps
template<typename T> void traps()
{
fflush(NULL);
signal_adapter (signal, SIGFPE, signal_handler);
signal_adapter (signal, SIGTRAP, signal_handler);
bool trap_flag = trapping(division_by_zero<T>());
......@@ -178,6 +183,7 @@ template<typename T> void traps()
#define SPECIALIZE_TRAPPING(T) \
template<> void traps< T >() \
{ \
fflush(NULL); \
signal_adapter (signal, SIGFPE, signal_handler); \
signal_adapter (signal, SIGTRAP, signal_handler); \
const char* p = bool_alpha[trapping(division_by_zero<T>())]; \
......@@ -194,10 +200,12 @@ SPECIALIZE_TRAPPING(unsigned long long);
#undef SPECIALIZE_TRAPPING
template<typename T> struct type_name_trait {
template<typename T>
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,25 +233,26 @@ DEFINED_TYPE_NAME(long double);
#undef DEFINED_TYPE_NAME
// declarator
template<typename T> struct declarator : type_name_trait<T> {
template<typename T>
struct declarator : type_name_trait<T>
{
typedef type_name_trait<T> 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<typename T> struct predicate {
template<typename T>
struct predicate
{
static const bool is_signed;
static const bool is_integer;
static const bool is_exact;
......@@ -258,7 +267,7 @@ template<typename T> struct predicate {
static const bool is_bounded;
static const bool traps;
};
};
template<typename T>
const bool predicate<T>::is_signed = T(-1) < 0;
......@@ -321,8 +330,9 @@ SPECIALIZE_IEC559(unsigned long long);
//
// Values
//
template<typename T> struct value {
template<typename T>
struct value
{
static const char min[];
static const char max[];
......@@ -337,7 +347,7 @@ template<typename T> struct value {
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) \
......@@ -639,7 +649,9 @@ void has_denorm_loss()
bool_alpha[predicate<T>::has_denorm_loss]);
}
template<typename T> struct infinity_trait {
template<typename T>
struct infinity_trait
{
static void has_denorm()
{
printf("%s%s;\n", tab2, "static const float_denorm_style "
......@@ -649,9 +661,8 @@ template<typename T> struct infinity_trait {
static void infinity()
{
printf("%s%s %s %s\n%s%s%s%s\n", tab2, "static",
declarator<T>::type_name, "infinity() throw()",
tab2, "{ return static_cast<", declarator<T>::type_name,
">(0); }");
declarator<T>::type_name, "infinity() throw()", tab2,
"{ return static_cast<", declarator<T>::type_name, ">(0); }");
}
static void quiet_NaN()
......@@ -677,7 +688,7 @@ template<typename T> struct infinity_trait {
tab2, "{ return static_cast<", declarator<T>::type_name,
">(0); }");
}
};
};
template<typename T>
......@@ -705,8 +716,9 @@ void round_style()
// type traits
template<typename T> struct type_trait {
template<typename T>
struct type_trait
{
type_trait()
{
declarator<T>::start();
......@@ -748,7 +760,7 @@ template<typename T> struct type_trait {
round_style<T>();
declarator<T>::end();
}
};
};
int main()
{
......
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