ICU 60.2 60.2

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

- File List
- Globals

platform.h
Go to the documentation of this file.
1 // © 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
136 #define U_PF_FUCHSIA 4100
137 /* Maximum value for Linux-based platform is 4499 */
139 #define U_PF_OS390 9000
140
141 #define U_PF_OS400 9400
142
143 #ifdef U_PLATFORM
144 /* Use the predefined value. */
145 #elif defined(__MINGW32__)
146 # define U_PLATFORM U_PF_MINGW
147 #elif defined(__CYGWIN__)
148 # define U_PLATFORM U_PF_CYGWIN
149 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
150 # define U_PLATFORM U_PF_WINDOWS
151 #elif defined(__ANDROID__)
152 # define U_PLATFORM U_PF_ANDROID
153 /* Android wchar_t support depends on the API level. */
154 # include <android/api-level.h>
155 #elif defined(__pnacl__) || defined(__native_client__)
156 # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT
157 #elif defined(__Fuchsia__)
158 # define U_PLATFORM U_PF_FUCHSIA
159 #elif defined(linux) || defined(__linux__) || defined(__linux)
160 # define U_PLATFORM U_PF_LINUX
161 #elif defined(__APPLE__) && defined(__MACH__)
162 # include <TargetConditionals.h>
163 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */
164 # define U_PLATFORM U_PF_IPHONE
165 # else
166 # define U_PLATFORM U_PF_DARWIN
167 # endif
168 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
169 # if defined(__FreeBSD__)
170 # include <sys/endian.h>
171 # endif
172 # define U_PLATFORM U_PF_BSD
173 #elif defined(sun) || defined(__sun)
174 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
175 # define U_PLATFORM U_PF_SOLARIS
176 # if defined(__GNUC__)
177 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
178 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
179 * is included which does not include this header file.
180 */
181 # include <sys/isa_defs.h>
182 # endif
183 #elif defined(_AIX) || defined(__TOS_AIX__)
184 # define U_PLATFORM U_PF_AIX
185 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
186 # define U_PLATFORM U_PF_HPUX
187 #elif defined(sgi) || defined(__sgi)
188 # define U_PLATFORM U_PF_IRIX
189 #elif defined(__QNX__) || defined(__QNXNTO__)
190 # define U_PLATFORM U_PF_QNX
191 #elif defined(__TOS_MVS__)
192 # define U_PLATFORM U_PF_OS390
193 #elif defined(__OS400__) || defined(__TOS_OS400__)
194 # define U_PLATFORM U_PF_OS400
195 #else
196 # define U_PLATFORM U_PF_UNKNOWN
197 #endif
198
209 #ifndef UPRV_INCOMPLETE_CPP11_SUPPORT
210 # define UPRV_INCOMPLETE_CPP11_SUPPORT (U_PLATFORM == U_PF_AIX || U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_SOLARIS )
211 #endif
212
219 /* Commented out because this is already set in mh-cygwin-msvc
220 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
221 # define CYGWINMSVC
222 #endif
223 */
224
231 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
232 /* Use the predefined value. */
233 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
234 # define U_PLATFORM_USES_ONLY_WIN32_API 1
235 #else
236 /* Cygwin implements POSIX. */
237 # define U_PLATFORM_USES_ONLY_WIN32_API 0
238 #endif
239
246 #ifdef U_PLATFORM_HAS_WIN32_API
247 /* Use the predefined value. */
248 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
249 # define U_PLATFORM_HAS_WIN32_API 1
250 #else
251 # define U_PLATFORM_HAS_WIN32_API 0
252 #endif
253
260 #ifdef U_PLATFORM_HAS_WINUWP_API
261 /* Use the predefined value. */
262 #else
263 # define U_PLATFORM_HAS_WINUWP_API 0
264 #endif
265
272 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
273 /* Use the predefined value. */
274 #elif U_PLATFORM_USES_ONLY_WIN32_API
275 # define U_PLATFORM_IMPLEMENTS_POSIX 0
276 #else
277 # define U_PLATFORM_IMPLEMENTS_POSIX 1
278 #endif
279
285 #ifdef U_PLATFORM_IS_LINUX_BASED
286 /* Use the predefined value. */
287 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
288 # define U_PLATFORM_IS_LINUX_BASED 1
289 #else
290 # define U_PLATFORM_IS_LINUX_BASED 0
291 #endif
292
298 #ifdef U_PLATFORM_IS_DARWIN_BASED
299 /* Use the predefined value. */
300 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
301 # define U_PLATFORM_IS_DARWIN_BASED 1
302 #else
303 # define U_PLATFORM_IS_DARWIN_BASED 0
304 #endif
305
313 #ifdef U_HAVE_STDINT_H
314 /* Use the predefined value. */
315 #elif U_PLATFORM_USES_ONLY_WIN32_API
316 # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
317 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
318 # define U_HAVE_STDINT_H 1
319 # else
320 # define U_HAVE_STDINT_H 0
321 # endif
322 #elif U_PLATFORM == U_PF_SOLARIS
323 /* Solaris has inttypes.h but not stdint.h. */
324 # define U_HAVE_STDINT_H 0
325 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
326 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
327 # define U_HAVE_STDINT_H 0
328 #else
329 # define U_HAVE_STDINT_H 1
330 #endif
331
338 #ifdef U_HAVE_INTTYPES_H
339 /* Use the predefined value. */
340 #elif U_PLATFORM == U_PF_SOLARIS
341 /* Solaris has inttypes.h but not stdint.h. */
342 # define U_HAVE_INTTYPES_H 1
343 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
344 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
345 # define U_HAVE_INTTYPES_H 1
346 #else
347 /* Most platforms have both inttypes.h and stdint.h, or neither. */
348 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
349 #endif
350
351 /*===========================================================================*/
353 /*===========================================================================*/
354
365 #ifdef __GNUC__
366 # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
367 #else
368 # define U_GCC_MAJOR_MINOR 0
369 #endif
370
376 #ifdef U_IS_BIG_ENDIAN
377 /* Use the predefined value. */
378 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
379 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
380 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
381 /* gcc */
382 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
383 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
384 # define U_IS_BIG_ENDIAN 1
385 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
386 # define U_IS_BIG_ENDIAN 0
387 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
388 /* These platforms do not appear to predefine any endianness macros. */
389 # define U_IS_BIG_ENDIAN 1
390 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
391 /* HPPA do not appear to predefine any endianness macros. */
392 # define U_IS_BIG_ENDIAN 1
393 #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
394 /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
395 # define U_IS_BIG_ENDIAN 1
396 #else
397 # define U_IS_BIG_ENDIAN 0
398 #endif
399
405 #ifdef U_HAVE_PLACEMENT_NEW
406 /* Use the predefined value. */
407 #elif defined(__BORLANDC__)
408 # define U_HAVE_PLACEMENT_NEW 0
409 #else
410 # define U_HAVE_PLACEMENT_NEW 1
411 #endif
412
419 #ifdef U_HAVE_DEBUG_LOCATION_NEW
420 /* Use the predefined value. */
421 #elif defined(_MSC_VER)
422 # define U_HAVE_DEBUG_LOCATION_NEW 1
423 #else
424 # define U_HAVE_DEBUG_LOCATION_NEW 0
425 #endif
426
427 /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */
428 #ifndef __has_attribute
429 # define __has_attribute(x) 0
430 #endif
431 #ifndef __has_cpp_attribute
432 # define __has_cpp_attribute(x) 0
433 #endif
434 #ifndef __has_builtin
435 # define __has_builtin(x) 0
436 #endif
437 #ifndef __has_feature
438 # define __has_feature(x) 0
439 #endif
440 #ifndef __has_extension
441 # define __has_extension(x) 0
442 #endif
443 #ifndef __has_warning
444 # define __has_warning(x) 0
445 #endif
446
452 #if defined(__GNUC__) && __GNUC__>=3
453 # define U_MALLOC_ATTR __attribute__ ((__malloc__))
454 #else
455 # define U_MALLOC_ATTR
456 #endif
457
463 #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || __has_attribute(alloc_size)
464 # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
465 # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
466 #else
467 # define U_ALLOC_SIZE_ATTR(X)
468 # define U_ALLOC_SIZE_ATTR2(X,Y)
469 #endif
470
477 #ifdef U_CPLUSPLUS_VERSION
478 # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
479 # undef U_CPLUSPLUS_VERSION
480 # define U_CPLUSPLUS_VERSION 0
481 # endif
482 /* Otherwise use the predefined value. */
483 #elif !defined(__cplusplus)
484 # define U_CPLUSPLUS_VERSION 0
485 #elif __cplusplus >= 201402L
486 # define U_CPLUSPLUS_VERSION 14
487 #elif __cplusplus >= 201103L
488 # define U_CPLUSPLUS_VERSION 11
489 #else
490 // C++98 or C++03
491 # define U_CPLUSPLUS_VERSION 1
492 #endif
493
494 #if (U_PLATFORM == U_PF_AIX || U_PLATFORM == U_PF_OS390) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
495 // add in std::nullptr_t
496 namespace std {
497 typedef decltype(nullptr) nullptr_t;
498 };
499 #endif
500
508 #ifdef U_NOEXCEPT
509 /* Use the predefined value. */
510 #elif defined(_HAS_EXCEPTIONS) && !_HAS_EXCEPTIONS /* Visual Studio */
511 # define U_NOEXCEPT
512 #elif U_CPLUSPLUS_VERSION >= 11 || __has_feature(cxx_noexcept) || __has_extension(cxx_noexcept) \
513 || (defined(_MSC_VER) && _MSC_VER >= 1900) /* Visual Studio 2015 */
514 # define U_NOEXCEPT noexcept
515 #else
516 # define U_NOEXCEPT
517 #endif
518
525 #ifndef __cplusplus
526 // Not for C.
527 #elif defined(U_FALLTHROUGH)
528 // Use the predefined value.
529 #elif defined(__clang__)
530 // Test for compiler vs. feature separately.
531 // Other compilers might choke on the feature test.
532 # if __has_cpp_attribute(clang::fallthrough) || \
533 (__has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough"))
534 # define U_FALLTHROUGH [[clang::fallthrough]]
535 # endif
536 #endif
537
538 #ifndef U_FALLTHROUGH
539 # define U_FALLTHROUGH
540 #endif
541
544 /*===========================================================================*/
546 /*===========================================================================*/
547
552 #define U_ASCII_FAMILY 0
553
558 #define U_EBCDIC_FAMILY 1
559
602 #ifdef U_CHARSET_FAMILY
603 /* Use the predefined value. */
604 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
605 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
606 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
607 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
608 #else
609 # define U_CHARSET_FAMILY U_ASCII_FAMILY
610 #endif
611
632 #ifdef U_CHARSET_IS_UTF8
633 /* Use the predefined value. */
634 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
635 # define U_CHARSET_IS_UTF8 1
636 #else
637 # define U_CHARSET_IS_UTF8 0
638 #endif
639
642 /*===========================================================================*/
644 /*===========================================================================*/
645
652 #ifdef U_HAVE_WCHAR_H
653 /* Use the predefined value. */
654 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
655 /*
656 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
657 * The type and header existed, but the library functions did not work as expected.
658 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
659 */
660 # define U_HAVE_WCHAR_H 0
661 #else
662 # define U_HAVE_WCHAR_H 1
663 #endif
664
671 #ifdef U_SIZEOF_WCHAR_T
672 /* Use the predefined value. */
673 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
674 /*
675 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
676 * Newer Mac OS X has size 4.
677 */
678 # define U_SIZEOF_WCHAR_T 1
679 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
680 # define U_SIZEOF_WCHAR_T 2
681 #elif U_PLATFORM == U_PF_AIX
682 /*
683 * AIX 6.1 information, section "Wide character data representation":
684 * "... the wchar_t datatype is 32-bit in the 64-bit environment and
685 * 16-bit in the 32-bit environment."
686 * and
687 * "All locales use Unicode for their wide character code values (process code),
688 * except the IBM-eucTW codeset."
689 */
690 # ifdef __64BIT__
691 # define U_SIZEOF_WCHAR_T 4
692 # else
693 # define U_SIZEOF_WCHAR_T 2
694 # endif
695 #elif U_PLATFORM == U_PF_OS390
696 /*
697 * z/OS V1R11 information center, section "LP64 | ILP32":
698 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
699 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
700 */
701 # ifdef _LP64
702 # define U_SIZEOF_WCHAR_T 4
703 # else
704 # define U_SIZEOF_WCHAR_T 2
705 # endif
706 #elif U_PLATFORM == U_PF_OS400
707 # if defined(__UTF32__)
708 /*
709 * LOCALETYPE(*LOCALEUTF) is specified.
710 * Wide-character strings are in UTF-32,
711 * narrow-character strings are in UTF-8.
712 */
713 # define U_SIZEOF_WCHAR_T 4
714 # elif defined(__UCS2__)
715 /*
716 * LOCALETYPE(*LOCALEUCS2) is specified.
717 * Wide-character strings are in UCS-2,
718 * narrow-character strings are in EBCDIC.
719 */
720 # define U_SIZEOF_WCHAR_T 2
721 #else
722 /*
723 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
724 * Wide-character strings are in 16-bit EBCDIC,
725 * narrow-character strings are in EBCDIC.
726 */
727 # define U_SIZEOF_WCHAR_T 2
728 # endif
729 #else
730 # define U_SIZEOF_WCHAR_T 4
731 #endif
732
733 #ifndef U_HAVE_WCSCPY
734 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
735 #endif
736
747 #ifdef U_HAVE_CHAR16_T
748 /* Use the predefined value. */
749 #else
750 /*
751 * Notes:
752 * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
753 * does not support u"abc" string literals.
754 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
755 * does not support u"abc" string literals.
756 * C++11 and C11 require support for UTF-16 literals
757 * TODO: Fix for plain C. Doesn't work on Mac.
758 */
759 # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
760 # define U_HAVE_CHAR16_T 1
761 # else
762 # define U_HAVE_CHAR16_T 0
763 # endif
764 #endif
765
773 #ifdef U_DECLARE_UTF16
774 /* Use the predefined value. */
775 #elif U_HAVE_CHAR16_T \
776 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
777 || (defined(__HP_aCC) && __HP_aCC >= 035000) \
778 || (defined(__HP_cc) && __HP_cc >= 111106)
779 # define U_DECLARE_UTF16(string) u ## string
780 #elif U_SIZEOF_WCHAR_T == 2 \
781 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
782 # define U_DECLARE_UTF16(string) L ## string
783 #else
784 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
785 #endif
786
789 /*===========================================================================*/
791 /*===========================================================================*/
792
793 #ifdef U_EXPORT
794 /* Use the predefined value. */
795 #elif defined(U_STATIC_IMPLEMENTATION)
796 # define U_EXPORT
797 #elif defined(__GNUC__)
798 # define U_EXPORT __attribute__((visibility("default")))
799 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
800 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
801 # define U_EXPORT __global
802 /*#elif defined(__HP_aCC) || defined(__HP_cc)
803 # define U_EXPORT __declspec(dllexport)*/
804 #elif defined(_MSC_VER)
805 # define U_EXPORT __declspec(dllexport)
806 #else
807 # define U_EXPORT
808 #endif
809
810 /* U_CALLCONV is releated to U_EXPORT2 */
811 #ifdef U_EXPORT2
812 /* Use the predefined value. */
813 #elif defined(_MSC_VER)
814 # define U_EXPORT2 __cdecl
815 #else
816 # define U_EXPORT2
817 #endif
818
819 #ifdef U_IMPORT
820 /* Use the predefined value. */
821 #elif defined(_MSC_VER)
822 /* Windows needs to export/import data. */
823 # define U_IMPORT __declspec(dllimport)
824 #else
825 # define U_IMPORT
826 #endif
827
845 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
846 # define U_CALLCONV __cdecl
847 #else
848 # define U_CALLCONV U_EXPORT2
849 #endif
850
856 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
857 # define U_CALLCONV_FPTR U_CALLCONV
858 #else
859 # define U_CALLCONV_FPTR
860 #endif
861 /* @} */
862
863 #endif
uvernum.h
C API: definitions of ICU version numbers.
uconfig.h
User-configurable settings.