putilimp.h 19 KB

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