ICU 54.1 54.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
platform.h
Go to the documentation of this file.
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 1997-2014, 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
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
87 #define U_PF_UNKNOWN 0
88
89 #define U_PF_WINDOWS 1000
90
91 #define U_PF_MINGW 1800
92
97 #define U_PF_CYGWIN 1900
98 /* Reserve 2000 for U_PF_UNIX? */
100 #define U_PF_HPUX 2100
101
102 #define U_PF_SOLARIS 2600
103
104 #define U_PF_BSD 3000
105
106 #define U_PF_AIX 3100
107
108 #define U_PF_IRIX 3200
109
117 #define U_PF_DARWIN 3500
118
119 #define U_PF_IPHONE 3550
120
121 #define U_PF_QNX 3700
122
123 #define U_PF_LINUX 4000
124
125 #define U_PF_ANDROID 4050
126
127 #define U_PF_OS390 9000
128
129 #define U_PF_OS400 9400
130
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(linux) || defined(__linux__) || defined(__linux)
144 # define U_PLATFORM U_PF_LINUX
145 #elif defined(__APPLE__) && defined(__MACH__)
146 # include <TargetConditionals.h>
147 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */
148 # define U_PLATFORM U_PF_IPHONE
149 # else
150 # define U_PLATFORM U_PF_DARWIN
151 # endif
152 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
153 # define U_PLATFORM U_PF_BSD
154 #elif defined(sun) || defined(__sun)
155 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
156 # define U_PLATFORM U_PF_SOLARIS
157 # if defined(__GNUC__)
158 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
159 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
160 * is included which does not include this header file.
161 */
162 # include <sys/isa_defs.h>
163 # endif
164 #elif defined(_AIX) || defined(__TOS_AIX__)
165 # define U_PLATFORM U_PF_AIX
166 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
167 # define U_PLATFORM U_PF_HPUX
168 #elif defined(sgi) || defined(__sgi)
169 # define U_PLATFORM U_PF_IRIX
170 #elif defined(__QNX__) || defined(__QNXNTO__)
171 # define U_PLATFORM U_PF_QNX
172 #elif defined(__TOS_MVS__)
173 # define U_PLATFORM U_PF_OS390
174 #elif defined(__OS400__) || defined(__TOS_OS400__)
175 # define U_PLATFORM U_PF_OS400
176 #else
177 # define U_PLATFORM U_PF_UNKNOWN
178 #endif
179
186 /* Commented out because this is already set in mh-cygwin-msvc
187 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
188 # define CYGWINMSVC
189 #endif
190 */
191
198 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
199 /* Use the predefined value. */
200 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
201 # define U_PLATFORM_USES_ONLY_WIN32_API 1
202 #else
203 /* Cygwin implements POSIX. */
204 # define U_PLATFORM_USES_ONLY_WIN32_API 0
205 #endif
206
213 #ifdef U_PLATFORM_HAS_WIN32_API
214 /* Use the predefined value. */
215 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
216 # define U_PLATFORM_HAS_WIN32_API 1
217 #else
218 # define U_PLATFORM_HAS_WIN32_API 0
219 #endif
220
227 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
228 /* Use the predefined value. */
229 #elif U_PLATFORM_USES_ONLY_WIN32_API
230 # define U_PLATFORM_IMPLEMENTS_POSIX 0
231 #else
232 # define U_PLATFORM_IMPLEMENTS_POSIX 1
233 #endif
234
240 #ifdef U_PLATFORM_IS_LINUX_BASED
241 /* Use the predefined value. */
242 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID
243 # define U_PLATFORM_IS_LINUX_BASED 1
244 #else
245 # define U_PLATFORM_IS_LINUX_BASED 0
246 #endif
247
253 #ifdef U_PLATFORM_IS_DARWIN_BASED
254 /* Use the predefined value. */
255 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
256 # define U_PLATFORM_IS_DARWIN_BASED 1
257 #else
258 # define U_PLATFORM_IS_DARWIN_BASED 0
259 #endif
260
268 #ifdef U_HAVE_STDINT_H
269 /* Use the predefined value. */
270 #elif U_PLATFORM_USES_ONLY_WIN32_API
271 # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
272 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
273 # define U_HAVE_STDINT_H 1
274 # else
275 # define U_HAVE_STDINT_H 0
276 # endif
277 #elif U_PLATFORM == U_PF_SOLARIS
278 /* Solaris has inttypes.h but not stdint.h. */
279 # define U_HAVE_STDINT_H 0
280 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
281 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
282 # define U_HAVE_STDINT_H 0
283 #else
284 # define U_HAVE_STDINT_H 1
285 #endif
286
293 #ifdef U_HAVE_INTTYPES_H
294 /* Use the predefined value. */
295 #elif U_PLATFORM == U_PF_SOLARIS
296 /* Solaris has inttypes.h but not stdint.h. */
297 # define U_HAVE_INTTYPES_H 1
298 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
299 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
300 # define U_HAVE_INTTYPES_H 1
301 #else
302 /* Most platforms have both inttypes.h and stdint.h, or neither. */
303 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
304 #endif
305
327 #ifndef U_IOSTREAM_SOURCE
328 #define U_IOSTREAM_SOURCE 199711
329 #endif
330
336 #ifdef U_HAVE_STD_STRING
337 /* Use the predefined value. */
338 #else
339 # define U_HAVE_STD_STRING 1
340 #endif
341
342 /*===========================================================================*/
344 /*===========================================================================*/
345
356 #ifdef __GNUC__
357 # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
358 #else
359 # define U_GCC_MAJOR_MINOR 0
360 #endif
361
367 #ifdef U_IS_BIG_ENDIAN
368 /* Use the predefined value. */
369 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
370 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
371 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
372 /* gcc */
373 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
374 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
375 # define U_IS_BIG_ENDIAN 1
376 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
377 # define U_IS_BIG_ENDIAN 0
378 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
379 /* These platforms do not appear to predefine any endianness macros. */
380 # define U_IS_BIG_ENDIAN 1
381 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
382 /* HPPA do not appear to predefine any endianness macros. */
383 # define U_IS_BIG_ENDIAN 1
384 #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
385 /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
386 # define U_IS_BIG_ENDIAN 1
387 #else
388 # define U_IS_BIG_ENDIAN 0
389 #endif
390
396 #ifdef U_HAVE_PLACEMENT_NEW
397 /* Use the predefined value. */
398 #elif defined(__BORLANDC__)
399 # define U_HAVE_PLACEMENT_NEW 0
400 #else
401 # define U_HAVE_PLACEMENT_NEW 1
402 #endif
403
410 #ifdef U_HAVE_DEBUG_LOCATION_NEW
411 /* Use the predefined value. */
412 #elif defined(_MSC_VER)
413 # define U_HAVE_DEBUG_LOCATION_NEW 1
414 #else
415 # define U_HAVE_DEBUG_LOCATION_NEW 0
416 #endif
417
418 /* Compatibility with non clang compilers */
419 #ifndef __has_attribute
420 # define __has_attribute(x) 0
421 #endif
422
428 #if defined(__GNUC__) && __GNUC__>=3
429 # define U_MALLOC_ATTR __attribute__ ((__malloc__))
430 #else
431 # define U_MALLOC_ATTR
432 #endif
433
439 #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)
440 # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
441 # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
442 #else
443 # define U_ALLOC_SIZE_ATTR(X)
444 # define U_ALLOC_SIZE_ATTR2(X,Y)
445 #endif
446
449 /*===========================================================================*/
451 /*===========================================================================*/
452
457 #define U_ASCII_FAMILY 0
458
463 #define U_EBCDIC_FAMILY 1
464
507 #ifdef U_CHARSET_FAMILY
508 /* Use the predefined value. */
509 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
510 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
511 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
512 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
513 #else
514 # define U_CHARSET_FAMILY U_ASCII_FAMILY
515 #endif
516
537 #ifdef U_CHARSET_IS_UTF8
538 /* Use the predefined value. */
539 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
540 # define U_CHARSET_IS_UTF8 1
541 #else
542 # define U_CHARSET_IS_UTF8 0
543 #endif
544
547 /*===========================================================================*/
549 /*===========================================================================*/
550
557 #ifdef U_HAVE_WCHAR_H
558 /* Use the predefined value. */
559 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
560 /*
561 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
562 * The type and header existed, but the library functions did not work as expected.
563 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
564 */
565 # define U_HAVE_WCHAR_H 0
566 #else
567 # define U_HAVE_WCHAR_H 1
568 #endif
569
576 #ifdef U_SIZEOF_WCHAR_T
577 /* Use the predefined value. */
578 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
579 /*
580 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
581 * Newer Mac OS X has size 4.
582 */
583 # define U_SIZEOF_WCHAR_T 1
584 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
585 # define U_SIZEOF_WCHAR_T 2
586 #elif U_PLATFORM == U_PF_AIX
587 /*
588 * AIX 6.1 information, section "Wide character data representation":
589 * "... the wchar_t datatype is 32-bit in the 64-bit environment and
590 * 16-bit in the 32-bit environment."
591 * and
592 * "All locales use Unicode for their wide character code values (process code),
593 * except the IBM-eucTW codeset."
594 */
595 # ifdef __64BIT__
596 # define U_SIZEOF_WCHAR_T 4
597 # else
598 # define U_SIZEOF_WCHAR_T 2
599 # endif
600 #elif U_PLATFORM == U_PF_OS390
601 /*
602 * z/OS V1R11 information center, section "LP64 | ILP32":
603 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
604 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
605 */
606 # ifdef _LP64
607 # define U_SIZEOF_WCHAR_T 4
608 # else
609 # define U_SIZEOF_WCHAR_T 2
610 # endif
611 #elif U_PLATFORM == U_PF_OS400
612 # if defined(__UTF32__)
613 /*
614 * LOCALETYPE(*LOCALEUTF) is specified.
615 * Wide-character strings are in UTF-32,
616 * narrow-character strings are in UTF-8.
617 */
618 # define U_SIZEOF_WCHAR_T 4
619 # elif defined(__UCS2__)
620 /*
621 * LOCALETYPE(*LOCALEUCS2) is specified.
622 * Wide-character strings are in UCS-2,
623 * narrow-character strings are in EBCDIC.
624 */
625 # define U_SIZEOF_WCHAR_T 2
626 #else
627 /*
628 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
629 * Wide-character strings are in 16-bit EBCDIC,
630 * narrow-character strings are in EBCDIC.
631 */
632 # define U_SIZEOF_WCHAR_T 2
633 # endif
634 #else
635 # define U_SIZEOF_WCHAR_T 4
636 #endif
637
638 #ifndef U_HAVE_WCSCPY
639 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
640 #endif
641
652 #ifdef U_HAVE_CHAR16_T
653 /* Use the predefined value. */
654 #else
655 /*
656 * Notes:
657 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
658 * does not support u"abc" string literals.
659 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
660 * does not support u"abc" string literals.
661 * C++11 and C11 require support for UTF-16 literals
662 */
663 # if (defined(__cplusplus) && __cplusplus >= 201103L) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
664 # define U_HAVE_CHAR16_T 1
665 # else
666 # define U_HAVE_CHAR16_T 0
667 # endif
668 #endif
669
677 #ifdef U_DECLARE_UTF16
678 /* Use the predefined value. */
679 #elif U_HAVE_CHAR16_T \
680 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
681 || (defined(__HP_aCC) && __HP_aCC >= 035000) \
682 || (defined(__HP_cc) && __HP_cc >= 111106)
683 # define U_DECLARE_UTF16(string) u ## string
684 #elif U_SIZEOF_WCHAR_T == 2 \
685 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
686 # define U_DECLARE_UTF16(string) L ## string
687 #else
688 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
689 #endif
690
693 /*===========================================================================*/
695 /*===========================================================================*/
696
697 #ifdef U_EXPORT
698 /* Use the predefined value. */
699 #elif defined(U_STATIC_IMPLEMENTATION)
700 # define U_EXPORT
701 #elif defined(__GNUC__)
702 # define U_EXPORT __attribute__((visibility("default")))
703 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
704 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
705 # define U_EXPORT __global
706 /*#elif defined(__HP_aCC) || defined(__HP_cc)
707 # define U_EXPORT __declspec(dllexport)*/
708 #elif defined(_MSC_VER)
709 # define U_EXPORT __declspec(dllexport)
710 #else
711 # define U_EXPORT
712 #endif
713
714 /* U_CALLCONV is releated to U_EXPORT2 */
715 #ifdef U_EXPORT2
716 /* Use the predefined value. */
717 #elif defined(_MSC_VER)
718 # define U_EXPORT2 __cdecl
719 #else
720 # define U_EXPORT2
721 #endif
722
723 #ifdef U_IMPORT
724 /* Use the predefined value. */
725 #elif defined(_MSC_VER)
726 /* Windows needs to export/import data. */
727 # define U_IMPORT __declspec(dllimport)
728 #else
729 # define U_IMPORT
730 #endif
731
743 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
744 # define U_CALLCONV __cdecl
745 #else
746 # define U_CALLCONV U_EXPORT2
747 #endif
748
749 /* @} */
750
751 #endif