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