ICU 49.1.1  49.1.1
platform.h
Go to the documentation of this file.
1 /*
2 ******************************************************************************
3 *
4 * Copyright (C) 1997-2012, 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 
74 #define U_PF_UNKNOWN 0
75 
76 #define U_PF_WINDOWS 1000
77 
78 #define U_PF_MINGW 1800
79 
84 #define U_PF_CYGWIN 1900
85 /* Reserve 2000 for U_PF_UNIX? */
87 #define U_PF_HPUX 2100
88 
89 #define U_PF_SOLARIS 2600
90 
91 #define U_PF_BSD 3000
92 
93 #define U_PF_AIX 3100
94 
95 #define U_PF_IRIX 3200
96 
104 #define U_PF_DARWIN 3500
105 
106 #define U_PF_IPHONE 3550
107 
108 #define U_PF_QNX 3700
109 
110 #define U_PF_LINUX 4000
111 
112 #define U_PF_ANDROID 4050
113 
114 #define U_PF_CLASSIC_MACOS 8000
115 
116 #define U_PF_OS390 9000
117 
118 #define U_PF_OS400 9400
119 
120 #ifdef U_PLATFORM
121  /* Use the predefined value. */
122 #elif defined(__MINGW32__)
123 # define U_PLATFORM U_PF_MINGW
124 #elif defined(__CYGWIN__)
125 # define U_PLATFORM U_PF_CYGWIN
126 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
127 # define U_PLATFORM U_PF_WINDOWS
128 #elif defined(__ANDROID__)
129 # define U_PLATFORM U_PF_ANDROID
130  /* Android wchar_t support depends on the API level. */
131 # include <android/api-level.h>
132 #elif defined(linux) || defined(__linux__) || defined(__linux)
133 # define U_PLATFORM U_PF_LINUX
134 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
135 # define U_PLATFORM U_PF_BSD
136 #elif defined(sun) || defined(__sun)
137  /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
138 # define U_PLATFORM U_PF_SOLARIS
139 # if defined(__GNUC__)
140  /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
141  * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
142  * is included which does not include this header file.
143  */
144 # include <sys/isa_defs.h>
145 # endif
146 #elif defined(_AIX) || defined(__TOS_AIX__)
147 # define U_PLATFORM U_PF_AIX
148 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
149 # define U_PLATFORM U_PF_HPUX
150 #elif defined(sgi) || defined(__sgi)
151 # define U_PLATFORM U_PF_IRIX
152 #elif defined(__APPLE__) && defined(__MACH__)
153 # include <TargetConditionals.h>
154 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */
155 # define U_PLATFORM U_PF_IPHONE
156 # else
157 # define U_PLATFORM U_PF_DARWIN
158 # endif
159 #elif defined(macintosh)
160 # define U_PLATFORM U_PF_CLASSIC_MACOS
161 #elif defined(__QNX__) || defined(__QNXNTO__)
162 # define U_PLATFORM U_PF_QNX
163 #elif defined(__TOS_MVS__)
164 # define U_PLATFORM U_PF_OS390
165 #elif defined(__OS400__) || defined(__TOS_OS400__)
166 # define U_PLATFORM U_PF_OS400
167 #else
168 # define U_PLATFORM U_PF_UNKNOWN
169 #endif
170 
177 /* Commented out because this is already set in mh-cygwin-msvc
178 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
179 # define CYGWINMSVC
180 #endif
181 */
182 
189 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
190  /* Use the predefined value. */
191 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
192 # define U_PLATFORM_USES_ONLY_WIN32_API 1
193 #else
194  /* Cygwin implements POSIX. */
195 # define U_PLATFORM_USES_ONLY_WIN32_API 0
196 #endif
197 
204 #ifdef U_PLATFORM_HAS_WIN32_API
205  /* Use the predefined value. */
206 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
207 # define U_PLATFORM_HAS_WIN32_API 1
208 #else
209 # define U_PLATFORM_HAS_WIN32_API 0
210 #endif
211 
218 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
219  /* Use the predefined value. */
220 #elif U_PLATFORM_USES_ONLY_WIN32_API || U_PLATFORM == U_PF_CLASSIC_MACOS
221 # define U_PLATFORM_IMPLEMENTS_POSIX 0
222 #else
223 # define U_PLATFORM_IMPLEMENTS_POSIX 1
224 #endif
225 
231 #ifdef U_PLATFORM_IS_LINUX_BASED
232  /* Use the predefined value. */
233 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= U_PF_ANDROID
234 # define U_PLATFORM_IS_LINUX_BASED 1
235 #else
236 # define U_PLATFORM_IS_LINUX_BASED 0
237 #endif
238 
244 #ifdef U_PLATFORM_IS_DARWIN_BASED
245  /* Use the predefined value. */
246 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
247 # define U_PLATFORM_IS_DARWIN_BASED 1
248 #else
249 # define U_PLATFORM_IS_DARWIN_BASED 0
250 #endif
251 
259 #ifdef U_HAVE_STDINT_H
260  /* Use the predefined value. */
261 #elif U_PLATFORM_USES_ONLY_WIN32_API
262 # if defined(__BORLANDC__) || (defined(_MSC_VER) && _MSC_VER>=1600)
263  /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
264 # define U_HAVE_STDINT_H 1
265 # else
266 # define U_HAVE_STDINT_H 0
267 # endif
268 #elif U_PLATFORM == U_PF_SOLARIS
269  /* Solaris has inttypes.h but not stdint.h. */
270 # define U_HAVE_STDINT_H 0
271 #else
272 # define U_HAVE_STDINT_H 1
273 #endif
274 
281 #ifdef U_HAVE_INTTYPES_H
282  /* Use the predefined value. */
283 #elif U_PLATFORM == U_PF_SOLARIS
284  /* Solaris has inttypes.h but not stdint.h. */
285 # define U_HAVE_INTTYPES_H 1
286 #else
287  /* Most platforms have both inttypes.h and stdint.h, or neither. */
288 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
289 #endif
290 
312 #ifndef U_IOSTREAM_SOURCE
313 #define U_IOSTREAM_SOURCE 199711
314 #endif
315 
321 #ifdef U_HAVE_STD_STRING
322  /* Use the predefined value. */
323 #elif U_PLATFORM == U_PF_ANDROID
324 # define U_HAVE_STD_STRING 0
325 #else
326 # define U_HAVE_STD_STRING 1
327 #endif
328 
329 /*===========================================================================*/
331 /*===========================================================================*/
332 
338 #ifdef U_IS_BIG_ENDIAN
339  /* Use the predefined value. */
340 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
341 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
342 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
343  /* gcc */
344 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
345 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
346 # define U_IS_BIG_ENDIAN 1
347 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
348 # define U_IS_BIG_ENDIAN 0
349 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400
350  /* These platforms do not appear to predefine any endianness macros. */
351 # define U_IS_BIG_ENDIAN 1
352 #else
353 # define U_IS_BIG_ENDIAN 0
354 #endif
355 
361 #ifdef U_HAVE_PLACEMENT_NEW
362  /* Use the predefined value. */
363 #elif defined(__BORLANDC__)
364 # define U_HAVE_PLACEMENT_NEW 0
365 #else
366 # define U_HAVE_PLACEMENT_NEW 1
367 #endif
368 
375 #ifdef U_HAVE_DEBUG_LOCATION_NEW
376  /* Use the predefined value. */
377 #elif defined(_MSC_VER)
378 # define U_HAVE_DEBUG_LOCATION_NEW 1
379 #else
380 # define U_HAVE_DEBUG_LOCATION_NEW 0
381 #endif
382 
385 /*===========================================================================*/
387 /*===========================================================================*/
388 
393 #define U_ASCII_FAMILY 0
394 
399 #define U_EBCDIC_FAMILY 1
400 
443 #ifdef U_CHARSET_FAMILY
444  /* Use the predefined value. */
445 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
446 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
447 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
448 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
449 #else
450 # define U_CHARSET_FAMILY U_ASCII_FAMILY
451 #endif
452 
473 #ifdef U_CHARSET_IS_UTF8
474  /* Use the predefined value. */
475 #elif U_PLATFORM == U_PF_ANDROID || U_PLATFORM_IS_DARWIN_BASED
476 # define U_CHARSET_IS_UTF8 1
477 #else
478 # define U_CHARSET_IS_UTF8 0
479 #endif
480 
483 /*===========================================================================*/
485 /*===========================================================================*/
486 
493 #ifdef U_HAVE_WCHAR_H
494  /* Use the predefined value. */
495 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
496  /*
497  * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
498  * The type and header existed, but the library functions did not work as expected.
499  * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
500  */
501 # define U_HAVE_WCHAR_H 0
502 #else
503 # define U_HAVE_WCHAR_H 1
504 #endif
505 
512 #ifdef U_SIZEOF_WCHAR_T
513  /* Use the predefined value. */
514 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9) || U_PLATFORM == U_PF_CLASSIC_MACOS
515  /*
516  * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
517  * Newer Mac OS X has size 4.
518  */
519 # define U_SIZEOF_WCHAR_T 1
520 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
521 # define U_SIZEOF_WCHAR_T 2
522 #elif U_PLATFORM == U_PF_AIX
523  /*
524  * AIX 6.1 information, section "Wide character data representation":
525  * "... the wchar_t datatype is 32-bit in the 64-bit environment and
526  * 16-bit in the 32-bit environment."
527  * and
528  * "All locales use Unicode for their wide character code values (process code),
529  * except the IBM-eucTW codeset."
530  */
531 # ifdef __64BIT__
532 # define U_SIZEOF_WCHAR_T 4
533 # else
534 # define U_SIZEOF_WCHAR_T 2
535 # endif
536 #elif U_PLATFORM == U_PF_OS390
537  /*
538  * z/OS V1R11 information center, section "LP64 | ILP32":
539  * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
540  * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
541  */
542 # ifdef _LP64
543 # define U_SIZEOF_WCHAR_T 4
544 # else
545 # define U_SIZEOF_WCHAR_T 2
546 # endif
547 #elif U_PLATFORM == U_PF_OS400
548 # if defined(__UTF32__)
549  /*
550  * LOCALETYPE(*LOCALEUTF) is specified.
551  * Wide-character strings are in UTF-32,
552  * narrow-character strings are in UTF-8.
553  */
554 # define U_SIZEOF_WCHAR_T 4
555 # elif defined(__UCS2__)
556  /*
557  * LOCALETYPE(*LOCALEUCS2) is specified.
558  * Wide-character strings are in UCS-2,
559  * narrow-character strings are in EBCDIC.
560  */
561 # define U_SIZEOF_WCHAR_T 2
562 #else
563  /*
564  * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
565  * Wide-character strings are in 16-bit EBCDIC,
566  * narrow-character strings are in EBCDIC.
567  */
568 # define U_SIZEOF_WCHAR_T 2
569 # endif
570 #else
571 # define U_SIZEOF_WCHAR_T 4
572 #endif
573 
574 #ifndef U_HAVE_WCSCPY
575 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
576 #endif
577 
588 #ifdef U_HAVE_CHAR16_T
589  /* Use the predefined value. */
590 #else
591  /*
592  * Notes:
593  * Visual Studio 10 (_MSC_VER>=1600) defines char16_t but
594  * does not support u"abc" string literals.
595  * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
596  * does not support u"abc" string literals.
597  */
598 # define U_HAVE_CHAR16_T 0
599 #endif
600 
608 #ifdef U_DECLARE_UTF16
609  /* Use the predefined value. */
610 #elif (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
611  || (defined(__HP_aCC) && __HP_aCC >= 035000) \
612  || (defined(__HP_cc) && __HP_cc >= 111106) \
613  || U_HAVE_CHAR16_T
614 # define U_DECLARE_UTF16(string) u ## string
615 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
616 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
617 /* Sun's C compiler has issues with this notation, and it's unreliable. */
618 # define U_DECLARE_UTF16(string) U ## string
619 #elif U_SIZEOF_WCHAR_T == 2 \
620  && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
621 # define U_DECLARE_UTF16(string) L ## string
622 #else
623  /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
624 #endif
625 
628 /*===========================================================================*/
630 /*===========================================================================*/
631 
632 #ifdef U_EXPORT
633  /* Use the predefined value. */
634 #elif defined(U_STATIC_IMPLEMENTATION)
635 # define U_EXPORT
636 #elif defined(__GNUC__)
637 # define U_EXPORT __attribute__((visibility("default")))
638 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
639  || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
640 # define U_EXPORT __global
641 /*#elif defined(__HP_aCC) || defined(__HP_cc)
642 # define U_EXPORT __declspec(dllexport)*/
643 #elif defined(_MSC_VER)
644 # define U_EXPORT __declspec(dllexport)
645 #else
646 # define U_EXPORT
647 #endif
648 
649 /* U_CALLCONV is releated to U_EXPORT2 */
650 #ifdef U_EXPORT2
651  /* Use the predefined value. */
652 #elif defined(_MSC_VER)
653 # define U_EXPORT2 __cdecl
654 #else
655 # define U_EXPORT2
656 #endif
657 
658 #ifdef U_IMPORT
659  /* Use the predefined value. */
660 #elif defined(_MSC_VER)
661  /* Windows needs to export/import data. */
662 # define U_IMPORT __declspec(dllimport)
663 #else
664 # define U_IMPORT
665 #endif
666 
678 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
679 # define U_CALLCONV __cdecl
680 #else
681 # define U_CALLCONV U_EXPORT2
682 #endif
683 
684 /* @} */
685 
686 #endif