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