ICU 58.2 58.2

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

- File List
- Globals

platform.h
Go to the documentation of this file.
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
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
89 #define U_PF_UNKNOWN 0
90
91 #define U_PF_WINDOWS 1000
92
93 #define U_PF_MINGW 1800
94
99 #define U_PF_CYGWIN 1900
100 /* Reserve 2000 for U_PF_UNIX? */
102 #define U_PF_HPUX 2100
103
104 #define U_PF_SOLARIS 2600
105
106 #define U_PF_BSD 3000
107
108 #define U_PF_AIX 3100
109
110 #define U_PF_IRIX 3200
111
119 #define U_PF_DARWIN 3500
120
121 #define U_PF_IPHONE 3550
122
123 #define U_PF_QNX 3700
124
125 #define U_PF_LINUX 4000
126
132 #define U_PF_BROWSER_NATIVE_CLIENT 4020
133
134 #define U_PF_ANDROID 4050
135 /* Maximum value for Linux-based platform is 4499 */
137 #define U_PF_OS390 9000
138
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
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
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
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
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
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
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
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
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
342 #ifndef U_IOSTREAM_SOURCE
343 #define U_IOSTREAM_SOURCE 199711
344 #endif
345
351 #ifdef U_HAVE_STD_STRING
352 /* Use the predefined value. */
353 #else
354 # define U_HAVE_STD_STRING 1
355 #endif
356
357 /*===========================================================================*/
359 /*===========================================================================*/
360
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
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
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
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
458 #if defined(__GNUC__) && __GNUC__>=3
459 # define U_MALLOC_ATTR __attribute__ ((__malloc__))
460 #else
461 # define U_MALLOC_ATTR
462 #endif
463
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
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
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
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
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
554 /*===========================================================================*/
556 /*===========================================================================*/
557
562 #define U_ASCII_FAMILY 0
563
568 #define U_EBCDIC_FAMILY 1
569
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
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 #else
647 # define U_CHARSET_IS_UTF8 0
648 #endif
649
652 /*===========================================================================*/
654 /*===========================================================================*/
655
662 #ifdef U_HAVE_WCHAR_H
663 /* Use the predefined value. */
664 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
665 /*
666 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
667 * The type and header existed, but the library functions did not work as expected.
668 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
669 */
670 # define U_HAVE_WCHAR_H 0
671 #else
672 # define U_HAVE_WCHAR_H 1
673 #endif
674
681 #ifdef U_SIZEOF_WCHAR_T
682 /* Use the predefined value. */
683 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
684 /*
685 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
686 * Newer Mac OS X has size 4.
687 */
688 # define U_SIZEOF_WCHAR_T 1
689 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
690 # define U_SIZEOF_WCHAR_T 2
691 #elif U_PLATFORM == U_PF_AIX
692 /*
693 * AIX 6.1 information, section "Wide character data representation":
694 * "... the wchar_t datatype is 32-bit in the 64-bit environment and
695 * 16-bit in the 32-bit environment."
696 * and
697 * "All locales use Unicode for their wide character code values (process code),
698 * except the IBM-eucTW codeset."
699 */
700 # ifdef __64BIT__
701 # define U_SIZEOF_WCHAR_T 4
702 # else
703 # define U_SIZEOF_WCHAR_T 2
704 # endif
705 #elif U_PLATFORM == U_PF_OS390
706 /*
707 * z/OS V1R11 information center, section "LP64 | ILP32":
708 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
709 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
710 */
711 # ifdef _LP64
712 # define U_SIZEOF_WCHAR_T 4
713 # else
714 # define U_SIZEOF_WCHAR_T 2
715 # endif
716 #elif U_PLATFORM == U_PF_OS400
717 # if defined(__UTF32__)
718 /*
719 * LOCALETYPE(*LOCALEUTF) is specified.
720 * Wide-character strings are in UTF-32,
721 * narrow-character strings are in UTF-8.
722 */
723 # define U_SIZEOF_WCHAR_T 4
724 # elif defined(__UCS2__)
725 /*
726 * LOCALETYPE(*LOCALEUCS2) is specified.
727 * Wide-character strings are in UCS-2,
728 * narrow-character strings are in EBCDIC.
729 */
730 # define U_SIZEOF_WCHAR_T 2
731 #else
732 /*
733 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
734 * Wide-character strings are in 16-bit EBCDIC,
735 * narrow-character strings are in EBCDIC.
736 */
737 # define U_SIZEOF_WCHAR_T 2
738 # endif
739 #else
740 # define U_SIZEOF_WCHAR_T 4
741 #endif
742
743 #ifndef U_HAVE_WCSCPY
744 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
745 #endif
746
757 #ifdef U_HAVE_CHAR16_T
758 /* Use the predefined value. */
759 #else
760 /*
761 * Notes:
762 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
763 * does not support u"abc" string literals.
764 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
765 * does not support u"abc" string literals.
766 * C++11 and C11 require support for UTF-16 literals
767 */
768 # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
769 # define U_HAVE_CHAR16_T 1
770 # else
771 # define U_HAVE_CHAR16_T 0
772 # endif
773 #endif
774
782 #ifdef U_DECLARE_UTF16
783 /* Use the predefined value. */
784 #elif U_HAVE_CHAR16_T \
785 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
786 || (defined(__HP_aCC) && __HP_aCC >= 035000) \
787 || (defined(__HP_cc) && __HP_cc >= 111106)
788 # define U_DECLARE_UTF16(string) u ## string
789 #elif U_SIZEOF_WCHAR_T == 2 \
790 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
791 # define U_DECLARE_UTF16(string) L ## string
792 #else
793 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
794 #endif
795
798 /*===========================================================================*/
800 /*===========================================================================*/
801
802 #ifdef U_EXPORT
803 /* Use the predefined value. */
804 #elif defined(U_STATIC_IMPLEMENTATION)
805 # define U_EXPORT
806 #elif defined(__GNUC__)
807 # define U_EXPORT __attribute__((visibility("default")))
808 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
809 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
810 # define U_EXPORT __global
811 /*#elif defined(__HP_aCC) || defined(__HP_cc)
812 # define U_EXPORT __declspec(dllexport)*/
813 #elif defined(_MSC_VER)
814 # define U_EXPORT __declspec(dllexport)
815 #else
816 # define U_EXPORT
817 #endif
818
819 /* U_CALLCONV is releated to U_EXPORT2 */
820 #ifdef U_EXPORT2
821 /* Use the predefined value. */
822 #elif defined(_MSC_VER)
823 # define U_EXPORT2 __cdecl
824 #else
825 # define U_EXPORT2
826 #endif
827
828 #ifdef U_IMPORT
829 /* Use the predefined value. */
830 #elif defined(_MSC_VER)
831 /* Windows needs to export/import data. */
832 # define U_IMPORT __declspec(dllimport)
833 #else
834 # define U_IMPORT
835 #endif
836
854 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
855 # define U_CALLCONV __cdecl
856 #else
857 # define U_CALLCONV U_EXPORT2
858 #endif
859
860 /* @} */
861
862 #endif
uvernum.h
C API: definitions of ICU version numbers.
uconfig.h
User-configurable settings.