platform.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854
  1. /*
  2. ******************************************************************************
  3. *
  4. * Copyright (C) 1997-2016, 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 "unicode/uconfig.h"
  21. #include "unicode/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. # if defined(__FreeBSD__)
  156. # include <sys/endian.h>
  157. # endif
  158. # define U_PLATFORM U_PF_BSD
  159. #elif defined(sun) || defined(__sun)
  160. /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
  161. # define U_PLATFORM U_PF_SOLARIS
  162. # if defined(__GNUC__)
  163. /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
  164. * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
  165. * is included which does not include this header file.
  166. */
  167. # include <sys/isa_defs.h>
  168. # endif
  169. #elif defined(_AIX) || defined(__TOS_AIX__)
  170. # define U_PLATFORM U_PF_AIX
  171. #elif defined(_hpux) || defined(hpux) || defined(__hpux)
  172. # define U_PLATFORM U_PF_HPUX
  173. #elif defined(sgi) || defined(__sgi)
  174. # define U_PLATFORM U_PF_IRIX
  175. #elif defined(__QNX__) || defined(__QNXNTO__)
  176. # define U_PLATFORM U_PF_QNX
  177. #elif defined(__TOS_MVS__)
  178. # define U_PLATFORM U_PF_OS390
  179. #elif defined(__OS400__) || defined(__TOS_OS400__)
  180. # define U_PLATFORM U_PF_OS400
  181. #else
  182. # define U_PLATFORM U_PF_UNKNOWN
  183. #endif
  184. /**
  185. * \def CYGWINMSVC
  186. * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
  187. * Otherwise undefined.
  188. * @internal
  189. */
  190. /* Commented out because this is already set in mh-cygwin-msvc
  191. #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
  192. # define CYGWINMSVC
  193. #endif
  194. */
  195. /**
  196. * \def U_PLATFORM_USES_ONLY_WIN32_API
  197. * Defines whether the platform uses only the Win32 API.
  198. * Set to 1 for Windows/MSVC and MinGW but not Cygwin.
  199. * @internal
  200. */
  201. #ifdef U_PLATFORM_USES_ONLY_WIN32_API
  202. /* Use the predefined value. */
  203. #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
  204. # define U_PLATFORM_USES_ONLY_WIN32_API 1
  205. #else
  206. /* Cygwin implements POSIX. */
  207. # define U_PLATFORM_USES_ONLY_WIN32_API 0
  208. #endif
  209. /**
  210. * \def U_PLATFORM_HAS_WIN32_API
  211. * Defines whether the Win32 API is available on the platform.
  212. * Set to 1 for Windows/MSVC, MinGW and Cygwin.
  213. * @internal
  214. */
  215. #ifdef U_PLATFORM_HAS_WIN32_API
  216. /* Use the predefined value. */
  217. #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
  218. # define U_PLATFORM_HAS_WIN32_API 1
  219. #else
  220. # define U_PLATFORM_HAS_WIN32_API 0
  221. #endif
  222. /**
  223. * \def U_PLATFORM_IMPLEMENTS_POSIX
  224. * Defines whether the platform implements (most of) the POSIX API.
  225. * Set to 1 for Cygwin and most other platforms.
  226. * @internal
  227. */
  228. #ifdef U_PLATFORM_IMPLEMENTS_POSIX
  229. /* Use the predefined value. */
  230. #elif U_PLATFORM_USES_ONLY_WIN32_API
  231. # define U_PLATFORM_IMPLEMENTS_POSIX 0
  232. #else
  233. # define U_PLATFORM_IMPLEMENTS_POSIX 1
  234. #endif
  235. /**
  236. * \def U_PLATFORM_IS_LINUX_BASED
  237. * Defines whether the platform is Linux or one of its derivatives.
  238. * @internal
  239. */
  240. #ifdef U_PLATFORM_IS_LINUX_BASED
  241. /* Use the predefined value. */
  242. #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
  243. # define U_PLATFORM_IS_LINUX_BASED 1
  244. #else
  245. # define U_PLATFORM_IS_LINUX_BASED 0
  246. #endif
  247. /**
  248. * \def U_PLATFORM_IS_DARWIN_BASED
  249. * Defines whether the platform is Darwin or one of its derivatives.
  250. * @internal
  251. */
  252. #ifdef U_PLATFORM_IS_DARWIN_BASED
  253. /* Use the predefined value. */
  254. #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
  255. # define U_PLATFORM_IS_DARWIN_BASED 1
  256. #else
  257. # define U_PLATFORM_IS_DARWIN_BASED 0
  258. #endif
  259. /**
  260. * \def U_HAVE_STDINT_H
  261. * Defines whether stdint.h is available. It is a C99 standard header.
  262. * We used to include inttypes.h which includes stdint.h but we usually do not need
  263. * the additional definitions from inttypes.h.
  264. * @internal
  265. */
  266. #ifdef U_HAVE_STDINT_H
  267. /* Use the predefined value. */
  268. #elif U_PLATFORM_USES_ONLY_WIN32_API
  269. # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
  270. /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
  271. # define U_HAVE_STDINT_H 1
  272. # else
  273. # define U_HAVE_STDINT_H 0
  274. # endif
  275. #elif U_PLATFORM == U_PF_SOLARIS
  276. /* Solaris has inttypes.h but not stdint.h. */
  277. # define U_HAVE_STDINT_H 0
  278. #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
  279. /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
  280. # define U_HAVE_STDINT_H 0
  281. #else
  282. # define U_HAVE_STDINT_H 1
  283. #endif
  284. /**
  285. * \def U_HAVE_INTTYPES_H
  286. * Defines whether inttypes.h is available. It is a C99 standard header.
  287. * We include inttypes.h where it is available but stdint.h is not.
  288. * @internal
  289. */
  290. #ifdef U_HAVE_INTTYPES_H
  291. /* Use the predefined value. */
  292. #elif U_PLATFORM == U_PF_SOLARIS
  293. /* Solaris has inttypes.h but not stdint.h. */
  294. # define U_HAVE_INTTYPES_H 1
  295. #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
  296. /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
  297. # define U_HAVE_INTTYPES_H 1
  298. #else
  299. /* Most platforms have both inttypes.h and stdint.h, or neither. */
  300. # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
  301. #endif
  302. /**
  303. * \def U_IOSTREAM_SOURCE
  304. * Defines what support for C++ streams is available.
  305. *
  306. * If U_IOSTREAM_SOURCE is set to 199711, then &lt;iostream&gt; is available
  307. * (the ISO/IEC C++ FDIS was published in November 1997), and then
  308. * one should qualify streams using the std namespace in ICU header
  309. * files.
  310. * Starting with ICU 49, this is the only supported version.
  311. *
  312. * If U_IOSTREAM_SOURCE is set to 198506, then &lt;iostream.h&gt; is
  313. * available instead (in June 1985 Stroustrup published
  314. * "An Extensible I/O Facility for C++" at the summer USENIX conference).
  315. * Starting with ICU 49, this version is not supported any more.
  316. *
  317. * If U_IOSTREAM_SOURCE is 0 (or any value less than 199711),
  318. * then C++ streams are not available and
  319. * support for them will be silently suppressed in ICU.
  320. *
  321. * @internal
  322. */
  323. #ifndef U_IOSTREAM_SOURCE
  324. #define U_IOSTREAM_SOURCE 199711
  325. #endif
  326. /**
  327. * \def U_HAVE_STD_STRING
  328. * Defines whether the standard C++ (STL) &lt;string&gt; header is available.
  329. * @internal
  330. */
  331. #ifdef U_HAVE_STD_STRING
  332. /* Use the predefined value. */
  333. #else
  334. # define U_HAVE_STD_STRING 1
  335. #endif
  336. /*===========================================================================*/
  337. /** @{ Compiler and environment features */
  338. /*===========================================================================*/
  339. /**
  340. * \def U_GCC_MAJOR_MINOR
  341. * Indicates whether the compiler is gcc (test for != 0),
  342. * and if so, contains its major (times 100) and minor version numbers.
  343. * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
  344. *
  345. * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
  346. * use "#if U_GCC_MAJOR_MINOR >= 406".
  347. * @internal
  348. */
  349. #ifdef __GNUC__
  350. # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
  351. #else
  352. # define U_GCC_MAJOR_MINOR 0
  353. #endif
  354. /**
  355. * \def U_IS_BIG_ENDIAN
  356. * Determines the endianness of the platform.
  357. * @internal
  358. */
  359. #ifdef U_IS_BIG_ENDIAN
  360. /* Use the predefined value. */
  361. #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
  362. # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
  363. #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
  364. /* gcc */
  365. # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
  366. #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
  367. # define U_IS_BIG_ENDIAN 1
  368. #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
  369. # define U_IS_BIG_ENDIAN 0
  370. #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
  371. /* These platforms do not appear to predefine any endianness macros. */
  372. # define U_IS_BIG_ENDIAN 1
  373. #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
  374. /* HPPA do not appear to predefine any endianness macros. */
  375. # define U_IS_BIG_ENDIAN 1
  376. #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
  377. /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
  378. # define U_IS_BIG_ENDIAN 1
  379. #else
  380. # define U_IS_BIG_ENDIAN 0
  381. #endif
  382. /**
  383. * \def U_HAVE_PLACEMENT_NEW
  384. * Determines whether to override placement new and delete for STL.
  385. * @stable ICU 2.6
  386. */
  387. #ifdef U_HAVE_PLACEMENT_NEW
  388. /* Use the predefined value. */
  389. #elif defined(__BORLANDC__)
  390. # define U_HAVE_PLACEMENT_NEW 0
  391. #else
  392. # define U_HAVE_PLACEMENT_NEW 1
  393. #endif
  394. /**
  395. * \def U_HAVE_DEBUG_LOCATION_NEW
  396. * Define this to define the MFC debug version of the operator new.
  397. *
  398. * @stable ICU 3.4
  399. */
  400. #ifdef U_HAVE_DEBUG_LOCATION_NEW
  401. /* Use the predefined value. */
  402. #elif defined(_MSC_VER)
  403. # define U_HAVE_DEBUG_LOCATION_NEW 1
  404. #else
  405. # define U_HAVE_DEBUG_LOCATION_NEW 0
  406. #endif
  407. /* Compatibility with non clang compilers: http://clang.llvm.org/docs/LanguageExtensions.html */
  408. #ifndef __has_attribute
  409. # define __has_attribute(x) 0
  410. #endif
  411. #ifndef __has_cpp_attribute
  412. # define __has_cpp_attribute(x) 0
  413. #endif
  414. #ifndef __has_builtin
  415. # define __has_builtin(x) 0
  416. #endif
  417. #ifndef __has_feature
  418. # define __has_feature(x) 0
  419. #endif
  420. #ifndef __has_extension
  421. # define __has_extension(x) 0
  422. #endif
  423. #ifndef __has_warning
  424. # define __has_warning(x) 0
  425. #endif
  426. /**
  427. * \def U_MALLOC_ATTR
  428. * Attribute to mark functions as malloc-like
  429. * @internal
  430. */
  431. #if defined(__GNUC__) && __GNUC__>=3
  432. # define U_MALLOC_ATTR __attribute__ ((__malloc__))
  433. #else
  434. # define U_MALLOC_ATTR
  435. #endif
  436. /**
  437. * \def U_ALLOC_SIZE_ATTR
  438. * Attribute to specify the size of the allocated buffer for malloc-like functions
  439. * @internal
  440. */
  441. #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)
  442. # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
  443. # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
  444. #else
  445. # define U_ALLOC_SIZE_ATTR(X)
  446. # define U_ALLOC_SIZE_ATTR2(X,Y)
  447. #endif
  448. /**
  449. * \def U_CPLUSPLUS_VERSION
  450. * 0 if no C++; 1, 11, 14, ... if C++.
  451. * Support for specific features cannot always be determined by the C++ version alone.
  452. * @internal
  453. */
  454. #ifdef U_CPLUSPLUS_VERSION
  455. # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
  456. # undef U_CPLUSPLUS_VERSION
  457. # define U_CPLUSPLUS_VERSION 0
  458. # endif
  459. /* Otherwise use the predefined value. */
  460. #elif !defined(__cplusplus)
  461. # define U_CPLUSPLUS_VERSION 0
  462. #elif __cplusplus >= 201402L
  463. # define U_CPLUSPLUS_VERSION 14
  464. #elif __cplusplus >= 201103L
  465. # define U_CPLUSPLUS_VERSION 11
  466. #else
  467. // C++98 or C++03
  468. # define U_CPLUSPLUS_VERSION 1
  469. #endif
  470. /**
  471. * \def U_HAVE_RVALUE_REFERENCES
  472. * Set to 1 if the compiler supports rvalue references.
  473. * C++11 feature, necessary for move constructor & move assignment.
  474. * @internal
  475. */
  476. #ifdef U_HAVE_RVALUE_REFERENCES
  477. /* Use the predefined value. */
  478. #elif U_CPLUSPLUS_VERSION >= 11 || __has_feature(cxx_rvalue_references) \
  479. || defined(__GXX_EXPERIMENTAL_CXX0X__) \
  480. || (defined(_MSC_VER) && _MSC_VER >= 1600) /* Visual Studio 2010 */
  481. # define U_HAVE_RVALUE_REFERENCES 1
  482. #else
  483. # define U_HAVE_RVALUE_REFERENCES 0
  484. #endif
  485. /**
  486. * \def U_NOEXCEPT
  487. * "noexcept" if supported, otherwise empty.
  488. * Some code, especially STL containers, uses move semantics of objects only
  489. * if the move constructor and the move operator are declared as not throwing exceptions.
  490. * @internal
  491. */
  492. #ifdef U_NOEXCEPT
  493. /* Use the predefined value. */
  494. #elif defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS /* Visual Studio */
  495. # define U_NOEXCEPT
  496. #elif U_CPLUSPLUS_VERSION >= 11 || __has_feature(cxx_noexcept) || __has_extension(cxx_noexcept) \
  497. || (defined(_MSC_VER) && _MSC_VER >= 1900) /* Visual Studio 2015 */
  498. # define U_NOEXCEPT noexcept
  499. #else
  500. # define U_NOEXCEPT
  501. #endif
  502. /**
  503. * \def U_FALLTHROUGH
  504. * Annotate intentional fall-through between switch labels.
  505. * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
  506. * @internal
  507. */
  508. #ifdef __cplusplus
  509. # if __has_cpp_attribute(clang::fallthrough) || \
  510. (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough"))
  511. # define U_FALLTHROUGH [[clang::fallthrough]]
  512. # else
  513. # define U_FALLTHROUGH
  514. # endif
  515. #else
  516. # define U_FALLTHROUGH
  517. #endif
  518. /** @} */
  519. /*===========================================================================*/
  520. /** @{ Character data types */
  521. /*===========================================================================*/
  522. /**
  523. * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
  524. * @stable ICU 2.0
  525. */
  526. #define U_ASCII_FAMILY 0
  527. /**
  528. * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
  529. * @stable ICU 2.0
  530. */
  531. #define U_EBCDIC_FAMILY 1
  532. /**
  533. * \def U_CHARSET_FAMILY
  534. *
  535. * <p>These definitions allow to specify the encoding of text
  536. * in the char data type as defined by the platform and the compiler.
  537. * It is enough to determine the code point values of "invariant characters",
  538. * which are the ones shared by all encodings that are in use
  539. * on a given platform.</p>
  540. *
  541. * <p>Those "invariant characters" should be all the uppercase and lowercase
  542. * latin letters, the digits, the space, and "basic punctuation".
  543. * Also, '\\n', '\\r', '\\t' should be available.</p>
  544. *
  545. * <p>The list of "invariant characters" is:<br>
  546. * \code
  547. * A-Z a-z 0-9 SPACE " % &amp; ' ( ) * + , - . / : ; < = > ? _
  548. * \endcode
  549. * <br>
  550. * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>
  551. *
  552. * <p>This matches the IBM Syntactic Character Set (CS 640).</p>
  553. *
  554. * <p>In other words, all the graphic characters in 7-bit ASCII should
  555. * be safely accessible except the following:</p>
  556. *
  557. * \code
  558. * '\' <backslash>
  559. * '[' <left bracket>
  560. * ']' <right bracket>
  561. * '{' <left brace>
  562. * '}' <right brace>
  563. * '^' <circumflex>
  564. * '~' <tilde>
  565. * '!' <exclamation mark>
  566. * '#' <number sign>
  567. * '|' <vertical line>
  568. * '$' <dollar sign>
  569. * '@' <commercial at>
  570. * '`' <grave accent>
  571. * \endcode
  572. * @stable ICU 2.0
  573. */
  574. #ifdef U_CHARSET_FAMILY
  575. /* Use the predefined value. */
  576. #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
  577. # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
  578. #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
  579. # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
  580. #else
  581. # define U_CHARSET_FAMILY U_ASCII_FAMILY
  582. #endif
  583. /**
  584. * \def U_CHARSET_IS_UTF8
  585. *
  586. * Hardcode the default charset to UTF-8.
  587. *
  588. * If this is set to 1, then
  589. * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
  590. * contain UTF-8 text, regardless of what the system API uses
  591. * - some ICU code will use fast functions like u_strFromUTF8()
  592. * rather than the more general and more heavy-weight conversion API (ucnv.h)
  593. * - ucnv_getDefaultName() always returns "UTF-8"
  594. * - ucnv_setDefaultName() is disabled and will not change the default charset
  595. * - static builds of ICU are smaller
  596. * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
  597. * configuration option (see unicode/uconfig.h)
  598. * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
  599. *
  600. * @stable ICU 4.2
  601. * @see UCONFIG_NO_CONVERSION
  602. */
  603. #ifdef U_CHARSET_IS_UTF8
  604. /* Use the predefined value. */
  605. #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
  606. # define U_CHARSET_IS_UTF8 1
  607. #else
  608. # define U_CHARSET_IS_UTF8 0
  609. #endif
  610. /** @} */
  611. /*===========================================================================*/
  612. /** @{ Information about wchar support */
  613. /*===========================================================================*/
  614. /**
  615. * \def U_HAVE_WCHAR_H
  616. * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
  617. *
  618. * @stable ICU 2.0
  619. */
  620. #ifdef U_HAVE_WCHAR_H
  621. /* Use the predefined value. */
  622. #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
  623. /*
  624. * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
  625. * The type and header existed, but the library functions did not work as expected.
  626. * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
  627. */
  628. # define U_HAVE_WCHAR_H 0
  629. #else
  630. # define U_HAVE_WCHAR_H 1
  631. #endif
  632. /**
  633. * \def U_SIZEOF_WCHAR_T
  634. * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
  635. *
  636. * @stable ICU 2.0
  637. */
  638. #ifdef U_SIZEOF_WCHAR_T
  639. /* Use the predefined value. */
  640. #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
  641. /*
  642. * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
  643. * Newer Mac OS X has size 4.
  644. */
  645. # define U_SIZEOF_WCHAR_T 1
  646. #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
  647. # define U_SIZEOF_WCHAR_T 2
  648. #elif U_PLATFORM == U_PF_AIX
  649. /*
  650. * AIX 6.1 information, section "Wide character data representation":
  651. * "... the wchar_t datatype is 32-bit in the 64-bit environment and
  652. * 16-bit in the 32-bit environment."
  653. * and
  654. * "All locales use Unicode for their wide character code values (process code),
  655. * except the IBM-eucTW codeset."
  656. */
  657. # ifdef __64BIT__
  658. # define U_SIZEOF_WCHAR_T 4
  659. # else
  660. # define U_SIZEOF_WCHAR_T 2
  661. # endif
  662. #elif U_PLATFORM == U_PF_OS390
  663. /*
  664. * z/OS V1R11 information center, section "LP64 | ILP32":
  665. * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
  666. * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
  667. */
  668. # ifdef _LP64
  669. # define U_SIZEOF_WCHAR_T 4
  670. # else
  671. # define U_SIZEOF_WCHAR_T 2
  672. # endif
  673. #elif U_PLATFORM == U_PF_OS400
  674. # if defined(__UTF32__)
  675. /*
  676. * LOCALETYPE(*LOCALEUTF) is specified.
  677. * Wide-character strings are in UTF-32,
  678. * narrow-character strings are in UTF-8.
  679. */
  680. # define U_SIZEOF_WCHAR_T 4
  681. # elif defined(__UCS2__)
  682. /*
  683. * LOCALETYPE(*LOCALEUCS2) is specified.
  684. * Wide-character strings are in UCS-2,
  685. * narrow-character strings are in EBCDIC.
  686. */
  687. # define U_SIZEOF_WCHAR_T 2
  688. #else
  689. /*
  690. * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
  691. * Wide-character strings are in 16-bit EBCDIC,
  692. * narrow-character strings are in EBCDIC.
  693. */
  694. # define U_SIZEOF_WCHAR_T 2
  695. # endif
  696. #else
  697. # define U_SIZEOF_WCHAR_T 4
  698. #endif
  699. #ifndef U_HAVE_WCSCPY
  700. #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
  701. #endif
  702. /** @} */
  703. /**
  704. * \def U_HAVE_CHAR16_T
  705. * Defines whether the char16_t type is available for UTF-16
  706. * and u"abc" UTF-16 string literals are supported.
  707. * This is a new standard type and standard string literal syntax in C++0x
  708. * but has been available in some compilers before.
  709. * @internal
  710. */
  711. #ifdef U_HAVE_CHAR16_T
  712. /* Use the predefined value. */
  713. #else
  714. /*
  715. * Notes:
  716. * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
  717. * does not support u"abc" string literals.
  718. * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
  719. * does not support u"abc" string literals.
  720. * C++11 and C11 require support for UTF-16 literals
  721. */
  722. # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
  723. # define U_HAVE_CHAR16_T 1
  724. # else
  725. # define U_HAVE_CHAR16_T 0
  726. # endif
  727. #endif
  728. /**
  729. * @{
  730. * \def U_DECLARE_UTF16
  731. * Do not use this macro because it is not defined on all platforms.
  732. * Use the UNICODE_STRING or U_STRING_DECL macros instead.
  733. * @internal
  734. */
  735. #ifdef U_DECLARE_UTF16
  736. /* Use the predefined value. */
  737. #elif U_HAVE_CHAR16_T \
  738. || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
  739. || (defined(__HP_aCC) && __HP_aCC >= 035000) \
  740. || (defined(__HP_cc) && __HP_cc >= 111106)
  741. # define U_DECLARE_UTF16(string) u ## string
  742. #elif U_SIZEOF_WCHAR_T == 2 \
  743. && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
  744. # define U_DECLARE_UTF16(string) L ## string
  745. #else
  746. /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
  747. #endif
  748. /** @} */
  749. /*===========================================================================*/
  750. /** @{ Symbol import-export control */
  751. /*===========================================================================*/
  752. #ifdef U_EXPORT
  753. /* Use the predefined value. */
  754. #elif defined(U_STATIC_IMPLEMENTATION)
  755. # define U_EXPORT
  756. #elif defined(__GNUC__)
  757. # define U_EXPORT __attribute__((visibility("default")))
  758. #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
  759. || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
  760. # define U_EXPORT __global
  761. /*#elif defined(__HP_aCC) || defined(__HP_cc)
  762. # define U_EXPORT __declspec(dllexport)*/
  763. #elif defined(_MSC_VER)
  764. # define U_EXPORT __declspec(dllexport)
  765. #else
  766. # define U_EXPORT
  767. #endif
  768. /* U_CALLCONV is releated to U_EXPORT2 */
  769. #ifdef U_EXPORT2
  770. /* Use the predefined value. */
  771. #elif defined(_MSC_VER)
  772. # define U_EXPORT2 __cdecl
  773. #else
  774. # define U_EXPORT2
  775. #endif
  776. #ifdef U_IMPORT
  777. /* Use the predefined value. */
  778. #elif defined(_MSC_VER)
  779. /* Windows needs to export/import data. */
  780. # define U_IMPORT __declspec(dllimport)
  781. #else
  782. # define U_IMPORT
  783. #endif
  784. /**
  785. * \def U_CALLCONV
  786. * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
  787. * in callback function typedefs to make sure that the calling convention
  788. * is compatible.
  789. *
  790. * This is only used for non-ICU-API functions.
  791. * When a function is a public ICU API,
  792. * you must use the U_CAPI and U_EXPORT2 qualifiers.
  793. * @stable ICU 2.0
  794. */
  795. #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
  796. # define U_CALLCONV __cdecl
  797. #else
  798. # define U_CALLCONV U_EXPORT2
  799. #endif
  800. /* @} */
  801. #endif