diff --git a/icu4c/source/common/cstring.c b/icu4c/source/common/cstring.c index 88e51acf145..ebd01a3b41b 100644 --- a/icu4c/source/common/cstring.c +++ b/icu4c/source/common/cstring.c @@ -18,7 +18,8 @@ * * Date Name Description * 6/18/98 hshih Created -* 09/08/98 stephen Added include for ctype, for Mac Port +* 09/08/98 stephen Added include for ctype, for Mac Port +* 11/15/99 helena Integrated S/390 IEEE changes. ***************************************************************************************** */ @@ -31,15 +32,7 @@ #include #include #include - -char T_CString_toffst(char a) -{ - if (a>0x39) return 0x37; - else return 0x30; -} - - -#define T_CString_itosOffset(a) a<=9?(0x30+a):(0x30+a+7) +#include "putil.h" char* T_CString_toLowerCase(char* str) @@ -97,24 +90,9 @@ void T_CString_integerToString(char* buffer, int32_t i, int32_t radix) int32_t T_CString_stringToInteger(const char *integerString, int32_t radix) { - - /* int32_t integer = 0; - int8_t sign = (integerString[0]=='-')?(1):0; - uint32_t i = sign; - int8_t digit;*/ char *end; return strtoul(integerString, &end, radix); - /* for (;integerString[i];i++) - { - digit = toupper(integerString[i]) - T_CString_toffst((char)toupper(integerString[i])); - if ((digit<0)||(digit>=radix)) { - return 0; - } - integer = integer*radix + digit; - } - - if (sign) return (-1)*integer; - else return integer;*/ + } diff --git a/icu4c/source/common/putil.c b/icu4c/source/common/putil.c index d5fbca145b4..a05e359f703 100644 --- a/icu4c/source/common/putil.c +++ b/icu4c/source/common/putil.c @@ -34,6 +34,7 @@ * 04/15/99 stephen Converted to C. * 06/28/99 stephen Removed mutex locking in u_isBigEndian(). * 08/04/99 jeffrey R. Added OS/2 changes +* 11/15/99 helena Integrated S/390 IEEE support. ******************************************************************************* */ @@ -68,8 +69,15 @@ #endif /* We return QNAN rather than SNAN*/ +#ifdef IEEE_754 #define NAN_TOP ((int16_t)0x7FF8) #define INF_TOP ((int16_t)0x7FF0) +#else +#ifdef OS390 +#define NAN_TOP ((int16_t)0x7F08) +#define INF_TOP ((int16_t)0x3F00) +#endif +#endif #define SIGN 0x80000000L @@ -174,6 +182,15 @@ icu_isNaN(double number) /* If your platform doesn't support IEEE 754 but *does* have an NaN value,*/ /* you'll need to replace this default implementation with what's correct*/ /* for your platform.*/ +#ifdef OS390 + uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, + sizeof(uint32_t)); + uint32_t lowBits = *(uint32_t*)u_bottomNBytesOfDouble(&number, + sizeof(uint32_t)); + + return ((highBits & 0x7F000000L) == 0x7F000000L) && + (((highBits & 0x000FFFFFL) != 0) || (lowBits != 0)); +#endif return number != number; #endif } @@ -224,6 +241,11 @@ icu_isNegativeInfinity(double number) #ifdef IEEE_754 return (number < 0 && icu_isInfinite(number)); #else +#ifdef OS390 + uint32_t highBits = *(uint32_t*)u_topNBytesOfDouble(&number, + sizeof(uint32_t)); + return((highBits & SIGN) && icu_isInfinite(number)); +#endif return icu_isInfinite(number); #endif } @@ -231,7 +253,7 @@ icu_isNegativeInfinity(double number) double icu_getNaN() { -#ifdef IEEE_754 +#if defined(IEEE_754) || defined(OS390) if( ! fgNaNInitialized) { umtx_lock(NULL); if( ! fgNaNInitialized) { @@ -392,8 +414,13 @@ icu_fmax(double x, double y) return (x > y ? x : y); #else /* {sfb} fix this*/ +#ifdef OS390 +/* this should work for all flt point w/o NaN and Infpecial cases */ + return (x > y ? x : y); +#else return x; #endif +#endif } int32_t @@ -420,8 +447,14 @@ icu_fmin(double x, double y) return (x > y ? y : x); #else /* {sfb} fix this*/ +#ifdef OS390 +/* this should work for all flt point w/o NaN and Inf special cases */ + + return (x > y ? y : x); +#else return x; #endif +#endif } int32_t @@ -565,8 +598,12 @@ int32_t icu_timezone() { #ifdef POSIX +#ifdef OS390 + return _timezone; +#else return timezone; #endif +#endif #if defined(OS400) || defined(XP_MAC) time_t t, t1, t2; @@ -612,9 +649,11 @@ icu_getDefaultDataDirectory() { #ifdef POSIX static char *PATH = 0; +#ifndef OS390 if(PATH == 0) { umtx_lock(NULL); if(PATH == 0) { +#endif /* Normally, the locale and converter data will be installed in the same tree as the ICU libraries - typically /usr/local/lib for the libraries, /usr/local/include for the headers, and @@ -632,8 +671,11 @@ icu_getDefaultDataDirectory() PATH = ICU_DATA_DIR; } } +#ifndef OS390 + } umtx_unlock(NULL); } +#endif return PATH; #endif @@ -930,6 +972,9 @@ icu_nextDouble(double d, bool_t next) *lowResult = lowMagnitude; return result; #else +#ifdef OS390 + double last_eps,sum; +#endif /* This is the portable implementation...*/ /* a small coefficient within the precision of the mantissa*/ static const double smallValue = 1e-10; @@ -938,7 +983,12 @@ icu_nextDouble(double d, bool_t next) if (!next) epsilon = -epsilon; double last_eps = epsilon * 2.0; /* avoid higher precision possibly used for temporay values*/ +#ifdef OS390 + last_eps = epsilon * 2.0; + sum = d + epsilon; +#else double sum = d + epsilon; +#endif while ((sum != d) && (epsilon != last_eps)) { last_eps = epsilon; epsilon /= 2.0; diff --git a/icu4c/source/common/putil.h b/icu4c/source/common/putil.h index 42428867b49..603885d3d51 100644 --- a/icu4c/source/common/putil.h +++ b/icu4c/source/common/putil.h @@ -20,6 +20,7 @@ * 08/24/98 stephen Added longBitsFromDouble * 03/02/99 stephen Removed openFile(). Added AS400 support. * 04/15/99 stephen Converted to C +* 11/15/99 helena Integrated S/390 changes for IEEE support. ******************************************************************************* */ @@ -61,6 +62,18 @@ U_CAPI int32_t U_EXPORT2 icu_max(int32_t x, int32_t y); U_CAPI int32_t U_EXPORT2 icu_min(int32_t x, int32_t y); U_CAPI double U_EXPORT2 icu_trunc(double d); U_CAPI void U_EXPORT2 icu_longBitsFromDouble(double d, int32_t *hi, uint32_t *lo); +#if U_IS_BIG_ENDIAN +# define icu_isNegative(number) (*((signed char *)&(number))<0) +#else +# define icu_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0) +#endif + +/* Conversion from a digit to the character with radix base from 2-19 */ +#ifndef OS390 +#define T_CString_itosOffset(a) a<=9?(0x30+a):(0x30+a+7) +#else +#define T_CString_itosOffset(a) a<=9?(0xF0+a):(0xC1+a-10) /* C1 is EBCDIC 'A' */ +#endif /* * Return the floor of the log base 10 of a given double. diff --git a/icu4c/source/common/rbcache.h b/icu4c/source/common/rbcache.h index 623b2fcd644..0d86f325a6d 100644 --- a/icu4c/source/common/rbcache.h +++ b/icu4c/source/common/rbcache.h @@ -36,7 +36,7 @@ class U_COMMON_API ResourceBundleCache // Not really external; just making the ~ResourceBundleCache(); UHashtable* hashTable; private: - static void deleteValue(void* value); + static void U_CALLCONV deleteValue(void* value); }; /** diff --git a/icu4c/source/common/rbdata.h b/icu4c/source/common/rbdata.h index 44d3d04fb55..f0c82f835d3 100644 --- a/icu4c/source/common/rbdata.h +++ b/icu4c/source/common/rbdata.h @@ -85,7 +85,7 @@ public: virtual UClassID getDynamicClassID(void) const; static UClassID getStaticClassID(void); - static void deleteValue(void* value); + static void U_CALLCONV deleteValue(void* value); static UClassID fgClassID; UHashtable *fHashtableValues; diff --git a/icu4c/source/common/rbread.cpp b/icu4c/source/common/rbread.cpp index b89b4505b93..9006cd1e0bf 100644 --- a/icu4c/source/common/rbread.cpp +++ b/icu4c/source/common/rbread.cpp @@ -40,7 +40,7 @@ static String2dList* read_strlist2d(FileStream *rb, UnicodeString& listname, UErrorCode& status); static TaggedList* read_taglist(FileStream *rb, UnicodeString& listname, UErrorCode& status); -static void RBHashtable_valueDeleter(void *value); +static void U_CALLCONV RBHashtable_valueDeleter(void *value); /* Read a string from a compiled resource file */ diff --git a/icu4c/source/common/uhash.h b/icu4c/source/common/uhash.h index 2a874771fe3..482ca9f1559 100644 --- a/icu4c/source/common/uhash.h +++ b/icu4c/source/common/uhash.h @@ -42,7 +42,7 @@ typedef int32_t (*UHashFunction)(const void*); * and uhash_put * @param parm A pointer to the data to be hashed. */ -typedef void (*ValueDeleter)(void* valuePtr); +typedef void (* U_CALLCONV ValueDeleter)(void* valuePtr); /** The UHashtable struct */ struct UHashtable { diff --git a/icu4c/source/common/utypes.h b/icu4c/source/common/utypes.h index 7a29b25cff6..62d78f57234 100644 --- a/icu4c/source/common/utypes.h +++ b/icu4c/source/common/utypes.h @@ -132,6 +132,13 @@ typedef uint16_t UChar; #endif #define U_CAPI U_CFUNC U_EXPORT +/* Work around the OS390 compiler issue, to be removed when the compiler +updates come out. */ +#ifdef OS390 +# define U_CALLCONV __cdecl +#else +# define U_CALLCONV +#endif /* Define NULL pointer value if it isn't already defined */ diff --git a/icu4c/source/i18n/colcache.cpp b/icu4c/source/i18n/colcache.cpp index 1be45e735b5..0f7dbf57d98 100644 --- a/icu4c/source/i18n/colcache.cpp +++ b/icu4c/source/i18n/colcache.cpp @@ -42,7 +42,7 @@ // CollationCache implementation //-------------------------------------------------------------------------------- -static void deleteTCD(void* TCD) +static void U_CALLCONV deleteTCD(void* TCD) { delete (TableCollationData*)TCD; } diff --git a/icu4c/source/i18n/decimfmt.cpp b/icu4c/source/i18n/decimfmt.cpp index 9501abd59c1..e986b964379 100644 --- a/icu4c/source/i18n/decimfmt.cpp +++ b/icu4c/source/i18n/decimfmt.cpp @@ -550,7 +550,7 @@ DecimalFormat::format( double number, * -Infinity. Proper detection of -0.0 is needed to deal with the * issues raised by bugs 4106658, 4106667, and 4147706. Liu 7/6/98. */ - bool_t isNegative = (number < 0.0) || (number == 0.0 && 1/number < 0.0); + bool_t isNegative = icu_isNegative(number); if (isNegative) number = -number; // Do this BEFORE checking to see if value is infinite! Sets the diff --git a/icu4c/source/i18n/timezone.h b/icu4c/source/i18n/timezone.h index ddb2c6a6f0e..3d13fe70dfe 100644 --- a/icu4c/source/i18n/timezone.h +++ b/icu4c/source/i18n/timezone.h @@ -442,7 +442,7 @@ private: /** * Delete function for fgHashtable. */ - static void deleteTimeZone(void*); + static void U_CALLCONV deleteTimeZone(void*); static int32_t fTimezoneCount; static UHashtable* fgHashtable; // hash table of objects in kSystemTimeZones,