1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/common/putilimp.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,279 @@
1.4 +/*
1.5 +******************************************************************************
1.6 +*
1.7 +* Copyright (C) 1997-2005, International Business Machines
1.8 +* Corporation and others. All Rights Reserved.
1.9 +*
1.10 +******************************************************************************
1.11 +*
1.12 +* FILE NAME : putilimp.h
1.13 +*
1.14 +* Date Name Description
1.15 +* 10/17/04 grhoten Move internal functions from putil.h to this file.
1.16 +******************************************************************************
1.17 +*/
1.18 +
1.19 +#ifndef PUTILIMP_H
1.20 +#define PUTILIMP_H
1.21 +
1.22 +#include "unicode/utypes.h"
1.23 +#include "unicode/putil.h"
1.24 +
1.25 +/*==========================================================================*/
1.26 +/* Platform utilities */
1.27 +/*==========================================================================*/
1.28 +
1.29 +/**
1.30 + * Platform utilities isolates the platform dependencies of the
1.31 + * libarary. For each platform which this code is ported to, these
1.32 + * functions may have to be re-implemented.
1.33 + */
1.34 +
1.35 +/**
1.36 + * Floating point utility to determine if a double is Not a Number (NaN).
1.37 + * @internal
1.38 + */
1.39 +U_INTERNAL UBool U_EXPORT2 uprv_isNaN(double d);
1.40 +/**
1.41 + * Floating point utility to determine if a double has an infinite value.
1.42 + * @internal
1.43 + */
1.44 +U_INTERNAL UBool U_EXPORT2 uprv_isInfinite(double d);
1.45 +/**
1.46 + * Floating point utility to determine if a double has a positive infinite value.
1.47 + * @internal
1.48 + */
1.49 +U_INTERNAL UBool U_EXPORT2 uprv_isPositiveInfinity(double d);
1.50 +/**
1.51 + * Floating point utility to determine if a double has a negative infinite value.
1.52 + * @internal
1.53 + */
1.54 +U_INTERNAL UBool U_EXPORT2 uprv_isNegativeInfinity(double d);
1.55 +/**
1.56 + * Floating point utility that returns a Not a Number (NaN) value.
1.57 + * @internal
1.58 + */
1.59 +U_INTERNAL double U_EXPORT2 uprv_getNaN(void);
1.60 +/**
1.61 + * Floating point utility that returns an infinite value.
1.62 + * @internal
1.63 + */
1.64 +U_INTERNAL double U_EXPORT2 uprv_getInfinity(void);
1.65 +
1.66 +/**
1.67 + * Floating point utility to truncate a double.
1.68 + * @internal
1.69 + */
1.70 +U_INTERNAL double U_EXPORT2 uprv_trunc(double d);
1.71 +/**
1.72 + * Floating point utility to calculate the floor of a double.
1.73 + * @internal
1.74 + */
1.75 +U_INTERNAL double U_EXPORT2 uprv_floor(double d);
1.76 +/**
1.77 + * Floating point utility to calculate the ceiling of a double.
1.78 + * @internal
1.79 + */
1.80 +U_INTERNAL double U_EXPORT2 uprv_ceil(double d);
1.81 +/**
1.82 + * Floating point utility to calculate the absolute value of a double.
1.83 + * @internal
1.84 + */
1.85 +U_INTERNAL double U_EXPORT2 uprv_fabs(double d);
1.86 +/**
1.87 + * Floating point utility to calculate the fractional and integer parts of a double.
1.88 + * @internal
1.89 + */
1.90 +U_INTERNAL double U_EXPORT2 uprv_modf(double d, double* pinteger);
1.91 +/**
1.92 + * Floating point utility to calculate the remainder of a double divided by another double.
1.93 + * @internal
1.94 + */
1.95 +U_INTERNAL double U_EXPORT2 uprv_fmod(double d, double y);
1.96 +/**
1.97 + * Floating point utility to calculate d to the power of exponent (d^exponent).
1.98 + * @internal
1.99 + */
1.100 +U_INTERNAL double U_EXPORT2 uprv_pow(double d, double exponent);
1.101 +/**
1.102 + * Floating point utility to calculate 10 to the power of exponent (10^exponent).
1.103 + * @internal
1.104 + */
1.105 +U_INTERNAL double U_EXPORT2 uprv_pow10(int32_t exponent);
1.106 +/**
1.107 + * Floating point utility to calculate the maximum value of two doubles.
1.108 + * @internal
1.109 + */
1.110 +U_INTERNAL double U_EXPORT2 uprv_fmax(double d, double y);
1.111 +/**
1.112 + * Floating point utility to calculate the minimum value of two doubles.
1.113 + * @internal
1.114 + */
1.115 +U_INTERNAL double U_EXPORT2 uprv_fmin(double d, double y);
1.116 +/**
1.117 + * Private utility to calculate the maximum value of two integers.
1.118 + * @internal
1.119 + */
1.120 +U_INTERNAL int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y);
1.121 +/**
1.122 + * Private utility to calculate the minimum value of two integers.
1.123 + * @internal
1.124 + */
1.125 +U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y);
1.126 +
1.127 +#if U_IS_BIG_ENDIAN
1.128 +# define uprv_isNegative(number) (*((signed char *)&(number))<0)
1.129 +#else
1.130 +# define uprv_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0)
1.131 +#endif
1.132 +
1.133 +/**
1.134 + * Return the largest positive number that can be represented by an integer
1.135 + * type of arbitrary bit length.
1.136 + * @internal
1.137 + */
1.138 +U_INTERNAL double U_EXPORT2 uprv_maxMantissa(void);
1.139 +
1.140 +/**
1.141 + * Return the floor of the log base 10 of a given double.
1.142 + * This method compensates for inaccuracies which arise naturally when
1.143 + * computing logs, and always gives the correct value. The parameter
1.144 + * must be positive and finite.
1.145 + * (Thanks to Alan Liu for supplying this function.)
1.146 + *
1.147 + * @param d the double value to apply the common log function for.
1.148 + * @return the log of value d.
1.149 + * @internal
1.150 + */
1.151 +U_INTERNAL int16_t U_EXPORT2 uprv_log10(double d);
1.152 +
1.153 +/**
1.154 + * Floating point utility to calculate the logarithm of a double.
1.155 + * @internal
1.156 + */
1.157 +U_INTERNAL double U_EXPORT2 uprv_log(double d);
1.158 +
1.159 +/**
1.160 + * Does common notion of rounding e.g. uprv_floor(x + 0.5);
1.161 + * @param x the double number
1.162 + * @return the rounded double
1.163 + * @internal
1.164 + */
1.165 +U_INTERNAL double U_EXPORT2 uprv_round(double x);
1.166 +
1.167 +#if 0
1.168 +/**
1.169 + * Returns the number of digits after the decimal point in a double number x.
1.170 + *
1.171 + * @param x the double number
1.172 + * @return the number of digits after the decimal point in a double number x.
1.173 + * @internal
1.174 + */
1.175 +/*U_INTERNAL int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/
1.176 +#endif
1.177 +
1.178 +/**
1.179 + * Time zone utilities
1.180 + *
1.181 + * Wrappers for C runtime library functions relating to timezones.
1.182 + * The t_tzset() function (similar to tzset) uses the current setting
1.183 + * of the environment variable TZ to assign values to three global
1.184 + * variables: daylight, timezone, and tzname. These variables have the
1.185 + * following meanings, and are declared in <time.h>.
1.186 + *
1.187 + * daylight Nonzero if daylight-saving-time zone (DST) is specified
1.188 + * in TZ; otherwise, 0. Default value is 1.
1.189 + * timezone Difference in seconds between coordinated universal
1.190 + * time and local time. E.g., -28,800 for PST (GMT-8hrs)
1.191 + * tzname(0) Three-letter time-zone name derived from TZ environment
1.192 + * variable. E.g., "PST".
1.193 + * tzname(1) Three-letter DST zone name derived from TZ environment
1.194 + * variable. E.g., "PDT". If DST zone is omitted from TZ,
1.195 + * tzname(1) is an empty string.
1.196 + *
1.197 + * Notes: For example, to set the TZ environment variable to correspond
1.198 + * to the current time zone in Germany, you can use one of the
1.199 + * following statements:
1.200 + *
1.201 + * set TZ=GST1GDT
1.202 + * set TZ=GST+1GDT
1.203 + *
1.204 + * If the TZ value is not set, t_tzset() attempts to use the time zone
1.205 + * information specified by the operating system. Under Windows NT
1.206 + * and Windows 95, this information is specified in the Control Panel's
1.207 + * Date/Time application.
1.208 + * @internal
1.209 + */
1.210 +U_INTERNAL void U_EXPORT2 uprv_tzset(void);
1.211 +
1.212 +/**
1.213 + * Difference in seconds between coordinated universal
1.214 + * time and local time. E.g., -28,800 for PST (GMT-8hrs)
1.215 + * @return the difference in seconds between coordinated universal time and local time.
1.216 + * @internal
1.217 + */
1.218 +U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void);
1.219 +
1.220 +/**
1.221 + * tzname(0) Three-letter time-zone name derived from TZ environment
1.222 + * variable. E.g., "PST".
1.223 + * tzname(1) Three-letter DST zone name derived from TZ environment
1.224 + * variable. E.g., "PDT". If DST zone is omitted from TZ,
1.225 + * tzname(1) is an empty string.
1.226 + * @internal
1.227 + */
1.228 +U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
1.229 +
1.230 +/**
1.231 + * Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
1.232 + * @return the UTC time measured in milliseconds
1.233 + * @internal
1.234 + */
1.235 +U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
1.236 +
1.237 +/**
1.238 + * Determine whether a pathname is absolute or not, as defined by the platform.
1.239 + * @param path Pathname to test
1.240 + * @return TRUE if the path is absolute
1.241 + * @internal (ICU 3.0)
1.242 + */
1.243 +U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path);
1.244 +
1.245 +/**
1.246 + * Maximum value of a (void*) - use to indicate the limit of an 'infinite' buffer.
1.247 + * In fact, buffer sizes must not exceed 2GB so that the difference between
1.248 + * the buffer limit and the buffer start can be expressed in an int32_t.
1.249 + *
1.250 + * The definition of U_MAX_PTR must fulfill the following conditions:
1.251 + * - return the largest possible pointer greater than base
1.252 + * - return a valid pointer according to the machine architecture (AS/400, 64-bit, etc.)
1.253 + * - avoid wrapping around at high addresses
1.254 + * - make sure that the returned pointer is not farther from base than 0x7fffffff
1.255 + *
1.256 + * @param base The beginning of a buffer to find the maximum offset from
1.257 + * @internal
1.258 + */
1.259 +#ifndef U_MAX_PTR
1.260 +# if defined(OS390) && !defined(_LP64)
1.261 + /* We have 31-bit pointers. */
1.262 +# define U_MAX_PTR(base) ((void *)0x7fffffff)
1.263 +# elif defined(OS400)
1.264 +/*
1.265 + * With the provided macro we should never be out of range of a given segment
1.266 + * (a traditional/typical segment that is). Our segments have 5 bytes for the id
1.267 + * and 3 bytes for the offset. The key is that the casting takes care of only
1.268 + * retrieving the offset portion minus x1000. Hence, the smallest offset seen in
1.269 + * a program is x001000 and when casted to an int would be 0. That's why we can
1.270 + * only add 0xffefff. Otherwise, we would exceed the segment.
1.271 + *
1.272 + * Currently, 16MB is the current addressing limitation on as/400. This macro
1.273 + * may eventually be changed to use 2GB addressability for the newer version of
1.274 + * as/400 machines.
1.275 + */
1.276 +# define U_MAX_PTR(base) ((void *)(((char *)base)-((int32_t)(base))+((int32_t)0xffefff)))
1.277 +# else
1.278 +# define U_MAX_PTR(base) ((void *)(((char *)(base)+0x7fffffffu) > (char *)(base) ? ((char *)(base)+0x7fffffffu) : (char *)-1))
1.279 +# endif
1.280 +#endif
1.281 +
1.282 +#endif