diff --git a/common/ttcn3float.hh b/common/ttcn3float.hh index 1819166d1966b51c40af0de5a55e932766819d75..ba67e29324bb53a4413c1fd1bbfd292a0ff2481c 100644 --- a/common/ttcn3float.hh +++ b/common/ttcn3float.hh @@ -14,7 +14,7 @@ #ifndef TTCN3FLOAT_HH_ #define TTCN3FLOAT_HH_ -#include <cmath> +#include <math.h> /* TTCN-3 float values that have absolute value smaller than this are displayed in exponential notation. */ @@ -23,31 +23,31 @@ are displayed in exponential notation. */ #define MAX_DECIMAL_FLOAT 1.0E+10 -//#ifndef signbit -// Probably Solaris. -// Thankfully, IEEE Std 1003.1, 2004 Edition says that signbit is a macro, -// hence it's safe to use ifdef. +#ifndef signbit + Probably Solaris. + Thankfully, IEEE Std 1003.1, 2004 Edition says that signbit is a macro, + hence it's safe to use ifdef. -//#ifdef __sparc -//// Big endian +#ifdef __sparc +// Big endian -//inline int signbitfunc(double d) -//{ -// return *((unsigned char*)&d) & 0x80; -//} +inline int signbitfunc(double d) +{ + return *((unsigned char*)&d) & 0x80; +} -//#else -// Probably Intel, assume little endian -//inline int signbitfunc(double d) -//{ -// return ((unsigned char*)&d)[sizeof(double)-1] & 0x80; -//} +#else + Probably Intel, assume little endian +inline int signbitfunc(double d) +{ + return ((unsigned char*)&d)[sizeof(double)-1] & 0x80; +} -//#endif +#endif -//#define signbit(d) signbitfunc(d) +#define signbit(d) signbitfunc(d) -//#endif // def signbit +#endif // def signbit /** A class which behaves almost, but not quite, entirely unlike * a floating-point value. @@ -89,14 +89,14 @@ struct ttcn3float { } bool operator<(double d) const { - if (std::isnan(value)) { + if (isnan(value)) { return false; // TTCN-3 special: NaN is bigger than anything except NaN } - else if (std::isnan(d)) { + else if (isnan(d)) { return true; // TTCN-3 special: NaN is bigger than anything except NaN } else if (value==0.0 && d==0.0) { // does not distinguish -0.0 - return std::signbit(value) && !std::signbit(d); // value negative, d positive + return signbit(value) && !signbit(d); // value negative, d positive } else { // finally, the sensible behavior return value < d; @@ -104,14 +104,14 @@ struct ttcn3float { } bool operator>(double d) const { - if (std::isnan(value)) { + if (isnan(value)) { return true; // TTCN-3 special: NaN is bigger than anything except NaN } - else if (std::isnan(d)) { + else if (isnan(d)) { return false; // TTCN-3 special: NaN is bigger than anything except NaN } else if (value==0.0 && d==0.0) { // does not distinguish -0.0 - return !std::signbit(value) && std::signbit(d); // value positive, d negative + return !signbit(value) && signbit(d); // value positive, d negative } else { // finally, the sensible behavior return value > d; @@ -119,14 +119,14 @@ struct ttcn3float { } bool operator==(double d) const { - if (std::isnan(value)) { - return !!std::isnan(d); // TTCN-3 special: NaN is bigger than anything except NaN + if (isnan(value)) { + return !!isnan(d); // TTCN-3 special: NaN is bigger than anything except NaN } - else if (std::isnan(d)) { + else if (isnan(d)) { return false; } else if (value==0.0 && d==0.0) { // does not distinguish -0.0 - return std::signbit(value) == std::signbit(d); + return signbit(value) == signbit(d); } else { // finally, the sensible behavior return value == d; diff --git a/core/Float.cc b/core/Float.cc index a741a0ffb65d9fbe67d46bf1a0eb1ceac535fc52..c0f7a9ff3e489de0b838acf13b4aec51accddc71 100644 --- a/core/Float.cc +++ b/core/Float.cc @@ -23,7 +23,7 @@ * ******************************************************************************/ #include <string.h> -#include <cmath> +#include <math.h> #include <float.h> #include "../common/memory.h" @@ -459,7 +459,7 @@ FLOAT::BER_encode_TLV(const TTCN_Typedescriptor_t& p_td, new_tlv=ASN_BER_TLV_t::construct(1, NULL); new_tlv->V.str.Vstr[0]=0x41; } - else if(std::isnan((double)float_value)) { + else if(isnan((double)float_value)) { TTCN_EncDec_ErrorContext::error_internal("Value is NaN."); } else { @@ -673,7 +673,7 @@ int FLOAT::RAW_encode(const TTCN_Typedescriptor_t& p_td, RAW_enc_tree& myleaf) c "Encoding an unbound value."); tmp = 0.0; } - if (std::isnan(tmp)) { + if (isnan(tmp)) { TTCN_EncDec_ErrorContext::error_internal("Value is NaN."); } if (myleaf.must_free) Free(myleaf.body.leaf.data_ptr); @@ -786,7 +786,7 @@ int FLOAT::RAW_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& buff, #else for (int i = 0, k = 7; i < 8; i++, k--) dv[i] = data[k]; #endif - if (std::isnan(tmp)) { + if (isnan(tmp)) { if (no_err) return -1; TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_LEN_ERR, "Not a Number received for type %s.", p_td.name); @@ -848,7 +848,7 @@ int FLOAT::XER_encode(const XERdescriptor_t& p_td, if (exer && (p_td.xer_bits & XER_DECIMAL)) { char buf[312]; int n = 0; - if (std::isnan((double)float_value)) { + if (isnan((double)float_value)) { n = snprintf(buf, sizeof(buf), "%s", XER_NAN_STR); } else if ((double)float_value == (double)INFINITY) { n = snprintf(buf, sizeof(buf), "%s", XER_POS_INF_STR); @@ -869,7 +869,7 @@ int FLOAT::XER_encode(const XERdescriptor_t& p_td, } else { CHARSTRING value; - if (std::isnan((double)float_value)) { + if (isnan((double)float_value)) { value = XER_NAN_STR; } else if ((double)float_value == (double)INFINITY) { value = XER_POS_INF_STR; @@ -1074,7 +1074,7 @@ int FLOAT::JSON_encode(const TTCN_Typedescriptor_t&, JSON_Tokenizer& p_tok) cons if (-(double)INFINITY == value) { return p_tok.put_next_token(JSON_TOKEN_STRING, NEG_INF_STR); } - if (std::isnan(value)) { + if (isnan(value)) { return p_tok.put_next_token(JSON_TOKEN_STRING, NAN_STR); } diff --git a/core/Snapshot.cc b/core/Snapshot.cc index 4d8f497b71248668386ead2c3d46e8cd14a8be06..7cf570f38348ed1f821a66de743f649a78fb0fb2 100644 --- a/core/Snapshot.cc +++ b/core/Snapshot.cc @@ -22,7 +22,7 @@ #include <string.h> #include <time.h> #include <sys/time.h> -#include <cmath> +#include <math.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> @@ -1086,7 +1086,7 @@ void TTCN_Snapshot::take_new(boolean block_execution) // the first timeout is in the future: blocking is needed // filling up tv with appropriate values if (block_time < (double)MAX_BLOCK_TIME) { - pollTimeout = static_cast<int>(std::floor(block_time*1000)); + pollTimeout = static_cast<int>(floor(block_time*1000)); handleTimer = TRUE; } else { // issue a warning: the user probably does not want such diff --git a/xsdconvert/SimpleType.cc b/xsdconvert/SimpleType.cc index 0cc34b95b1b21feecff9399e011266ed5e3953a0..c9c857c952d390e3b7a2ac5d60b4bcd149e90563 100644 --- a/xsdconvert/SimpleType.cc +++ b/xsdconvert/SimpleType.cc @@ -23,7 +23,7 @@ #include "ComplexType.hh" #include "Constant.hh" -#include <cmath> +#include <math.h> #include <cfloat> extern bool g_flag_used; @@ -1372,12 +1372,12 @@ void EnumerationType::printToFile(FILE * file, unsigned int indent_level) const fprintf(file, "infinity"); } else if (itemFloat->Data == MINUS_INFINITY) { fprintf(file, "-infinity"); - } else if (std::isnan(itemFloat->Data)) { + } else if (isnan(itemFloat->Data)) { fprintf(file, "not_a_number"); } else { double intpart = 0; double fracpart = 0; - fracpart = std::modf(itemFloat->Data, &intpart); + fracpart = modf(itemFloat->Data, &intpart); if (fracpart == 0) { fprintf(file, "%lld.0", (long long int) (itemFloat->Data)); } else { @@ -1547,7 +1547,7 @@ void ValueType::applyFacets() // only for integer and float types // totalDigits facet is only for integer types and decimal if (facet_totalDigits > 0) // if this facet is used { - double r = std::pow(10.0, facet_totalDigits); + double r = pow(10.0, facet_totalDigits); if (base == "integer") { lower = (int) -(r - 1); @@ -1691,7 +1691,7 @@ void ValueType::printToFile(FILE * file) const { } else { double intpart = 0; double fracpart = 0; - fracpart = std::modf(lower, &intpart); + fracpart = modf(lower, &intpart); if (fracpart == 0) { fprintf(file, "%.1Lf", lower); } else { @@ -1709,7 +1709,7 @@ void ValueType::printToFile(FILE * file) const { } else { double intpart = 0; double fracpart = 0; - fracpart = std::modf(upper, &intpart); + fracpart = modf(upper, &intpart); if (fracpart == 0) { fprintf(file, "%.1Lf", upper); } else {