platform.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  1. /*
  2. ******************************************************************************
  3. *
  4. * Copyright (C) 1997-2015, International Business Machines
  5. * Corporation and others. All Rights Reserved.
  6. *
  7. ******************************************************************************
  8. *
  9. * FILE NAME : platform.h
  10. *
  11. * Date Name Description
  12. * 05/13/98 nos Creation (content moved here from ptypes.h).
  13. * 03/02/99 stephen Added AS400 support.
  14. * 03/30/99 stephen Added Linux support.
  15. * 04/13/99 stephen Reworked for autoconf.
  16. ******************************************************************************
  17. */
  18. #ifndef _PLATFORM_H
  19. #define _PLATFORM_H
  20. #include "uconfig.h"
  21. #include "uvernum.h"
  22. /**
  23. * \file
  24. * \brief Basic types for the platform.
  25. *
  26. * This file used to be generated by autoconf/configure.
  27. * Starting with ICU 49, platform.h is a normal source file,
  28. * to simplify cross-compiling and working with non-autoconf/make build systems.
  29. *
  30. * When a value in this file does not work on a platform, then please
  31. * try to derive it from the U_PLATFORM value
  32. * (for which we might need a new value constant in rare cases)
  33. * and/or from other macros that are predefined by the compiler
  34. * or defined in standard (POSIX or platform or compiler) headers.
  35. *
  36. * As a temporary workaround, you can add an explicit <code>#define</code> for some macros
  37. * before it is first tested, or add an equivalent -D macro definition
  38. * to the compiler's command line.
  39. *
  40. * Note: Some compilers provide ways to show the predefined macros.
  41. * For example, with gcc you can compile an empty .c file and have the compiler
  42. * print the predefined macros with
  43. * \code
  44. * gcc -E -dM -x c /dev/null | sort
  45. * \endcode
  46. * (You can provide an actual empty .c file rather than /dev/null.
  47. * <code>-x c++</code> is for C++.)
  48. */
  49. /**
  50. * Define some things so that they can be documented.
  51. * @internal
  52. */
  53. #ifdef U_IN_DOXYGEN
  54. /*
  55. * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented.
  56. * Solution: #define any defines for non @internal API here, so that they are visible in the docs. If you just set PREDEFINED in Doxyfile.in, they won't be documented.
  57. */
  58. /* None for now. */
  59. #endif
  60. /**
  61. * \def U_PLATFORM
  62. * The U_PLATFORM macro defines the platform we're on.
  63. *
  64. * We used to define one different, value-less macro per platform.
  65. * That made it hard to know the set of relevant platforms and macros,
  66. * and hard to deal with variants of platforms.
  67. *
  68. * Starting with ICU 49, we define platforms as numeric macros,
  69. * with ranges of values for related platforms and their variants.
  70. * The U_PLATFORM macro is set to one of these values.
  71. *
  72. * Historical note from the Solaris Wikipedia article:
  73. * AT&T and Sun collaborated on a project to merge the most popular Unix variants
  74. * on the market at that time: BSD, System V, and Xenix.
  75. * This became Unix System V Release 4 (SVR4).
  76. *
  77. * @internal
  78. */
  79. /** Unknown platform. @internal */
  80. #define U_PF_UNKNOWN 0
  81. /** Windows @internal */
  82. #define U_PF_WINDOWS 1000
  83. /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */
  84. #define U_PF_MINGW 1800
  85. /**
  86. * Cygwin. Windows, calls to cygwin1.dll for Posix functions,
  87. * using MSVC or GNU gcc and binutils.
  88. * @internal
  89. */
  90. #define U_PF_CYGWIN 1900
  91. /* Reserve 2000 for U_PF_UNIX? */
  92. /** HP-UX is based on UNIX System V. @internal */
  93. #define U_PF_HPUX 2100
  94. /** Solaris is a Unix operating system based on SVR4. @internal */
  95. #define U_PF_SOLARIS 2600
  96. /** BSD is a UNIX operating system derivative. @internal */
  97. #define U_PF_BSD 3000
  98. /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */
  99. #define U_PF_AIX 3100
  100. /** IRIX is based on UNIX System V with BSD extensions. @internal */
  101. #define U_PF_IRIX 3200
  102. /**
  103. * Darwin is a POSIX-compliant operating system, composed of code developed by Apple,
  104. * as well as code derived from NeXTSTEP, BSD, and other projects,
  105. * built around the Mach kernel.
  106. * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based.
  107. * (Original description modified from WikiPedia.)
  108. * @internal
  109. */
  110. #define U_PF_DARWIN 3500
  111. /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */
  112. #define U_PF_IPHONE 3550
  113. /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */
  114. #define U_PF_QNX 3700
  115. /** Linux is a Unix-like operating system. @internal */
  116. #define U_PF_LINUX 4000
  117. /**
  118. * Native Client is pretty close to Linux.
  119. * See https://developer.chrome.com/native-client and
  120. * http://www.chromium.org/nativeclient
  121. * @internal
  122. */
  123. #define U_PF_BROWSER_NATIVE_CLIENT 4020
  124. /** Android is based on Linux. @internal */
  125. #define U_PF_ANDROID 4050
  126. /* Maximum value for Linux-based platform is 4499 */
  127. /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */
  128. #define U_PF_OS390 9000
  129. /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */
  130. #define U_PF_OS400 9400
  131. #ifdef U_PLATFORM
  132. /* Use the predefined value. */
  133. #elif defined(__MINGW32__)
  134. # define U_PLATFORM U_PF_MINGW
  135. #elif defined(__CYGWIN__)
  136. # define U_PLATFORM U_PF_CYGWIN
  137. #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
  138. # define U_PLATFORM U_PF_WINDOWS
  139. #elif defined(__ANDROID__)
  140. # define U_PLATFORM U_PF_ANDROID
  141. /* Android wchar_t support depends on the API level. */
  142. # include <android/api-level.h>
  143. #elif defined(__native_client__)
  144. # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT
  145. #elif defined(linux) || defined(__linux__) || defined(__linux)
  146. # define U_PLATFORM U_PF_LINUX
  147. #elif defined(__APPLE__) && defined(__MACH__)
  148. # include <TargetConditionals.h>
  149. # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */
  150. # define U_PLATFORM U_PF_IPHONE
  151. # else
  152. # define U_PLATFORM U_PF_DARWIN
  153. # endif
  154. #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
  155. # define U_PLATFORM U_PF_BSD
  156. #elif defined(sun) || defined(__sun)
  157. /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
  158. # define U_PLATFORM U_PF_SOLARIS
  159. # if defined(__GNUC__)
  160. /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
  161. * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
  162. * is included which does not include this header file.
  163. */
  164. # include <sys/isa_defs.h>
  165. # endif
  166. #elif defined(_AIX) || defined(__TOS_AIX__)
  167. # define U_PLATFORM U_PF_AIX
  168. #elif defined(_hpux) || defined(hpux) || defined(__hpux)
  169. # define U_PLATFORM U_PF_HPUX
  170. #elif defined(sgi) || defined(__sgi)
  171. # define U_PLATFORM U_PF_IRIX
  172. #elif defined(__QNX__) || defined(__QNXNTO__)
  173. # define U_PLATFORM U_PF_QNX
  174. #elif defined(__TOS_MVS__)
  175. # define U_PLATFORM U_PF_OS390
  176. #elif defined(__OS400__) || defined(__TOS_OS400__)
  177. # define U_PLATFORM U_PF_OS400
  178. #else
  179. # define U_PLATFORM U_PF_UNKNOWN
  180. #endif
  181. /**
  182. * \def CYGWINMSVC
  183. * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
  184. * Otherwise undefined.
  185. * @internal
  186. */
  187. /* Commented out because this is already set in mh-cygwin-msvc
  188. #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
  189. # define CYGWINMSVC
  190. #endif
  191. */
  192. /**
  193. * \def U_PLATFORM_USES_ONLY_WIN32_API
  194. * Defines whether the platform uses only the Win32 API.
  195. * Set to 1 for Windows/MSVC and MinGW but not Cygwin.
  196. * @internal
  197. */
  198. #ifdef U_PLATFORM_USES_ONLY_WIN32_API
  199. /* Use the predefined value. */
  200. #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
  201. # define U_PLATFORM_USES_ONLY_WIN32_API 1
  202. #else
  203. /* Cygwin implements POSIX. */
  204. # define U_PLATFORM_USES_ONLY_WIN32_API 0
  205. #endif
  206. /**
  207. * \def U_PLATFORM_HAS_WIN32_API
  208. * Defines whether the Win32 API is available on the platform.
  209. * Set to 1 for Windows/MSVC, MinGW and Cygwin.
  210. * @internal
  211. */
  212. #ifdef U_PLATFORM_HAS_WIN32_API
  213. /* Use the predefined value. */
  214. #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
  215. # define U_PLATFORM_HAS_WIN32_API 1
  216. #else
  217. # define U_PLATFORM_HAS_WIN32_API 0
  218. #endif
  219. /**
  220. * \def U_PLATFORM_IMPLEMENTS_POSIX
  221. * Defines whether the platform implements (most of) the POSIX API.
  222. * Set to 1 for Cygwin and most other platforms.
  223. * @internal
  224. */
  225. #ifdef U_PLATFORM_IMPLEMENTS_POSIX
  226. /* Use the predefined value. */
  227. #elif U_PLATFORM_USES_ONLY_WIN32_API
  228. # define U_PLATFORM_IMPLEMENTS_POSIX 0
  229. #else
  230. # define U_PLATFORM_IMPLEMENTS_POSIX 1
  231. #endif
  232. /**
  233. * \def U_PLATFORM_IS_LINUX_BASED
  234. * Defines whether the platform is Linux or one of its derivatives.
  235. * @internal
  236. */
  237. #ifdef U_PLATFORM_IS_LINUX_BASED
  238. /* Use the predefined value. */
  239. #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
  240. # define U_PLATFORM_IS_LINUX_BASED 1
  241. #else
  242. # define U_PLATFORM_IS_LINUX_BASED 0
  243. #endif
  244. /**
  245. * \def U_PLATFORM_IS_DARWIN_BASED
  246. * Defines whether the platform is Darwin or one of its derivatives.
  247. * @internal
  248. */
  249. #ifdef U_PLATFORM_IS_DARWIN_BASED
  250. /* Use the predefined value. */
  251. #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
  252. # define U_PLATFORM_IS_DARWIN_BASED 1
  253. #else
  254. # define U_PLATFORM_IS_DARWIN_BASED 0
  255. #endif
  256. /**
  257. * \def U_HAVE_STDINT_H
  258. * Defines whether stdint.h is available. It is a C99 standard header.
  259. * We used to include inttypes.h which includes stdint.h but we usually do not need
  260. * the additional definitions from inttypes.h.
  261. * @internal
  262. */
  263. #ifdef U_HAVE_STDINT_H
  264. /* Use the predefined value. */
  265. #elif U_PLATFORM_USES_ONLY_WIN32_API
  266. # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
  267. /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
  268. # define U_HAVE_STDINT_H 1
  269. # else
  270. # define U_HAVE_STDINT_H 0
  271. # endif
  272. #elif U_PLATFORM == U_PF_SOLARIS
  273. /* Solaris has inttypes.h but not stdint.h. */
  274. # define U_HAVE_STDINT_H 0
  275. #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
  276. /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
  277. # define U_HAVE_STDINT_H 0
  278. #else
  279. # define U_HAVE_STDINT_H 1
  280. #endif
  281. /**
  282. * \def U_HAVE_INTTYPES_H
  283. * Defines whether inttypes.h is available. It is a C99 standard header.
  284. * We include inttypes.h where it is available but stdint.h is not.
  285. * @internal
  286. */
  287. #ifdef U_HAVE_INTTYPES_H
  288. /* Use the predefined value. */
  289. #elif U_PLATFORM == U_PF_SOLARIS
  290. /* Solaris has inttypes.h but not stdint.h. */
  291. # define U_HAVE_INTTYPES_H 1
  292. #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
  293. /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
  294. # define U_HAVE_INTTYPES_H 1
  295. #else
  296. /* Most platforms have both inttypes.h and stdint.h, or neither. */
  297. # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
  298. #endif
  299. /**
  300. * \def U_IOSTREAM_SOURCE
  301. * Defines what support for C++ streams is available.
  302. *
  303. * If U_IOSTREAM_SOURCE is set to 199711, then &lt;iostream&gt; is available
  304. * (the ISO/IEC C++ FDIS was published in November 1997), and then
  305. * one should qualify streams using the std namespace in ICU header
  306. * files.
  307. * Starting with ICU 49, this is the only supported version.
  308. *
  309. * If U_IOSTREAM_SOURCE is set to 198506, then &lt;iostream.h&gt; is
  310. * available instead (in June 1985 Stroustrup published
  311. * "An Extensible I/O Facility for C++" at the summer USENIX conference).
  312. * Starting with ICU 49, this version is not supported any more.
  313. *
  314. * If U_IOSTREAM_SOURCE is 0 (or any value less than 199711),
  315. * then C++ streams are not available and
  316. * support for them will be silently suppressed in ICU.
  317. *
  318. * @internal
  319. */
  320. #ifndef U_IOSTREAM_SOURCE
  321. #define U_IOSTREAM_SOURCE 199711
  322. #endif
  323. /**
  324. * \def U_HAVE_STD_STRING
  325. * Defines whether the standard C++ (STL) &lt;string&gt; header is available.
  326. * @internal
  327. */
  328. #ifdef U_HAVE_STD_STRING
  329. /* Use the predefined value. */
  330. #else
  331. # define U_HAVE_STD_STRING 1
  332. #endif
  333. /*===========================================================================*/
  334. /** @{ Compiler and environment features */
  335. /*===========================================================================*/
  336. /**
  337. * \def U_GCC_MAJOR_MINOR
  338. * Indicates whether the compiler is gcc (test for != 0),
  339. * and if so, contains its major (times 100) and minor version numbers.
  340. * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
  341. *
  342. * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
  343. * use "#if U_GCC_MAJOR_MINOR >= 406".
  344. * @internal
  345. */
  346. #ifdef __GNUC__
  347. # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
  348. #else
  349. # define U_GCC_MAJOR_MINOR 0
  350. #endif
  351. /**
  352. * \def U_IS_BIG_ENDIAN
  353. * Determines the endianness of the platform.
  354. * @internal
  355. */
  356. #ifdef U_IS_BIG_ENDIAN
  357. /* Use the predefined value. */
  358. #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
  359. # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
  360. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
  361. /* gcc */
  362. # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  363. #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
  364. # define U_IS_BIG_ENDIAN 1
  365. #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
  366. # define U_IS_BIG_ENDIAN 0
  367. #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
  368. /* These platforms do not appear to predefine any endianness macros. */
  369. # define U_IS_BIG_ENDIAN 1
  370. #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
  371. /* HPPA do not appear to predefine any endianness macros. */
  372. # define U_IS_BIG_ENDIAN 1
  373. #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
  374. /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
  375. # define U_IS_BIG_ENDIAN 1
  376. #else
  377. # define U_IS_BIG_ENDIAN 0
  378. #endif
  379. /**
  380. * \def U_HAVE_PLACEMENT_NEW
  381. * Determines whether to override placement new and delete for STL.
  382. * @stable ICU 2.6
  383. */
  384. #ifdef U_HAVE_PLACEMENT_NEW
  385. /* Use the predefined value. */
  386. #elif defined(__BORLANDC__)
  387. # define U_HAVE_PLACEMENT_NEW 0
  388. #else
  389. # define U_HAVE_PLACEMENT_NEW 1
  390. #endif
  391. /**
  392. * \def U_HAVE_DEBUG_LOCATION_NEW
  393. * Define this to define the MFC debug version of the operator new.
  394. *
  395. * @stable ICU 3.4
  396. */
  397. #ifdef U_HAVE_DEBUG_LOCATION_NEW
  398. /* Use the predefined value. */
  399. #elif defined(_MSC_VER)
  400. # define U_HAVE_DEBUG_LOCATION_NEW 1
  401. #else
  402. # define U_HAVE_DEBUG_LOCATION_NEW 0
  403. #endif
  404. /* Compatibility with non clang compilers */
  405. #ifndef __has_attribute
  406. # define __has_attribute(x) 0
  407. #endif
  408. /**
  409. * \def U_MALLOC_ATTR
  410. * Attribute to mark functions as malloc-like
  411. * @internal
  412. */
  413. #if defined(__GNUC__) && __GNUC__>=3
  414. # define U_MALLOC_ATTR __attribute__ ((__malloc__))
  415. #else
  416. # define U_MALLOC_ATTR
  417. #endif
  418. /**
  419. * \def U_ALLOC_SIZE_ATTR
  420. * Attribute to specify the size of the allocated buffer for malloc-like functions
  421. * @internal
  422. */
  423. #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)
  424. # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
  425. # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
  426. #else
  427. # define U_ALLOC_SIZE_ATTR(X)
  428. # define U_ALLOC_SIZE_ATTR2(X,Y)
  429. #endif
  430. /** @} */
  431. /*===========================================================================*/
  432. /** @{ Character data types */
  433. /*===========================================================================*/
  434. /**
  435. * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
  436. * @stable ICU 2.0
  437. */
  438. #define U_ASCII_FAMILY 0
  439. /**
  440. * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
  441. * @stable ICU 2.0
  442. */
  443. #define U_EBCDIC_FAMILY 1
  444. /**
  445. * \def U_CHARSET_FAMILY
  446. *
  447. * <p>These definitions allow to specify the encoding of text
  448. * in the char data type as defined by the platform and the compiler.
  449. * It is enough to determine the code point values of "invariant characters",
  450. * which are the ones shared by all encodings that are in use
  451. * on a given platform.</p>
  452. *
  453. * <p>Those "invariant characters" should be all the uppercase and lowercase
  454. * latin letters, the digits, the space, and "basic punctuation".
  455. * Also, '\\n', '\\r', '\\t' should be available.</p>
  456. *
  457. * <p>The list of "invariant characters" is:<br>
  458. * \code
  459. * A-Z a-z 0-9 SPACE " % &amp; ' ( ) * + , - . / : ; < = > ? _
  460. * \endcode
  461. * <br>
  462. * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>
  463. *
  464. * <p>This matches the IBM Syntactic Character Set (CS 640).</p>
  465. *
  466. * <p>In other words, all the graphic characters in 7-bit ASCII should
  467. * be safely accessible except the following:</p>
  468. *
  469. * \code
  470. * '\' <backslash>
  471. * '[' <left bracket>
  472. * ']' <right bracket>
  473. * '{' <left brace>
  474. * '}' <right brace>
  475. * '^' <circumflex>
  476. * '~' <tilde>
  477. * '!' <exclamation mark>
  478. * '#' <number sign>
  479. * '|' <vertical line>
  480. * '$' <dollar sign>
  481. * '@' <commercial at>
  482. * '`' <grave accent>
  483. * \endcode
  484. * @stable ICU 2.0
  485. */
  486. #ifdef U_CHARSET_FAMILY
  487. /* Use the predefined value. */
  488. #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
  489. # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
  490. #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
  491. # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
  492. #else
  493. # define U_CHARSET_FAMILY U_ASCII_FAMILY
  494. #endif
  495. /**
  496. * \def U_CHARSET_IS_UTF8
  497. *
  498. * Hardcode the default charset to UTF-8.
  499. *
  500. * If this is set to 1, then
  501. * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
  502. * contain UTF-8 text, regardless of what the system API uses
  503. * - some ICU code will use fast functions like u_strFromUTF8()
  504. * rather than the more general and more heavy-weight conversion API (ucnv.h)
  505. * - ucnv_getDefaultName() always returns "UTF-8"
  506. * - ucnv_setDefaultName() is disabled and will not change the default charset
  507. * - static builds of ICU are smaller
  508. * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
  509. * configuration option (see unicode/uconfig.h)
  510. * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
  511. *
  512. * @stable ICU 4.2
  513. * @see UCONFIG_NO_CONVERSION
  514. */
  515. #ifdef U_CHARSET_IS_UTF8
  516. /* Use the predefined value. */
  517. #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
  518. # define U_CHARSET_IS_UTF8 1
  519. #else
  520. # define U_CHARSET_IS_UTF8 0
  521. #endif
  522. /** @} */
  523. /*===========================================================================*/
  524. /** @{ Information about wchar support */
  525. /*===========================================================================*/
  526. /**
  527. * \def U_HAVE_WCHAR_H
  528. * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
  529. *
  530. * @stable ICU 2.0
  531. */
  532. #ifdef U_HAVE_WCHAR_H
  533. /* Use the predefined value. */
  534. #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
  535. /*
  536. * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
  537. * The type and header existed, but the library functions did not work as expected.
  538. * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
  539. */
  540. # define U_HAVE_WCHAR_H 0
  541. #else
  542. # define U_HAVE_WCHAR_H 1
  543. #endif
  544. /**
  545. * \def U_SIZEOF_WCHAR_T
  546. * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
  547. *
  548. * @stable ICU 2.0
  549. */
  550. #ifdef U_SIZEOF_WCHAR_T
  551. /* Use the predefined value. */
  552. #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
  553. /*
  554. * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
  555. * Newer Mac OS X has size 4.
  556. */
  557. # define U_SIZEOF_WCHAR_T 1
  558. #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
  559. # define U_SIZEOF_WCHAR_T 2
  560. #elif U_PLATFORM == U_PF_AIX
  561. /*
  562. * AIX 6.1 information, section "Wide character data representation":
  563. * "... the wchar_t datatype is 32-bit in the 64-bit environment and
  564. * 16-bit in the 32-bit environment."
  565. * and
  566. * "All locales use Unicode for their wide character code values (process code),
  567. * except the IBM-eucTW codeset."
  568. */
  569. # ifdef __64BIT__
  570. # define U_SIZEOF_WCHAR_T 4
  571. # else
  572. # define U_SIZEOF_WCHAR_T 2
  573. # endif
  574. #elif U_PLATFORM == U_PF_OS390
  575. /*
  576. * z/OS V1R11 information center, section "LP64 | ILP32":
  577. * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
  578. * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
  579. */
  580. # ifdef _LP64
  581. # define U_SIZEOF_WCHAR_T 4
  582. # else
  583. # define U_SIZEOF_WCHAR_T 2
  584. # endif
  585. #elif U_PLATFORM == U_PF_OS400
  586. # if defined(__UTF32__)
  587. /*
  588. * LOCALETYPE(*LOCALEUTF) is specified.
  589. * Wide-character strings are in UTF-32,
  590. * narrow-character strings are in UTF-8.
  591. */
  592. # define U_SIZEOF_WCHAR_T 4
  593. # elif defined(__UCS2__)
  594. /*
  595. * LOCALETYPE(*LOCALEUCS2) is specified.
  596. * Wide-character strings are in UCS-2,
  597. * narrow-character strings are in EBCDIC.
  598. */
  599. # define U_SIZEOF_WCHAR_T 2
  600. #else
  601. /*
  602. * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
  603. * Wide-character strings are in 16-bit EBCDIC,
  604. * narrow-character strings are in EBCDIC.
  605. */
  606. # define U_SIZEOF_WCHAR_T 2
  607. # endif
  608. #else
  609. # define U_SIZEOF_WCHAR_T 4
  610. #endif
  611. #ifndef U_HAVE_WCSCPY
  612. #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
  613. #endif
  614. /** @} */
  615. /**
  616. * \def U_HAVE_CHAR16_T
  617. * Defines whether the char16_t type is available for UTF-16
  618. * and u"abc" UTF-16 string literals are supported.
  619. * This is a new standard type and standard string literal syntax in C++0x
  620. * but has been available in some compilers before.
  621. * @internal
  622. */
  623. #ifdef U_HAVE_CHAR16_T
  624. /* Use the predefined value. */
  625. #else
  626. /*
  627. * Notes:
  628. * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
  629. * does not support u"abc" string literals.
  630. * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
  631. * does not support u"abc" string literals.
  632. * C++11 and C11 require support for UTF-16 literals
  633. */
  634. # if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
  635. # define U_HAVE_CHAR16_T 1
  636. # else
  637. # define U_HAVE_CHAR16_T 0
  638. # endif
  639. #endif
  640. /**
  641. * @{
  642. * \def U_DECLARE_UTF16
  643. * Do not use this macro because it is not defined on all platforms.
  644. * Use the UNICODE_STRING or U_STRING_DECL macros instead.
  645. * @internal
  646. */
  647. #ifdef U_DECLARE_UTF16
  648. /* Use the predefined value. */
  649. #elif U_HAVE_CHAR16_T \
  650. || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
  651. || (defined(__HP_aCC) && __HP_aCC >= 035000) \
  652. || (defined(__HP_cc) && __HP_cc >= 111106)
  653. # define U_DECLARE_UTF16(string) u ## string
  654. #elif U_SIZEOF_WCHAR_T == 2 \
  655. && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
  656. # define U_DECLARE_UTF16(string) L ## string
  657. #else
  658. /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
  659. #endif
  660. /** @} */
  661. /*===========================================================================*/
  662. /** @{ Symbol import-export control */
  663. /*===========================================================================*/
  664. #ifdef U_EXPORT
  665. /* Use the predefined value. */
  666. #elif defined(U_STATIC_IMPLEMENTATION)
  667. # define U_EXPORT
  668. #elif defined(__GNUC__)
  669. # define U_EXPORT __attribute__((visibility("default")))
  670. #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
  671. || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
  672. # define U_EXPORT __global
  673. /*#elif defined(__HP_aCC) || defined(__HP_cc)
  674. # define U_EXPORT __declspec(dllexport)*/
  675. #elif defined(_MSC_VER)
  676. # define U_EXPORT __declspec(dllexport)
  677. #else
  678. # define U_EXPORT
  679. #endif
  680. /* U_CALLCONV is releated to U_EXPORT2 */
  681. #ifdef U_EXPORT2
  682. /* Use the predefined value. */
  683. #elif defined(_MSC_VER)
  684. # define U_EXPORT2 __cdecl
  685. #else
  686. # define U_EXPORT2
  687. #endif
  688. #ifdef U_IMPORT
  689. /* Use the predefined value. */
  690. #elif defined(_MSC_VER)
  691. /* Windows needs to export/import data. */
  692. # define U_IMPORT __declspec(dllimport)
  693. #else
  694. # define U_IMPORT
  695. #endif
  696. /**
  697. * \def U_CALLCONV
  698. * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
  699. * in callback function typedefs to make sure that the calling convention
  700. * is compatible.
  701. *
  702. * This is only used for non-ICU-API functions.
  703. * When a function is a public ICU API,
  704. * you must use the U_CAPI and U_EXPORT2 qualifiers.
  705. * @stable ICU 2.0
  706. */
  707. #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
  708. # define U_CALLCONV __cdecl
  709. #else
  710. # define U_CALLCONV U_EXPORT2
  711. #endif
  712. /* @} */
  713. #endif