Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1997-2013, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ****************************************************************************** |
michael@0 | 8 | * |
michael@0 | 9 | * FILE NAME : putilimp.h |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 10/17/04 grhoten Move internal functions from putil.h to this file. |
michael@0 | 13 | ****************************************************************************** |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | #ifndef PUTILIMP_H |
michael@0 | 17 | #define PUTILIMP_H |
michael@0 | 18 | |
michael@0 | 19 | #include "unicode/utypes.h" |
michael@0 | 20 | #include "unicode/putil.h" |
michael@0 | 21 | |
michael@0 | 22 | /** |
michael@0 | 23 | * \def U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC |
michael@0 | 24 | * Nearly all CPUs and compilers implement a right-shift of a signed integer |
michael@0 | 25 | * as an Arithmetic Shift Right which copies the sign bit (the Most Significant Bit (MSB)) |
michael@0 | 26 | * into the vacated bits (sign extension). |
michael@0 | 27 | * For example, (int32_t)0xfff5fff3>>4 becomes 0xffff5fff and -1>>1=-1. |
michael@0 | 28 | * |
michael@0 | 29 | * This can be useful for storing a signed value in the upper bits |
michael@0 | 30 | * and another bit field in the lower bits. |
michael@0 | 31 | * The signed value can be retrieved by simple right-shifting. |
michael@0 | 32 | * |
michael@0 | 33 | * This is consistent with the Java language. |
michael@0 | 34 | * |
michael@0 | 35 | * However, the C standard allows compilers to implement a right-shift of a signed integer |
michael@0 | 36 | * as a Logical Shift Right which copies a 0 into the vacated bits. |
michael@0 | 37 | * For example, (int32_t)0xfff5fff3>>4 becomes 0x0fff5fff and -1>>1=0x7fffffff. |
michael@0 | 38 | * |
michael@0 | 39 | * Code that depends on the natural behavior should be guarded with this macro, |
michael@0 | 40 | * with an alternate path for unusual platforms. |
michael@0 | 41 | * @internal |
michael@0 | 42 | */ |
michael@0 | 43 | #ifdef U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC |
michael@0 | 44 | /* Use the predefined value. */ |
michael@0 | 45 | #else |
michael@0 | 46 | /* |
michael@0 | 47 | * Nearly all CPUs & compilers implement a right-shift of a signed integer |
michael@0 | 48 | * as an Arithmetic Shift Right (with sign extension). |
michael@0 | 49 | */ |
michael@0 | 50 | # define U_SIGNED_RIGHT_SHIFT_IS_ARITHMETIC 1 |
michael@0 | 51 | #endif |
michael@0 | 52 | |
michael@0 | 53 | /** Define this to 1 if your platform supports IEEE 754 floating point, |
michael@0 | 54 | to 0 if it does not. */ |
michael@0 | 55 | #ifndef IEEE_754 |
michael@0 | 56 | # define IEEE_754 1 |
michael@0 | 57 | #endif |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * uintptr_t is an optional part of the standard definitions in stdint.h. |
michael@0 | 61 | * The opengroup.org documentation for stdint.h says |
michael@0 | 62 | * "On XSI-conformant systems, the intptr_t and uintptr_t types are required; |
michael@0 | 63 | * otherwise, they are optional." |
michael@0 | 64 | * We assume that when uintptr_t is defined, UINTPTR_MAX is defined as well. |
michael@0 | 65 | * |
michael@0 | 66 | * Do not use ptrdiff_t since it is signed. size_t is unsigned. |
michael@0 | 67 | */ |
michael@0 | 68 | /* TODO: This check fails on some z environments. Filed a ticket #9357 for this. */ |
michael@0 | 69 | #if !defined(__intptr_t_defined) && !defined(UINTPTR_MAX) && (U_PLATFORM != U_PF_OS390) |
michael@0 | 70 | typedef size_t uintptr_t; |
michael@0 | 71 | #endif |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * \def U_HAVE_MSVC_2003_OR_EARLIER |
michael@0 | 75 | * Flag for workaround of MSVC 2003 optimization bugs |
michael@0 | 76 | * @internal |
michael@0 | 77 | */ |
michael@0 | 78 | #if !defined(U_HAVE_MSVC_2003_OR_EARLIER) && defined(_MSC_VER) && (_MSC_VER < 1400) |
michael@0 | 79 | #define U_HAVE_MSVC_2003_OR_EARLIER |
michael@0 | 80 | #endif |
michael@0 | 81 | |
michael@0 | 82 | /*===========================================================================*/ |
michael@0 | 83 | /** @{ Information about POSIX support */ |
michael@0 | 84 | /*===========================================================================*/ |
michael@0 | 85 | |
michael@0 | 86 | #ifdef U_HAVE_NL_LANGINFO_CODESET |
michael@0 | 87 | /* Use the predefined value. */ |
michael@0 | 88 | #elif U_PLATFORM_HAS_WIN32_API |
michael@0 | 89 | # define U_HAVE_NL_LANGINFO_CODESET 0 |
michael@0 | 90 | #else |
michael@0 | 91 | # define U_HAVE_NL_LANGINFO_CODESET 1 |
michael@0 | 92 | #endif |
michael@0 | 93 | |
michael@0 | 94 | #ifdef U_NL_LANGINFO_CODESET |
michael@0 | 95 | /* Use the predefined value. */ |
michael@0 | 96 | #elif !U_HAVE_NL_LANGINFO_CODESET |
michael@0 | 97 | # define U_NL_LANGINFO_CODESET -1 |
michael@0 | 98 | #elif U_PLATFORM == U_PF_OS400 |
michael@0 | 99 | /* not defined */ |
michael@0 | 100 | #else |
michael@0 | 101 | # define U_NL_LANGINFO_CODESET CODESET |
michael@0 | 102 | #endif |
michael@0 | 103 | |
michael@0 | 104 | #ifdef U_TZSET |
michael@0 | 105 | /* Use the predefined value. */ |
michael@0 | 106 | #elif U_PLATFORM_USES_ONLY_WIN32_API |
michael@0 | 107 | # define U_TZSET _tzset |
michael@0 | 108 | #elif U_PLATFORM == U_PF_OS400 |
michael@0 | 109 | /* not defined */ |
michael@0 | 110 | #else |
michael@0 | 111 | # define U_TZSET tzset |
michael@0 | 112 | #endif |
michael@0 | 113 | |
michael@0 | 114 | #if defined(U_TIMEZONE) || defined(U_HAVE_TIMEZONE) |
michael@0 | 115 | /* Use the predefined value. */ |
michael@0 | 116 | #elif U_PLATFORM == U_PF_ANDROID |
michael@0 | 117 | # define U_TIMEZONE timezone |
michael@0 | 118 | #elif U_PLATFORM_IS_LINUX_BASED |
michael@0 | 119 | # if !defined(__UCLIBC__) |
michael@0 | 120 | /* __timezone is only available in glibc */ |
michael@0 | 121 | # define U_TIMEZONE __timezone |
michael@0 | 122 | # endif |
michael@0 | 123 | #elif U_PLATFORM_USES_ONLY_WIN32_API |
michael@0 | 124 | # define U_TIMEZONE _timezone |
michael@0 | 125 | #elif U_PLATFORM == U_PF_BSD && !defined(__NetBSD__) |
michael@0 | 126 | /* not defined */ |
michael@0 | 127 | #elif U_PLATFORM == U_PF_OS400 |
michael@0 | 128 | /* not defined */ |
michael@0 | 129 | #elif U_PLATFORM == U_PF_IPHONE |
michael@0 | 130 | /* not defined */ |
michael@0 | 131 | #else |
michael@0 | 132 | # define U_TIMEZONE timezone |
michael@0 | 133 | #endif |
michael@0 | 134 | |
michael@0 | 135 | #ifdef U_TZNAME |
michael@0 | 136 | /* Use the predefined value. */ |
michael@0 | 137 | #elif U_PLATFORM_USES_ONLY_WIN32_API |
michael@0 | 138 | # define U_TZNAME _tzname |
michael@0 | 139 | #elif U_PLATFORM == U_PF_OS400 |
michael@0 | 140 | /* not defined */ |
michael@0 | 141 | #else |
michael@0 | 142 | # define U_TZNAME tzname |
michael@0 | 143 | #endif |
michael@0 | 144 | |
michael@0 | 145 | #ifdef U_HAVE_MMAP |
michael@0 | 146 | /* Use the predefined value. */ |
michael@0 | 147 | #elif U_PLATFORM_HAS_WIN32_API |
michael@0 | 148 | # define U_HAVE_MMAP 0 |
michael@0 | 149 | #else |
michael@0 | 150 | # define U_HAVE_MMAP 1 |
michael@0 | 151 | #endif |
michael@0 | 152 | |
michael@0 | 153 | #ifdef U_HAVE_POPEN |
michael@0 | 154 | /* Use the predefined value. */ |
michael@0 | 155 | #elif U_PLATFORM_USES_ONLY_WIN32_API |
michael@0 | 156 | # define U_HAVE_POPEN 0 |
michael@0 | 157 | #elif U_PLATFORM == U_PF_OS400 |
michael@0 | 158 | # define U_HAVE_POPEN 0 |
michael@0 | 159 | #else |
michael@0 | 160 | # define U_HAVE_POPEN 1 |
michael@0 | 161 | #endif |
michael@0 | 162 | |
michael@0 | 163 | /** |
michael@0 | 164 | * \def U_HAVE_DIRENT_H |
michael@0 | 165 | * Defines whether dirent.h is available. |
michael@0 | 166 | * @internal |
michael@0 | 167 | */ |
michael@0 | 168 | #ifdef U_HAVE_DIRENT_H |
michael@0 | 169 | /* Use the predefined value. */ |
michael@0 | 170 | #elif U_PLATFORM_HAS_WIN32_API |
michael@0 | 171 | # define U_HAVE_DIRENT_H 0 |
michael@0 | 172 | #else |
michael@0 | 173 | # define U_HAVE_DIRENT_H 1 |
michael@0 | 174 | #endif |
michael@0 | 175 | |
michael@0 | 176 | /** @} */ |
michael@0 | 177 | |
michael@0 | 178 | /*===========================================================================*/ |
michael@0 | 179 | /** @{ GCC built in functions for atomic memory operations */ |
michael@0 | 180 | /*===========================================================================*/ |
michael@0 | 181 | |
michael@0 | 182 | /** |
michael@0 | 183 | * \def U_HAVE_GCC_ATOMICS |
michael@0 | 184 | * @internal |
michael@0 | 185 | */ |
michael@0 | 186 | #ifdef U_HAVE_GCC_ATOMICS |
michael@0 | 187 | /* Use the predefined value. */ |
michael@0 | 188 | #elif U_PLATFORM == U_PF_MINGW |
michael@0 | 189 | #define U_HAVE_GCC_ATOMICS 0 |
michael@0 | 190 | #elif U_GCC_MAJOR_MINOR >= 404 || defined(__clang__) |
michael@0 | 191 | /* TODO: Intel icc and IBM xlc on AIX also support gcc atomics. (Intel originated them.) |
michael@0 | 192 | * Add them for these compilers. |
michael@0 | 193 | * Note: Clang sets __GNUC__ defines for version 4.2, so misses the 4.4 test here. |
michael@0 | 194 | */ |
michael@0 | 195 | # define U_HAVE_GCC_ATOMICS 1 |
michael@0 | 196 | #else |
michael@0 | 197 | # define U_HAVE_GCC_ATOMICS 0 |
michael@0 | 198 | #endif |
michael@0 | 199 | |
michael@0 | 200 | /** @} */ |
michael@0 | 201 | |
michael@0 | 202 | /** |
michael@0 | 203 | * \def U_HAVE_STD_ATOMICS |
michael@0 | 204 | * Defines whether the standard C++11 <atomic> is available. |
michael@0 | 205 | * ICU will use this when avialable, |
michael@0 | 206 | * otherwise will fall back to compiler or platform specific alternatives. |
michael@0 | 207 | * @internal |
michael@0 | 208 | */ |
michael@0 | 209 | #ifdef U_HAVE_STD_ATOMICS |
michael@0 | 210 | /* Use the predefined value. */ |
michael@0 | 211 | #elif !defined(__cplusplus) || __cplusplus<201103L |
michael@0 | 212 | /* Not C++11, disable use of atomics */ |
michael@0 | 213 | # define U_HAVE_STD_ATOMICS 0 |
michael@0 | 214 | #elif __clang__ && __clang_major__==3 && __clang_minor__<=1 |
michael@0 | 215 | /* Clang 3.1, has atomic variable initializer bug. */ |
michael@0 | 216 | # define U_HAVE_STD_ATOMICS 0 |
michael@0 | 217 | #else |
michael@0 | 218 | /* U_HAVE_ATOMIC is typically set by an autoconf test of #include <atomic> */ |
michael@0 | 219 | /* Can be set manually, or left undefined, on platforms without autoconf. */ |
michael@0 | 220 | # if defined(U_HAVE_ATOMIC) && U_HAVE_ATOMIC |
michael@0 | 221 | # define U_HAVE_STD_ATOMICS 1 |
michael@0 | 222 | # else |
michael@0 | 223 | # define U_HAVE_STD_ATOMICS 0 |
michael@0 | 224 | # endif |
michael@0 | 225 | #endif |
michael@0 | 226 | |
michael@0 | 227 | |
michael@0 | 228 | /*===========================================================================*/ |
michael@0 | 229 | /** @{ Code alignment */ |
michael@0 | 230 | /*===========================================================================*/ |
michael@0 | 231 | |
michael@0 | 232 | /** |
michael@0 | 233 | * \def U_ALIGN_CODE |
michael@0 | 234 | * This is used to align code fragments to a specific byte boundary. |
michael@0 | 235 | * This is useful for getting consistent performance test results. |
michael@0 | 236 | * @internal |
michael@0 | 237 | */ |
michael@0 | 238 | #ifdef U_ALIGN_CODE |
michael@0 | 239 | /* Use the predefined value. */ |
michael@0 | 240 | #elif defined(_MSC_VER) && defined(_M_IX86) && !defined(_MANAGED) |
michael@0 | 241 | # define U_ALIGN_CODE(boundarySize) __asm align boundarySize |
michael@0 | 242 | #else |
michael@0 | 243 | # define U_ALIGN_CODE(boundarySize) |
michael@0 | 244 | #endif |
michael@0 | 245 | |
michael@0 | 246 | /** @} */ |
michael@0 | 247 | |
michael@0 | 248 | /*===========================================================================*/ |
michael@0 | 249 | /** @{ Programs used by ICU code */ |
michael@0 | 250 | /*===========================================================================*/ |
michael@0 | 251 | |
michael@0 | 252 | /** |
michael@0 | 253 | * \def U_MAKE_IS_NMAKE |
michael@0 | 254 | * Defines whether the "make" program is Windows nmake. |
michael@0 | 255 | */ |
michael@0 | 256 | #ifdef U_MAKE_IS_NMAKE |
michael@0 | 257 | /* Use the predefined value. */ |
michael@0 | 258 | #elif U_PLATFORM == U_PF_WINDOWS |
michael@0 | 259 | # define U_MAKE_IS_NMAKE 1 |
michael@0 | 260 | #else |
michael@0 | 261 | # define U_MAKE_IS_NMAKE 0 |
michael@0 | 262 | #endif |
michael@0 | 263 | |
michael@0 | 264 | /** @} */ |
michael@0 | 265 | |
michael@0 | 266 | /*==========================================================================*/ |
michael@0 | 267 | /* Platform utilities */ |
michael@0 | 268 | /*==========================================================================*/ |
michael@0 | 269 | |
michael@0 | 270 | /** |
michael@0 | 271 | * Platform utilities isolates the platform dependencies of the |
michael@0 | 272 | * libarary. For each platform which this code is ported to, these |
michael@0 | 273 | * functions may have to be re-implemented. |
michael@0 | 274 | */ |
michael@0 | 275 | |
michael@0 | 276 | /** |
michael@0 | 277 | * Floating point utility to determine if a double is Not a Number (NaN). |
michael@0 | 278 | * @internal |
michael@0 | 279 | */ |
michael@0 | 280 | U_INTERNAL UBool U_EXPORT2 uprv_isNaN(double d); |
michael@0 | 281 | /** |
michael@0 | 282 | * Floating point utility to determine if a double has an infinite value. |
michael@0 | 283 | * @internal |
michael@0 | 284 | */ |
michael@0 | 285 | U_INTERNAL UBool U_EXPORT2 uprv_isInfinite(double d); |
michael@0 | 286 | /** |
michael@0 | 287 | * Floating point utility to determine if a double has a positive infinite value. |
michael@0 | 288 | * @internal |
michael@0 | 289 | */ |
michael@0 | 290 | U_INTERNAL UBool U_EXPORT2 uprv_isPositiveInfinity(double d); |
michael@0 | 291 | /** |
michael@0 | 292 | * Floating point utility to determine if a double has a negative infinite value. |
michael@0 | 293 | * @internal |
michael@0 | 294 | */ |
michael@0 | 295 | U_INTERNAL UBool U_EXPORT2 uprv_isNegativeInfinity(double d); |
michael@0 | 296 | /** |
michael@0 | 297 | * Floating point utility that returns a Not a Number (NaN) value. |
michael@0 | 298 | * @internal |
michael@0 | 299 | */ |
michael@0 | 300 | U_INTERNAL double U_EXPORT2 uprv_getNaN(void); |
michael@0 | 301 | /** |
michael@0 | 302 | * Floating point utility that returns an infinite value. |
michael@0 | 303 | * @internal |
michael@0 | 304 | */ |
michael@0 | 305 | U_INTERNAL double U_EXPORT2 uprv_getInfinity(void); |
michael@0 | 306 | |
michael@0 | 307 | /** |
michael@0 | 308 | * Floating point utility to truncate a double. |
michael@0 | 309 | * @internal |
michael@0 | 310 | */ |
michael@0 | 311 | U_INTERNAL double U_EXPORT2 uprv_trunc(double d); |
michael@0 | 312 | /** |
michael@0 | 313 | * Floating point utility to calculate the floor of a double. |
michael@0 | 314 | * @internal |
michael@0 | 315 | */ |
michael@0 | 316 | U_INTERNAL double U_EXPORT2 uprv_floor(double d); |
michael@0 | 317 | /** |
michael@0 | 318 | * Floating point utility to calculate the ceiling of a double. |
michael@0 | 319 | * @internal |
michael@0 | 320 | */ |
michael@0 | 321 | U_INTERNAL double U_EXPORT2 uprv_ceil(double d); |
michael@0 | 322 | /** |
michael@0 | 323 | * Floating point utility to calculate the absolute value of a double. |
michael@0 | 324 | * @internal |
michael@0 | 325 | */ |
michael@0 | 326 | U_INTERNAL double U_EXPORT2 uprv_fabs(double d); |
michael@0 | 327 | /** |
michael@0 | 328 | * Floating point utility to calculate the fractional and integer parts of a double. |
michael@0 | 329 | * @internal |
michael@0 | 330 | */ |
michael@0 | 331 | U_INTERNAL double U_EXPORT2 uprv_modf(double d, double* pinteger); |
michael@0 | 332 | /** |
michael@0 | 333 | * Floating point utility to calculate the remainder of a double divided by another double. |
michael@0 | 334 | * @internal |
michael@0 | 335 | */ |
michael@0 | 336 | U_INTERNAL double U_EXPORT2 uprv_fmod(double d, double y); |
michael@0 | 337 | /** |
michael@0 | 338 | * Floating point utility to calculate d to the power of exponent (d^exponent). |
michael@0 | 339 | * @internal |
michael@0 | 340 | */ |
michael@0 | 341 | U_INTERNAL double U_EXPORT2 uprv_pow(double d, double exponent); |
michael@0 | 342 | /** |
michael@0 | 343 | * Floating point utility to calculate 10 to the power of exponent (10^exponent). |
michael@0 | 344 | * @internal |
michael@0 | 345 | */ |
michael@0 | 346 | U_INTERNAL double U_EXPORT2 uprv_pow10(int32_t exponent); |
michael@0 | 347 | /** |
michael@0 | 348 | * Floating point utility to calculate the maximum value of two doubles. |
michael@0 | 349 | * @internal |
michael@0 | 350 | */ |
michael@0 | 351 | U_INTERNAL double U_EXPORT2 uprv_fmax(double d, double y); |
michael@0 | 352 | /** |
michael@0 | 353 | * Floating point utility to calculate the minimum value of two doubles. |
michael@0 | 354 | * @internal |
michael@0 | 355 | */ |
michael@0 | 356 | U_INTERNAL double U_EXPORT2 uprv_fmin(double d, double y); |
michael@0 | 357 | /** |
michael@0 | 358 | * Private utility to calculate the maximum value of two integers. |
michael@0 | 359 | * @internal |
michael@0 | 360 | */ |
michael@0 | 361 | U_INTERNAL int32_t U_EXPORT2 uprv_max(int32_t d, int32_t y); |
michael@0 | 362 | /** |
michael@0 | 363 | * Private utility to calculate the minimum value of two integers. |
michael@0 | 364 | * @internal |
michael@0 | 365 | */ |
michael@0 | 366 | U_INTERNAL int32_t U_EXPORT2 uprv_min(int32_t d, int32_t y); |
michael@0 | 367 | |
michael@0 | 368 | #if U_IS_BIG_ENDIAN |
michael@0 | 369 | # define uprv_isNegative(number) (*((signed char *)&(number))<0) |
michael@0 | 370 | #else |
michael@0 | 371 | # define uprv_isNegative(number) (*((signed char *)&(number)+sizeof(number)-1)<0) |
michael@0 | 372 | #endif |
michael@0 | 373 | |
michael@0 | 374 | /** |
michael@0 | 375 | * Return the largest positive number that can be represented by an integer |
michael@0 | 376 | * type of arbitrary bit length. |
michael@0 | 377 | * @internal |
michael@0 | 378 | */ |
michael@0 | 379 | U_INTERNAL double U_EXPORT2 uprv_maxMantissa(void); |
michael@0 | 380 | |
michael@0 | 381 | /** |
michael@0 | 382 | * Floating point utility to calculate the logarithm of a double. |
michael@0 | 383 | * @internal |
michael@0 | 384 | */ |
michael@0 | 385 | U_INTERNAL double U_EXPORT2 uprv_log(double d); |
michael@0 | 386 | |
michael@0 | 387 | /** |
michael@0 | 388 | * Does common notion of rounding e.g. uprv_floor(x + 0.5); |
michael@0 | 389 | * @param x the double number |
michael@0 | 390 | * @return the rounded double |
michael@0 | 391 | * @internal |
michael@0 | 392 | */ |
michael@0 | 393 | U_INTERNAL double U_EXPORT2 uprv_round(double x); |
michael@0 | 394 | |
michael@0 | 395 | #if 0 |
michael@0 | 396 | /** |
michael@0 | 397 | * Returns the number of digits after the decimal point in a double number x. |
michael@0 | 398 | * |
michael@0 | 399 | * @param x the double number |
michael@0 | 400 | * @return the number of digits after the decimal point in a double number x. |
michael@0 | 401 | * @internal |
michael@0 | 402 | */ |
michael@0 | 403 | /*U_INTERNAL int32_t U_EXPORT2 uprv_digitsAfterDecimal(double x);*/ |
michael@0 | 404 | #endif |
michael@0 | 405 | |
michael@0 | 406 | #if !U_CHARSET_IS_UTF8 |
michael@0 | 407 | /** |
michael@0 | 408 | * Please use ucnv_getDefaultName() instead. |
michael@0 | 409 | * Return the default codepage for this platform and locale. |
michael@0 | 410 | * This function can call setlocale() on Unix platforms. Please read the |
michael@0 | 411 | * platform documentation on setlocale() before calling this function. |
michael@0 | 412 | * @return the default codepage for this platform |
michael@0 | 413 | * @internal |
michael@0 | 414 | */ |
michael@0 | 415 | U_INTERNAL const char* U_EXPORT2 uprv_getDefaultCodepage(void); |
michael@0 | 416 | #endif |
michael@0 | 417 | |
michael@0 | 418 | /** |
michael@0 | 419 | * Please use uloc_getDefault() instead. |
michael@0 | 420 | * Return the default locale ID string by querying ths system, or |
michael@0 | 421 | * zero if one cannot be found. |
michael@0 | 422 | * This function can call setlocale() on Unix platforms. Please read the |
michael@0 | 423 | * platform documentation on setlocale() before calling this function. |
michael@0 | 424 | * @return the default locale ID string |
michael@0 | 425 | * @internal |
michael@0 | 426 | */ |
michael@0 | 427 | U_INTERNAL const char* U_EXPORT2 uprv_getDefaultLocaleID(void); |
michael@0 | 428 | |
michael@0 | 429 | /** |
michael@0 | 430 | * Time zone utilities |
michael@0 | 431 | * |
michael@0 | 432 | * Wrappers for C runtime library functions relating to timezones. |
michael@0 | 433 | * The t_tzset() function (similar to tzset) uses the current setting |
michael@0 | 434 | * of the environment variable TZ to assign values to three global |
michael@0 | 435 | * variables: daylight, timezone, and tzname. These variables have the |
michael@0 | 436 | * following meanings, and are declared in <time.h>. |
michael@0 | 437 | * |
michael@0 | 438 | * daylight Nonzero if daylight-saving-time zone (DST) is specified |
michael@0 | 439 | * in TZ; otherwise, 0. Default value is 1. |
michael@0 | 440 | * timezone Difference in seconds between coordinated universal |
michael@0 | 441 | * time and local time. E.g., -28,800 for PST (GMT-8hrs) |
michael@0 | 442 | * tzname(0) Three-letter time-zone name derived from TZ environment |
michael@0 | 443 | * variable. E.g., "PST". |
michael@0 | 444 | * tzname(1) Three-letter DST zone name derived from TZ environment |
michael@0 | 445 | * variable. E.g., "PDT". If DST zone is omitted from TZ, |
michael@0 | 446 | * tzname(1) is an empty string. |
michael@0 | 447 | * |
michael@0 | 448 | * Notes: For example, to set the TZ environment variable to correspond |
michael@0 | 449 | * to the current time zone in Germany, you can use one of the |
michael@0 | 450 | * following statements: |
michael@0 | 451 | * |
michael@0 | 452 | * set TZ=GST1GDT |
michael@0 | 453 | * set TZ=GST+1GDT |
michael@0 | 454 | * |
michael@0 | 455 | * If the TZ value is not set, t_tzset() attempts to use the time zone |
michael@0 | 456 | * information specified by the operating system. Under Windows NT |
michael@0 | 457 | * and Windows 95, this information is specified in the Control Panel's |
michael@0 | 458 | * Date/Time application. |
michael@0 | 459 | * @internal |
michael@0 | 460 | */ |
michael@0 | 461 | U_INTERNAL void U_EXPORT2 uprv_tzset(void); |
michael@0 | 462 | |
michael@0 | 463 | /** |
michael@0 | 464 | * Difference in seconds between coordinated universal |
michael@0 | 465 | * time and local time. E.g., -28,800 for PST (GMT-8hrs) |
michael@0 | 466 | * @return the difference in seconds between coordinated universal time and local time. |
michael@0 | 467 | * @internal |
michael@0 | 468 | */ |
michael@0 | 469 | U_INTERNAL int32_t U_EXPORT2 uprv_timezone(void); |
michael@0 | 470 | |
michael@0 | 471 | /** |
michael@0 | 472 | * tzname(0) Three-letter time-zone name derived from TZ environment |
michael@0 | 473 | * variable. E.g., "PST". |
michael@0 | 474 | * tzname(1) Three-letter DST zone name derived from TZ environment |
michael@0 | 475 | * variable. E.g., "PDT". If DST zone is omitted from TZ, |
michael@0 | 476 | * tzname(1) is an empty string. |
michael@0 | 477 | * @internal |
michael@0 | 478 | */ |
michael@0 | 479 | U_INTERNAL const char* U_EXPORT2 uprv_tzname(int n); |
michael@0 | 480 | |
michael@0 | 481 | /** |
michael@0 | 482 | * Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970. |
michael@0 | 483 | * This function is affected by 'faketime' and should be the bottleneck for all user-visible ICU time functions. |
michael@0 | 484 | * @return the UTC time measured in milliseconds |
michael@0 | 485 | * @internal |
michael@0 | 486 | */ |
michael@0 | 487 | U_INTERNAL UDate U_EXPORT2 uprv_getUTCtime(void); |
michael@0 | 488 | |
michael@0 | 489 | /** |
michael@0 | 490 | * Get UTC (GMT) time measured in milliseconds since 0:00 on 1/1/1970. |
michael@0 | 491 | * This function is not affected by 'faketime', so it should only be used by low level test functions- not by anything that |
michael@0 | 492 | * exposes time to the end user. |
michael@0 | 493 | * @return the UTC time measured in milliseconds |
michael@0 | 494 | * @internal |
michael@0 | 495 | */ |
michael@0 | 496 | U_INTERNAL UDate U_EXPORT2 uprv_getRawUTCtime(void); |
michael@0 | 497 | |
michael@0 | 498 | /** |
michael@0 | 499 | * Determine whether a pathname is absolute or not, as defined by the platform. |
michael@0 | 500 | * @param path Pathname to test |
michael@0 | 501 | * @return TRUE if the path is absolute |
michael@0 | 502 | * @internal (ICU 3.0) |
michael@0 | 503 | */ |
michael@0 | 504 | U_INTERNAL UBool U_EXPORT2 uprv_pathIsAbsolute(const char *path); |
michael@0 | 505 | |
michael@0 | 506 | /** |
michael@0 | 507 | * Use U_MAX_PTR instead of this function. |
michael@0 | 508 | * @param void pointer to test |
michael@0 | 509 | * @return the largest possible pointer greater than the base |
michael@0 | 510 | * @internal (ICU 3.8) |
michael@0 | 511 | */ |
michael@0 | 512 | U_INTERNAL void * U_EXPORT2 uprv_maximumPtr(void *base); |
michael@0 | 513 | |
michael@0 | 514 | /** |
michael@0 | 515 | * Maximum value of a (void*) - use to indicate the limit of an 'infinite' buffer. |
michael@0 | 516 | * In fact, buffer sizes must not exceed 2GB so that the difference between |
michael@0 | 517 | * the buffer limit and the buffer start can be expressed in an int32_t. |
michael@0 | 518 | * |
michael@0 | 519 | * The definition of U_MAX_PTR must fulfill the following conditions: |
michael@0 | 520 | * - return the largest possible pointer greater than base |
michael@0 | 521 | * - return a valid pointer according to the machine architecture (AS/400, 64-bit, etc.) |
michael@0 | 522 | * - avoid wrapping around at high addresses |
michael@0 | 523 | * - make sure that the returned pointer is not farther from base than 0x7fffffff bytes |
michael@0 | 524 | * |
michael@0 | 525 | * @param base The beginning of a buffer to find the maximum offset from |
michael@0 | 526 | * @internal |
michael@0 | 527 | */ |
michael@0 | 528 | #ifndef U_MAX_PTR |
michael@0 | 529 | # if U_PLATFORM == U_PF_OS390 && !defined(_LP64) |
michael@0 | 530 | /* We have 31-bit pointers. */ |
michael@0 | 531 | # define U_MAX_PTR(base) ((void *)0x7fffffff) |
michael@0 | 532 | # elif U_PLATFORM == U_PF_OS400 |
michael@0 | 533 | # define U_MAX_PTR(base) uprv_maximumPtr((void *)base) |
michael@0 | 534 | # elif 0 |
michael@0 | 535 | /* |
michael@0 | 536 | * For platforms where pointers are scalar values (which is normal, but unlike i5/OS) |
michael@0 | 537 | * but that do not define uintptr_t. |
michael@0 | 538 | * |
michael@0 | 539 | * However, this does not work on modern compilers: |
michael@0 | 540 | * The C++ standard does not define pointer overflow, and allows compilers to |
michael@0 | 541 | * assume that p+u>p for any pointer p and any integer u>0. |
michael@0 | 542 | * Thus, modern compilers optimize away the ">" comparison. |
michael@0 | 543 | * (See ICU tickets #7187 and #8096.) |
michael@0 | 544 | */ |
michael@0 | 545 | # define U_MAX_PTR(base) \ |
michael@0 | 546 | ((void *)(((char *)(base)+0x7fffffffu) > (char *)(base) \ |
michael@0 | 547 | ? ((char *)(base)+0x7fffffffu) \ |
michael@0 | 548 | : (char *)-1)) |
michael@0 | 549 | # else |
michael@0 | 550 | /* Default version. C++ standard compliant for scalar pointers. */ |
michael@0 | 551 | # define U_MAX_PTR(base) \ |
michael@0 | 552 | ((void *)(((uintptr_t)(base)+0x7fffffffu) > (uintptr_t)(base) \ |
michael@0 | 553 | ? ((uintptr_t)(base)+0x7fffffffu) \ |
michael@0 | 554 | : (uintptr_t)-1)) |
michael@0 | 555 | # endif |
michael@0 | 556 | #endif |
michael@0 | 557 | |
michael@0 | 558 | /* Dynamic Library Functions */ |
michael@0 | 559 | |
michael@0 | 560 | typedef void (UVoidFunction)(void); |
michael@0 | 561 | |
michael@0 | 562 | #if U_ENABLE_DYLOAD |
michael@0 | 563 | /** |
michael@0 | 564 | * Load a library |
michael@0 | 565 | * @internal (ICU 4.4) |
michael@0 | 566 | */ |
michael@0 | 567 | U_INTERNAL void * U_EXPORT2 uprv_dl_open(const char *libName, UErrorCode *status); |
michael@0 | 568 | |
michael@0 | 569 | /** |
michael@0 | 570 | * Close a library |
michael@0 | 571 | * @internal (ICU 4.4) |
michael@0 | 572 | */ |
michael@0 | 573 | U_INTERNAL void U_EXPORT2 uprv_dl_close( void *lib, UErrorCode *status); |
michael@0 | 574 | |
michael@0 | 575 | /** |
michael@0 | 576 | * Extract a symbol from a library (function) |
michael@0 | 577 | * @internal (ICU 4.8) |
michael@0 | 578 | */ |
michael@0 | 579 | U_INTERNAL UVoidFunction* U_EXPORT2 uprv_dlsym_func( void *lib, const char *symbolName, UErrorCode *status); |
michael@0 | 580 | |
michael@0 | 581 | /** |
michael@0 | 582 | * Extract a symbol from a library (function) |
michael@0 | 583 | * Not implemented, no clients. |
michael@0 | 584 | * @internal |
michael@0 | 585 | */ |
michael@0 | 586 | /* U_INTERNAL void * U_EXPORT2 uprv_dlsym_data( void *lib, const char *symbolName, UErrorCode *status); */ |
michael@0 | 587 | |
michael@0 | 588 | #endif |
michael@0 | 589 | |
michael@0 | 590 | /** |
michael@0 | 591 | * Define malloc and related functions |
michael@0 | 592 | * @internal |
michael@0 | 593 | */ |
michael@0 | 594 | #if U_PLATFORM == U_PF_OS400 |
michael@0 | 595 | # define uprv_default_malloc(x) _C_TS_malloc(x) |
michael@0 | 596 | # define uprv_default_realloc(x,y) _C_TS_realloc(x,y) |
michael@0 | 597 | # define uprv_default_free(x) _C_TS_free(x) |
michael@0 | 598 | /* also _C_TS_calloc(x) */ |
michael@0 | 599 | #else |
michael@0 | 600 | /* C defaults */ |
michael@0 | 601 | # define uprv_default_malloc(x) malloc(x) |
michael@0 | 602 | # define uprv_default_realloc(x,y) realloc(x,y) |
michael@0 | 603 | # define uprv_default_free(x) free(x) |
michael@0 | 604 | #endif |
michael@0 | 605 | |
michael@0 | 606 | |
michael@0 | 607 | #endif |