From 28a167b3bda43c2ddf9cf8a2a7e312077b6095bf Mon Sep 17 00:00:00 2001 From: gbeauche <> Date: Wed, 22 Jun 2005 12:27:01 +0000 Subject: [PATCH] Avoid to determine vector register numeric_limits<>. This fixes build with ancient compilers like gcc "2.96". --- .../src/kpx_cpu/src/cpu/ppc/ppc-operands.hpp | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operands.hpp b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operands.hpp index 758d5d53..95716ac9 100644 --- a/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operands.hpp +++ b/SheepShaver/src/kpx_cpu/src/cpu/ppc/ppc-operands.hpp @@ -21,7 +21,34 @@ #ifndef PPC_OPERANDS_H #define PPC_OPERANDS_H -#include +/** + * Numerical limits of vector registers components + **/ + +template< class type > +struct vector_numeric_limits { + static type min() throw(); + static type max() throw(); +}; + +#define DEFINE_NUMERIC_LIMITS(TYPE, SMAX, USFX) \ +template<> \ +struct vector_numeric_limits { \ + static inline TYPE min() throw() { return -(SMAX) - 1; } \ + static inline TYPE max() throw() { return SMAX; } \ +}; \ +template<> \ +struct vector_numeric_limits { \ + static inline u##TYPE min() throw() { return 0##USFX; } \ + static inline u##TYPE max() throw() { return SMAX * 2##USFX + 1; } \ +} + +DEFINE_NUMERIC_LIMITS( int8, 127, U); +DEFINE_NUMERIC_LIMITS(int16, 32767, U); +DEFINE_NUMERIC_LIMITS(int32, 2147483647L, UL); +DEFINE_NUMERIC_LIMITS(int64, 9223372036854775807LL, ULL); + +#undef DEFINE_NUMERIC_LIMITS /** * Compile time checks @@ -196,12 +223,12 @@ struct vector_saturate_operand : input_vr< field >, output_vr< field > { static const uint32 element_size = sizeof(value_type); static inline bool saturate(element_type & v) { bool sat = false; - if (v > std::numeric_limits::max()) { - v = std::numeric_limits::max(); + if (v > vector_numeric_limits::max()) { + v = vector_numeric_limits::max(); sat = true; } - else if (v < std::numeric_limits::min()) { - v = std::numeric_limits::min(); + else if (v < vector_numeric_limits::min()) { + v = vector_numeric_limits::min(); sat = true; } return sat;