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