Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

putil.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *
00004 *   Copyright (C) 1997-2001, 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 
00044 /* Floating point utilities 
00045  * @draft
00046  */
00047 U_CAPI UBool  U_EXPORT2  uprv_isNaN(double);
00048 U_CAPI UBool  U_EXPORT2 uprv_isInfinite(double);
00049 U_CAPI UBool   U_EXPORT2 uprv_isPositiveInfinity(double);
00050 U_CAPI UBool   U_EXPORT2 uprv_isNegativeInfinity(double);
00051 U_CAPI double   U_EXPORT2 uprv_getNaN(void);
00052 U_CAPI double   U_EXPORT2 uprv_getInfinity(void);
00053 
00054 U_CAPI double   U_EXPORT2 uprv_floor(double x);
00055 U_CAPI double   U_EXPORT2 uprv_ceil(double x);
00056 U_CAPI double   U_EXPORT2 uprv_fabs(double x);
00057 U_CAPI double   U_EXPORT2 uprv_modf(double x, double* y);
00058 U_CAPI double   U_EXPORT2 uprv_fmod(double x, double y);
00059 U_CAPI double   U_EXPORT2 uprv_pow10(int32_t x);
00060 U_CAPI double   U_EXPORT2 uprv_IEEEremainder(double x, double y);
00061 U_CAPI double   U_EXPORT2 uprv_fmax(double x, double y);
00062 U_CAPI double   U_EXPORT2 uprv_fmin(double x, double y);
00063 U_CAPI int32_t  U_EXPORT2 uprv_max(int32_t x, int32_t y);
00064 U_CAPI int32_t  U_EXPORT2 uprv_min(int32_t x, int32_t y);
00065 U_CAPI double   U_EXPORT2 uprv_trunc(double d);
00066 U_CAPI void     U_EXPORT2 uprv_longBitsFromDouble(double d, int32_t *hi, uint32_t *lo);
00067 #if U_IS_BIG_ENDIAN
00068 #   define uprv_isNegative(number) (*((signed char *)&(number))<0)
00069 #else
00070 #   define uprv_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0)
00071 #endif
00072 
00073 /* Conversion from a digit to the character with radix base from 2-19 */
00074 #define T_CString_itosOffset(a) ((a)<=9?('0'+(a)):('A'+(a)-10))
00075 
00076 /*
00077  * Return the floor of the log base 10 of a given double.
00078  * This method compensates for inaccuracies which arise naturally when
00079  * computing logs, and always gives the correct value.  The parameter
00080  * must be positive and finite.
00081  * (Thanks to Alan Liu for supplying this function.)
00082  */
00090 U_CAPI int16_t  U_EXPORT2 uprv_log10(double d);
00091 
00098 U_CAPI int32_t  U_EXPORT2 uprv_digitsAfterDecimal(double x);
00099 
00132 U_CAPI void     U_EXPORT2 uprv_tzset(void);
00133 U_CAPI int32_t  U_EXPORT2 uprv_timezone(void);
00134 U_CAPI char*    U_EXPORT2 uprv_tzname(int n);
00135 
00140 U_CAPI int32_t  U_EXPORT2 uprv_getUTCtime(void);
00141 
00146 U_CAPI const char* U_EXPORT2 u_getDataDirectory(void);
00147 
00152 U_CAPI void U_EXPORT2 u_setDataDirectory(const char *directory);
00153 
00154 
00155 #ifdef OS390
00156 
00160 U_CAPI UBool uprv_isOS390BatchMode(void);
00161 #endif
00162 
00167 U_CAPI const char*  U_EXPORT2 uprv_getDefaultCodepage(void);
00168 
00174 U_CAPI const char*  U_EXPORT2 uprv_getDefaultLocaleID(void);
00175 
00176 /*
00177  * Finds the least double greater than d (if positive == true),
00178  * or the greatest double less than d (if positive == false).
00179  *
00180  * This is a special purpose function defined by the ChoiceFormat API
00181  * documentation.
00182  * It is not a general purpose function and not defined for NaN or Infinity
00183  * @draft
00184  */
00185 U_CAPI double       U_EXPORT2 uprv_nextDouble(double d, UBool positive);
00186 
00192 #ifdef XP_MAC
00193 #   define U_FILE_SEP_CHAR ':'
00194 #   define U_PATH_SEP_CHAR ';'
00195 #   define U_FILE_SEP_STRING ":"
00196 #   define U_PATH_SEP_STRING ";"
00197 #elif defined(WIN32) || defined(OS2)
00198 #   define U_FILE_SEP_CHAR '\\'
00199 #   define U_PATH_SEP_CHAR ';'
00200 #   define U_FILE_SEP_STRING "\\"
00201 #   define U_PATH_SEP_STRING ";"
00202 #else
00203 #   define U_FILE_SEP_CHAR '/'
00204 #   define U_PATH_SEP_CHAR ':'
00205 #   define U_FILE_SEP_STRING "/"
00206 #   define U_PATH_SEP_STRING ":"
00207 #endif
00208 
00225 U_CAPI void U_EXPORT2
00226 u_charsToUChars(const char *cs, UChar *us, UTextOffset length);
00227 
00245 U_CAPI void U_EXPORT2
00246 u_UCharsToChars(const UChar *us, char *cs, UTextOffset length);
00247 
00257 U_CAPI void U_EXPORT2
00258 u_versionFromString(UVersionInfo versionArray, const char *versionString);
00259 
00270 U_CAPI void U_EXPORT2
00271 u_versionToString(UVersionInfo versionArray, char *versionString);
00272 
00280 U_CAPI void U_EXPORT2
00281 u_getVersion(UVersionInfo versionArray);
00282 
00283 /* Define U_UPPER_ORDINAL */
00284 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
00285 #   define U_UPPER_ORDINAL(x) ((x)-'A')
00286 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
00287 #   define U_UPPER_ORDINAL(x) (((x) < 'J') ? ((x)-'A') : \
00288                               (((x) < 'S') ? ((x)-'J'+9) : \
00289                                ((x)-'S'+18)))
00290 #else
00291 #   error Unknown charset family!
00292 #endif
00293 
00308 #ifndef U_MAX_PTR
00309 #  ifdef OS390
00310 #    define U_MAX_PTR(base) ((void *)0x7fffffff)
00311 #  elif defined(OS400)
00312 /*
00313  * With the provided macro we should never be out of range of a given segment
00314  * (a traditional/typical segment that is).  Our segments have 5 bytes for the id
00315  * and 3 bytes for the offset.  The key is that the casting takes care of only
00316  * retrieving the offset portion minus x1000.  Hence, the smallest offset seen in
00317  * a program is x001000 and when casted to an int would be 0.  That's why we can
00318  * only add 0xffefff.  Otherwise, we would exceed the segment.
00319  *
00320  * Currently, 16MB is the current addressing limitation on as/400.  This macro
00321  * may eventually be changed to use 2GB addressability for the newer version of
00322  * as/400 machines.
00323  */
00324 #    define U_MAX_PTR(base) ((void *)(((char *)base)-((int32_t)(base))+((int32_t)0xffefff)))
00325 #  else
00326 #    define U_MAX_PTR(base) ((void *)(((char *)(base)+0x7fffffff) > (char *)(base) ? ((char *)(base)+0x7fffffff) : (char *)-1))
00327 #  endif
00328 #endif
00329 
00330 #endif

Generated at Tue Jun 12 14:03:58 2001 for ICU 1.8.1 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000