sl@0
|
1 |
/*
|
sl@0
|
2 |
******************************************************************************
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* Copyright (C) 1997-2005, International Business Machines
|
sl@0
|
5 |
* Corporation and others. All Rights Reserved.
|
sl@0
|
6 |
*
|
sl@0
|
7 |
******************************************************************************
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* FILE NAME : putilimp.h
|
sl@0
|
10 |
*
|
sl@0
|
11 |
* Date Name Description
|
sl@0
|
12 |
* 10/17/04 grhoten Move internal functions from putil.h to this file.
|
sl@0
|
13 |
******************************************************************************
|
sl@0
|
14 |
*/
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef PUTILIMP_H
|
sl@0
|
17 |
#define PUTILIMP_H
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "unicode/utypes.h"
|
sl@0
|
20 |
#include "unicode/putil.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
/*==========================================================================*/
|
sl@0
|
23 |
/* Platform utilities */
|
sl@0
|
24 |
/*==========================================================================*/
|
sl@0
|
25 |
|
sl@0
|
26 |
/**
|
sl@0
|
27 |
* Platform utilities isolates the platform dependencies of the
|
sl@0
|
28 |
* libarary. For each platform which this code is ported to, these
|
sl@0
|
29 |
* functions may have to be re-implemented.
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
|
sl@0
|
32 |
/**
|
sl@0
|
33 |
* Floating point utility to determine if a double is Not a Number (NaN).
|
sl@0
|
34 |
* @internal
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
U_INTERNAL UBool U_EXPORT2 uprv_isNaN(double d);
|
sl@0
|
37 |
/**
|
sl@0
|
38 |
* Floating point utility to determine if a double has an infinite value.
|
sl@0
|
39 |
* @internal
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
U_INTERNAL UBool U_EXPORT2 uprv_isInfinite(double d);
|
sl@0
|
42 |
/**
|
sl@0
|
43 |
* Floating point utility to determine if a double has a positive infinite value.
|
sl@0
|
44 |
* @internal
|
sl@0
|
45 |
*/
|
sl@0
|
46 |
U_INTERNAL UBool U_EXPORT2 uprv_isPositiveInfinity(double d);
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
* Floating point utility to determine if a double has a negative infinite value.
|
sl@0
|
49 |
* @internal
|
sl@0
|
50 |
*/
|
sl@0
|
51 |
U_INTERNAL UBool U_EXPORT2 uprv_isNegativeInfinity(double d);
|
sl@0
|
52 |
/**
|
sl@0
|
53 |
* Floating point utility that returns a Not a Number (NaN) value.
|
sl@0
|
54 |
* @internal
|
sl@0
|
55 |
*/
|
sl@0
|
56 |
U_INTERNAL double U_EXPORT2 uprv_getNaN(void);
|
sl@0
|
57 |
/**
|
sl@0
|
58 |
* Floating point utility that returns an infinite value.
|
sl@0
|
59 |
* @internal
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
U_INTERNAL double U_EXPORT2 uprv_getInfinity(void);
|
sl@0
|
62 |
|
sl@0
|
63 |
/**
|
sl@0
|
64 |
* Floating point utility to truncate a double.
|
sl@0
|
65 |
* @internal
|
sl@0
|
66 |
*/
|
sl@0
|
67 |
U_INTERNAL double U_EXPORT2 uprv_trunc(double d);
|
sl@0
|
68 |
/**
|
sl@0
|
69 |
* Floating point utility to calculate the floor of a double.
|
sl@0
|
70 |
* @internal
|
sl@0
|
71 |
*/
|
sl@0
|
72 |
U_INTERNAL double U_EXPORT2 uprv_floor(double d);
|
sl@0
|
73 |
/**
|
sl@0
|
74 |
* Floating point utility to calculate the ceiling of a double.
|
sl@0
|
75 |
* @internal
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
U_INTERNAL double U_EXPORT2 uprv_ceil(double d);
|
sl@0
|
78 |
/**
|
sl@0
|
79 |
* Floating point utility to calculate the absolute value of a double.
|
sl@0
|
80 |
* @internal
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
U_INTERNAL double U_EXPORT2 uprv_fabs(double d);
|
sl@0
|
83 |
/**
|
sl@0
|
84 |
* Floating point utility to calculate the fractional and integer parts of a double.
|
sl@0
|
85 |
* @internal
|
sl@0
|
86 |
*/
|
sl@0
|
87 |
U_INTERNAL double U_EXPORT2 uprv_modf(double d, double* pinteger);
|
sl@0
|
88 |
/**
|
sl@0
|
89 |
* Floating point utility to calculate the remainder of a double divided by another double.
|
sl@0
|
90 |
* @internal
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
U_INTERNAL double U_EXPORT2 uprv_fmod(double d, double y);
|
sl@0
|
93 |
/**
|
sl@0
|
94 |
* Floating point utility to calculate d to the power of exponent (d^exponent).
|
sl@0
|
95 |
* @internal
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
U_INTERNAL double U_EXPORT2 uprv_pow(double d, double exponent);
|
sl@0
|
98 |
/**
|
sl@0
|
99 |
* Floating point utility to calculate 10 to the power of exponent (10^exponent).
|
sl@0
|
100 |
* @internal
|
sl@0
|
101 |
*/
|
sl@0
|
102 |
U_INTERNAL double U_EXPORT2 uprv_pow10(int32_t exponent);
|
sl@0
|
103 |
/**
|
sl@0
|
104 |
* Floating point utility to calculate the maximum value of two doubles.
|
sl@0
|
105 |
* @internal
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
U_INTERNAL double U_EXPORT2 uprv_fmax(double d, double y);
|
sl@0
|
108 |
/**
|
sl@0
|
109 |
* Floating point utility to calculate the minimum value of two doubles.
|
sl@0
|
110 |
* @internal
|
sl@0
|
111 |
*/
|
sl@0
|
112 |
U_INTERNAL double U_EXPORT2 uprv_fmin(double d, double y);
|
sl@0
|
113 |
/**
|
sl@0
|
114 |
* Private utility to calculate the maximum value of two integers.
|
sl@0
|
115 |
* @internal
|
sl@0
|
116 |
*/
|
sl@0
|
117 |
U_INTERNAL int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y);
|
sl@0
|
118 |
/**
|
sl@0
|
119 |
* Private utility to calculate the minimum value of two integers.
|
sl@0
|
120 |
* @internal
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y);
|
sl@0
|
123 |
|
sl@0
|
124 |
#if U_IS_BIG_ENDIAN
|
sl@0
|
125 |
# define uprv_isNegative(number) (*((signed char *)&(number))<0)
|
sl@0
|
126 |
#else
|
sl@0
|
127 |
# define uprv_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0)
|
sl@0
|
128 |
#endif
|
sl@0
|
129 |
|
sl@0
|
130 |
/**
|
sl@0
|
131 |
* Return the largest positive number that can be represented by an integer
|
sl@0
|
132 |
* type of arbitrary bit length.
|
sl@0
|
133 |
* @internal
|
sl@0
|
134 |
*/
|
sl@0
|
135 |
U_INTERNAL double U_EXPORT2 uprv_maxMantissa(void);
|
sl@0
|
136 |
|
sl@0
|
137 |
/**
|
sl@0
|
138 |
* Return the floor of the log base 10 of a given double.
|
sl@0
|
139 |
* This method compensates for inaccuracies which arise naturally when
|
sl@0
|
140 |
* computing logs, and always gives the correct value. The parameter
|
sl@0
|
141 |
* must be positive and finite.
|
sl@0
|
142 |
* (Thanks to Alan Liu for supplying this function.)
|
sl@0
|
143 |
*
|
sl@0
|
144 |
* @param d the double value to apply the common log function for.
|
sl@0
|
145 |
* @return the log of value d.
|
sl@0
|
146 |
* @internal
|
sl@0
|
147 |
*/
|
sl@0
|
148 |
U_INTERNAL int16_t U_EXPORT2 uprv_log10(double d);
|
sl@0
|
149 |
|
sl@0
|
150 |
/**
|
sl@0
|
151 |
* Floating point utility to calculate the logarithm of a double.
|
sl@0
|
152 |
* @internal
|
sl@0
|
153 |
*/
|
sl@0
|
154 |
U_INTERNAL double U_EXPORT2 uprv_log(double d);
|
sl@0
|
155 |
|
sl@0
|
156 |
/**
|
sl@0
|
157 |
* Does common notion of rounding e.g. uprv_floor(x + 0.5);
|
sl@0
|
158 |
* @param x the double number
|
sl@0
|
159 |
* @return the rounded double
|
sl@0
|
160 |
* @internal
|
sl@0
|
161 |
*/
|
sl@0
|
162 |
U_INTERNAL double U_EXPORT2 uprv_round(double x);
|
sl@0
|
163 |
|
sl@0
|
164 |
#if 0
|
sl@0
|
165 |
/**
|
sl@0
|
166 |
* Returns the number of digits after the decimal point in a double number x.
|
sl@0
|
167 |
*
|
sl@0
|
168 |
* @param x the double number
|
sl@0
|
169 |
* @return the number of digits after the decimal point in a double number x.
|
sl@0
|
170 |
* @internal
|
sl@0
|
171 |
*/
|
sl@0
|
172 |
/*U_INTERNAL int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/
|
sl@0
|
173 |
#endif
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
* Time zone utilities
|
sl@0
|
177 |
*
|
sl@0
|
178 |
* Wrappers for C runtime library functions relating to timezones.
|
sl@0
|
179 |
* The t_tzset() function (similar to tzset) uses the current setting
|
sl@0
|
180 |
* of the environment variable TZ to assign values to three global
|
sl@0
|
181 |
* variables: daylight, timezone, and tzname. These variables have the
|
sl@0
|
182 |
* following meanings, and are declared in <time.h>.
|
sl@0
|
183 |
*
|
sl@0
|
184 |
* daylight Nonzero if daylight-saving-time zone (DST) is specified
|
sl@0
|
185 |
* in TZ; otherwise, 0. Default value is 1.
|
sl@0
|
186 |
* timezone Difference in seconds between coordinated universal
|
sl@0
|
187 |
* time and local time. E.g., -28,800 for PST (GMT-8hrs)
|
sl@0
|
188 |
* tzname(0) Three-letter time-zone name derived from TZ environment
|
sl@0
|
189 |
* variable. E.g., "PST".
|
sl@0
|
190 |
* tzname(1) Three-letter DST zone name derived from TZ environment
|
sl@0
|
191 |
* variable. E.g., "PDT". If DST zone is omitted from TZ,
|
sl@0
|
192 |
* tzname(1) is an empty string.
|
sl@0
|
193 |
*
|
sl@0
|
194 |
* Notes: For example, to set the TZ environment variable to correspond
|
sl@0
|
195 |
* to the current time zone in Germany, you can use one of the
|
sl@0
|
196 |
* following statements:
|
sl@0
|
197 |
*
|
sl@0
|
198 |
* set TZ=GST1GDT
|
sl@0
|
199 |
* set TZ=GST+1GDT
|
sl@0
|
200 |
*
|
sl@0
|
201 |
* If the TZ value is not set, t_tzset() attempts to use the time zone
|
sl@0
|
202 |
* information specified by the operating system. Under Windows NT
|
sl@0
|
203 |
* and Windows 95, this information is specified in the Control Panel's
|
sl@0
|
204 |
* Date/Time application.
|
sl@0
|
205 |
* @internal
|
sl@0
|
206 |
*/
|
sl@0
|
207 |
U_INTERNAL void U_EXPORT2 uprv_tzset(void);
|
sl@0
|
208 |
|
sl@0
|
209 |
/**
|
sl@0
|
210 |
* Difference in seconds between coordinated universal
|
sl@0
|
211 |
* time and local time. E.g., -28,800 for PST (GMT-8hrs)
|
sl@0
|
212 |
* @return the difference in seconds between coordinated universal time and local time.
|
sl@0
|
213 |
* @internal
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void);
|
sl@0
|
216 |
|
sl@0
|
217 |
/**
|
sl@0
|
218 |
* tzname(0) Three-letter time-zone name derived from TZ environment
|
sl@0
|
219 |
* variable. E.g., "PST".
|
sl@0
|
220 |
* tzname(1) Three-letter DST zone name derived from TZ environment
|
sl@0
|
221 |
* variable. E.g., "PDT". If DST zone is omitted from TZ,
|
sl@0
|
222 |
* tzname(1) is an empty string.
|
sl@0
|
223 |
* @internal
|
sl@0
|
224 |
*/
|
sl@0
|
225 |
U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n);
|
sl@0
|
226 |
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
* Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970.
|
sl@0
|
229 |
* @return the UTC time measured in milliseconds
|
sl@0
|
230 |
* @internal
|
sl@0
|
231 |
*/
|
sl@0
|
232 |
U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void);
|
sl@0
|
233 |
|
sl@0
|
234 |
/**
|
sl@0
|
235 |
* Determine whether a pathname is absolute or not, as defined by the platform.
|
sl@0
|
236 |
* @param path Pathname to test
|
sl@0
|
237 |
* @return TRUE if the path is absolute
|
sl@0
|
238 |
* @internal (ICU 3.0)
|
sl@0
|
239 |
*/
|
sl@0
|
240 |
U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path);
|
sl@0
|
241 |
|
sl@0
|
242 |
/**
|
sl@0
|
243 |
* Maximum value of a (void*) - use to indicate the limit of an 'infinite' buffer.
|
sl@0
|
244 |
* In fact, buffer sizes must not exceed 2GB so that the difference between
|
sl@0
|
245 |
* the buffer limit and the buffer start can be expressed in an int32_t.
|
sl@0
|
246 |
*
|
sl@0
|
247 |
* The definition of U_MAX_PTR must fulfill the following conditions:
|
sl@0
|
248 |
* - return the largest possible pointer greater than base
|
sl@0
|
249 |
* - return a valid pointer according to the machine architecture (AS/400, 64-bit, etc.)
|
sl@0
|
250 |
* - avoid wrapping around at high addresses
|
sl@0
|
251 |
* - make sure that the returned pointer is not farther from base than 0x7fffffff
|
sl@0
|
252 |
*
|
sl@0
|
253 |
* @param base The beginning of a buffer to find the maximum offset from
|
sl@0
|
254 |
* @internal
|
sl@0
|
255 |
*/
|
sl@0
|
256 |
#ifndef U_MAX_PTR
|
sl@0
|
257 |
# if defined(OS390) && !defined(_LP64)
|
sl@0
|
258 |
/* We have 31-bit pointers. */
|
sl@0
|
259 |
# define U_MAX_PTR(base) ((void *)0x7fffffff)
|
sl@0
|
260 |
# elif defined(OS400)
|
sl@0
|
261 |
/*
|
sl@0
|
262 |
* With the provided macro we should never be out of range of a given segment
|
sl@0
|
263 |
* (a traditional/typical segment that is). Our segments have 5 bytes for the id
|
sl@0
|
264 |
* and 3 bytes for the offset. The key is that the casting takes care of only
|
sl@0
|
265 |
* retrieving the offset portion minus x1000. Hence, the smallest offset seen in
|
sl@0
|
266 |
* a program is x001000 and when casted to an int would be 0. That's why we can
|
sl@0
|
267 |
* only add 0xffefff. Otherwise, we would exceed the segment.
|
sl@0
|
268 |
*
|
sl@0
|
269 |
* Currently, 16MB is the current addressing limitation on as/400. This macro
|
sl@0
|
270 |
* may eventually be changed to use 2GB addressability for the newer version of
|
sl@0
|
271 |
* as/400 machines.
|
sl@0
|
272 |
*/
|
sl@0
|
273 |
# define U_MAX_PTR(base) ((void *)(((char *)base)-((int32_t)(base))+((int32_t)0xffefff)))
|
sl@0
|
274 |
# else
|
sl@0
|
275 |
# define U_MAX_PTR(base) ((void *)(((char *)(base)+0x7fffffffu) > (char *)(base) ? ((char *)(base)+0x7fffffffu) : (char *)-1))
|
sl@0
|
276 |
# endif
|
sl@0
|
277 |
#endif
|
sl@0
|
278 |
|
sl@0
|
279 |
#endif
|