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