putil.h

Go to the documentation of this file.
00001 /* 00002 ****************************************************************************** 00003 * 00004 * Copyright (C) 1997-2004, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ****************************************************************************** 00008 * 00009 * FILE NAME : putil.h 00010 * 00011 * Date Name Description 00012 * 05/14/98 nos Creation (content moved here from utypes.h). 00013 * 06/17/99 erm Added IEEE_754 00014 * 07/22/98 stephen Added IEEEremainder, max, min, trunc 00015 * 08/13/98 stephen Added isNegativeInfinity, isPositiveInfinity 00016 * 08/24/98 stephen Added longBitsFromDouble 00017 * 03/02/99 stephen Removed openFile(). Added AS400 support. 00018 * 04/15/99 stephen Converted to C 00019 * 11/15/99 helena Integrated S/390 changes for IEEE support. 00020 * 01/11/00 helena Added u_getVersion. 00021 ****************************************************************************** 00022 */ 00023 00024 #ifndef PUTIL_H 00025 #define PUTIL_H 00026 00027 #include "unicode/utypes.h" 00028 00029 /* Define this to 1 if your platform supports IEEE 754 floating point, 00030 to 0 if it does not. */ 00031 #ifndef IEEE_754 00032 # define IEEE_754 1 00033 #endif 00034 00035 /*==========================================================================*/ 00036 /* Platform utilities */ 00037 /*==========================================================================*/ 00038 00049 U_INTERNAL UBool U_EXPORT2 uprv_isNaN(double d); 00054 U_INTERNAL UBool U_EXPORT2 uprv_isInfinite(double d); 00059 U_INTERNAL UBool U_EXPORT2 uprv_isPositiveInfinity(double d); 00064 U_INTERNAL UBool U_EXPORT2 uprv_isNegativeInfinity(double d); 00069 U_INTERNAL double U_EXPORT2 uprv_getNaN(void); 00074 U_INTERNAL double U_EXPORT2 uprv_getInfinity(void); 00075 00080 U_INTERNAL double U_EXPORT2 uprv_trunc(double d); 00085 U_INTERNAL double U_EXPORT2 uprv_floor(double d); 00090 U_INTERNAL double U_EXPORT2 uprv_ceil(double d); 00095 U_INTERNAL double U_EXPORT2 uprv_fabs(double d); 00100 U_INTERNAL double U_EXPORT2 uprv_modf(double d, double* pinteger); 00105 U_INTERNAL double U_EXPORT2 uprv_fmod(double d, double y); 00110 U_INTERNAL double U_EXPORT2 uprv_pow(double d, double exponent); 00115 U_INTERNAL double U_EXPORT2 uprv_pow10(int32_t exponent); 00120 U_INTERNAL double U_EXPORT2 uprv_fmax(double d, double y); 00125 U_INTERNAL double U_EXPORT2 uprv_fmin(double d, double y); 00130 U_INTERNAL int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y); 00135 U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y); 00136 00137 #if U_IS_BIG_ENDIAN 00138 # define uprv_isNegative(number) (*((signed char *)&(number))<0) 00139 #else 00140 # define uprv_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0) 00141 #endif 00142 00148 U_INTERNAL double U_EXPORT2 uprv_maxMantissa(void); 00149 00161 U_INTERNAL int16_t U_EXPORT2 uprv_log10(double d); 00162 00167 U_INTERNAL double U_EXPORT2 uprv_log(double d); 00168 00175 U_INTERNAL double U_EXPORT2 uprv_round(double x); 00176 00177 #if 0 00178 00185 /*U_INTERNAL int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/ 00186 #endif 00187 00220 U_INTERNAL void U_EXPORT2 uprv_tzset(void); 00221 00228 U_STABLE int32_t U_EXPORT2 uprv_timezone(void); 00229 00238 U_INTERNAL char* U_EXPORT2 uprv_tzname(int n); 00239 00245 U_INTERNAL int32_t U_EXPORT2 uprv_getUTCtime(void); 00246 00267 U_STABLE const char* U_EXPORT2 u_getDataDirectory(void); 00268 00288 U_STABLE void U_EXPORT2 u_setDataDirectory(const char *directory); 00289 00298 U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void); 00299 00309 U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void); 00310 00316 #ifdef XP_MAC 00317 # define U_FILE_SEP_CHAR ':' 00318 # define U_FILE_ALT_SEP_CHAR ':' 00319 # define U_PATH_SEP_CHAR ';' 00320 # define U_FILE_SEP_STRING ":" 00321 # define U_FILE_ALT_SEP_STRING ":" 00322 # define U_PATH_SEP_STRING ";" 00323 #elif defined(WIN32) || defined(OS2) 00324 # define U_FILE_SEP_CHAR '\\' 00325 # define U_FILE_ALT_SEP_CHAR '/' 00326 # define U_PATH_SEP_CHAR ';' 00327 # define U_FILE_SEP_STRING "\\" 00328 # define U_FILE_ALT_SEP_STRING "/" 00329 # define U_PATH_SEP_STRING ";" 00330 #else 00331 # define U_FILE_SEP_CHAR '/' 00332 # define U_FILE_ALT_SEP_CHAR '/' 00333 # define U_PATH_SEP_CHAR ':' 00334 # define U_FILE_SEP_STRING "/" 00335 # define U_FILE_ALT_SEP_STRING "/" 00336 # define U_PATH_SEP_STRING ":" 00337 #endif 00338 00345 U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path); 00346 00363 U_STABLE void U_EXPORT2 00364 u_charsToUChars(const char *cs, UChar *us, int32_t length); 00365 00383 U_STABLE void U_EXPORT2 00384 u_UCharsToChars(const UChar *us, char *cs, int32_t length); 00385 00396 U_INTERNAL UBool U_EXPORT2 00397 uprv_isInvariantString(const char *s, int32_t length); 00398 00409 U_INTERNAL UBool U_EXPORT2 00410 uprv_isInvariantUString(const UChar *s, int32_t length); 00411 00417 #if U_CHARSET_FAMILY==U_ASCII_FAMILY 00418 # define U_UPPER_ORDINAL(x) ((x)-'A') 00419 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 00420 # define U_UPPER_ORDINAL(x) (((x) < 'J') ? ((x)-'A') : \ 00421 (((x) < 'S') ? ((x)-'J'+9) : \ 00422 ((x)-'S'+18))) 00423 #else 00424 # error Unknown charset family! 00425 #endif 00426 00441 #ifndef U_MAX_PTR 00442 # ifdef OS390 00443 # define U_MAX_PTR(base) ((void *)0x7fffffff) 00444 # elif defined(OS400) 00445 /* 00446 * With the provided macro we should never be out of range of a given segment 00447 * (a traditional/typical segment that is). Our segments have 5 bytes for the id 00448 * and 3 bytes for the offset. The key is that the casting takes care of only 00449 * retrieving the offset portion minus x1000. Hence, the smallest offset seen in 00450 * a program is x001000 and when casted to an int would be 0. That's why we can 00451 * only add 0xffefff. Otherwise, we would exceed the segment. 00452 * 00453 * Currently, 16MB is the current addressing limitation on as/400. This macro 00454 * may eventually be changed to use 2GB addressability for the newer version of 00455 * as/400 machines. 00456 */ 00457 # define U_MAX_PTR(base) ((void *)(((char *)base)-((int32_t)(base))+((int32_t)0xffefff))) 00458 # else 00459 # define U_MAX_PTR(base) ((void *)(((char *)(base)+0x7fffffffu) > (char *)(base) ? ((char *)(base)+0x7fffffffu) : (char *)-1)) 00460 # endif 00461 #endif 00462 00463 #endif

Generated on Fri Jun 18 12:35:58 2004 for ICU by doxygen 1.3.7