jpayne@69
|
1 // © 2016 and later: Unicode, Inc. and others.
|
jpayne@69
|
2 // License & terms of use: http://www.unicode.org/copyright.html
|
jpayne@69
|
3 /*
|
jpayne@69
|
4 ******************************************************************************
|
jpayne@69
|
5 *
|
jpayne@69
|
6 * Copyright (C) 1997-2016, International Business Machines
|
jpayne@69
|
7 * Corporation and others. All Rights Reserved.
|
jpayne@69
|
8 *
|
jpayne@69
|
9 ******************************************************************************
|
jpayne@69
|
10 *
|
jpayne@69
|
11 * FILE NAME : platform.h
|
jpayne@69
|
12 *
|
jpayne@69
|
13 * Date Name Description
|
jpayne@69
|
14 * 05/13/98 nos Creation (content moved here from ptypes.h).
|
jpayne@69
|
15 * 03/02/99 stephen Added AS400 support.
|
jpayne@69
|
16 * 03/30/99 stephen Added Linux support.
|
jpayne@69
|
17 * 04/13/99 stephen Reworked for autoconf.
|
jpayne@69
|
18 ******************************************************************************
|
jpayne@69
|
19 */
|
jpayne@69
|
20
|
jpayne@69
|
21 #ifndef _PLATFORM_H
|
jpayne@69
|
22 #define _PLATFORM_H
|
jpayne@69
|
23
|
jpayne@69
|
24 #include "unicode/uconfig.h"
|
jpayne@69
|
25 #include "unicode/uvernum.h"
|
jpayne@69
|
26
|
jpayne@69
|
27 /**
|
jpayne@69
|
28 * \file
|
jpayne@69
|
29 * \brief Basic types for the platform.
|
jpayne@69
|
30 *
|
jpayne@69
|
31 * This file used to be generated by autoconf/configure.
|
jpayne@69
|
32 * Starting with ICU 49, platform.h is a normal source file,
|
jpayne@69
|
33 * to simplify cross-compiling and working with non-autoconf/make build systems.
|
jpayne@69
|
34 *
|
jpayne@69
|
35 * When a value in this file does not work on a platform, then please
|
jpayne@69
|
36 * try to derive it from the U_PLATFORM value
|
jpayne@69
|
37 * (for which we might need a new value constant in rare cases)
|
jpayne@69
|
38 * and/or from other macros that are predefined by the compiler
|
jpayne@69
|
39 * or defined in standard (POSIX or platform or compiler) headers.
|
jpayne@69
|
40 *
|
jpayne@69
|
41 * As a temporary workaround, you can add an explicit \#define for some macros
|
jpayne@69
|
42 * before it is first tested, or add an equivalent -D macro definition
|
jpayne@69
|
43 * to the compiler's command line.
|
jpayne@69
|
44 *
|
jpayne@69
|
45 * Note: Some compilers provide ways to show the predefined macros.
|
jpayne@69
|
46 * For example, with gcc you can compile an empty .c file and have the compiler
|
jpayne@69
|
47 * print the predefined macros with
|
jpayne@69
|
48 * \code
|
jpayne@69
|
49 * gcc -E -dM -x c /dev/null | sort
|
jpayne@69
|
50 * \endcode
|
jpayne@69
|
51 * (You can provide an actual empty .c file rather than /dev/null.
|
jpayne@69
|
52 * <code>-x c++</code> is for C++.)
|
jpayne@69
|
53 */
|
jpayne@69
|
54
|
jpayne@69
|
55 /**
|
jpayne@69
|
56 * Define some things so that they can be documented.
|
jpayne@69
|
57 * @internal
|
jpayne@69
|
58 */
|
jpayne@69
|
59 #ifdef U_IN_DOXYGEN
|
jpayne@69
|
60 /*
|
jpayne@69
|
61 * Problem: "platform.h:335: warning: documentation for unknown define U_HAVE_STD_STRING found." means that U_HAVE_STD_STRING is not documented.
|
jpayne@69
|
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.
|
jpayne@69
|
63 */
|
jpayne@69
|
64
|
jpayne@69
|
65 /* None for now. */
|
jpayne@69
|
66 #endif
|
jpayne@69
|
67
|
jpayne@69
|
68 /**
|
jpayne@69
|
69 * \def U_PLATFORM
|
jpayne@69
|
70 * The U_PLATFORM macro defines the platform we're on.
|
jpayne@69
|
71 *
|
jpayne@69
|
72 * We used to define one different, value-less macro per platform.
|
jpayne@69
|
73 * That made it hard to know the set of relevant platforms and macros,
|
jpayne@69
|
74 * and hard to deal with variants of platforms.
|
jpayne@69
|
75 *
|
jpayne@69
|
76 * Starting with ICU 49, we define platforms as numeric macros,
|
jpayne@69
|
77 * with ranges of values for related platforms and their variants.
|
jpayne@69
|
78 * The U_PLATFORM macro is set to one of these values.
|
jpayne@69
|
79 *
|
jpayne@69
|
80 * Historical note from the Solaris Wikipedia article:
|
jpayne@69
|
81 * AT&T and Sun collaborated on a project to merge the most popular Unix variants
|
jpayne@69
|
82 * on the market at that time: BSD, System V, and Xenix.
|
jpayne@69
|
83 * This became Unix System V Release 4 (SVR4).
|
jpayne@69
|
84 *
|
jpayne@69
|
85 * @internal
|
jpayne@69
|
86 */
|
jpayne@69
|
87
|
jpayne@69
|
88 /** Unknown platform. @internal */
|
jpayne@69
|
89 #define U_PF_UNKNOWN 0
|
jpayne@69
|
90 /** Windows @internal */
|
jpayne@69
|
91 #define U_PF_WINDOWS 1000
|
jpayne@69
|
92 /** MinGW. Windows, calls to Win32 API, but using GNU gcc and binutils. @internal */
|
jpayne@69
|
93 #define U_PF_MINGW 1800
|
jpayne@69
|
94 /**
|
jpayne@69
|
95 * Cygwin. Windows, calls to cygwin1.dll for Posix functions,
|
jpayne@69
|
96 * using MSVC or GNU gcc and binutils.
|
jpayne@69
|
97 * @internal
|
jpayne@69
|
98 */
|
jpayne@69
|
99 #define U_PF_CYGWIN 1900
|
jpayne@69
|
100 /* Reserve 2000 for U_PF_UNIX? */
|
jpayne@69
|
101 /** HP-UX is based on UNIX System V. @internal */
|
jpayne@69
|
102 #define U_PF_HPUX 2100
|
jpayne@69
|
103 /** Solaris is a Unix operating system based on SVR4. @internal */
|
jpayne@69
|
104 #define U_PF_SOLARIS 2600
|
jpayne@69
|
105 /** BSD is a UNIX operating system derivative. @internal */
|
jpayne@69
|
106 #define U_PF_BSD 3000
|
jpayne@69
|
107 /** AIX is based on UNIX System V Releases and 4.3 BSD. @internal */
|
jpayne@69
|
108 #define U_PF_AIX 3100
|
jpayne@69
|
109 /** IRIX is based on UNIX System V with BSD extensions. @internal */
|
jpayne@69
|
110 #define U_PF_IRIX 3200
|
jpayne@69
|
111 /**
|
jpayne@69
|
112 * Darwin is a POSIX-compliant operating system, composed of code developed by Apple,
|
jpayne@69
|
113 * as well as code derived from NeXTSTEP, BSD, and other projects,
|
jpayne@69
|
114 * built around the Mach kernel.
|
jpayne@69
|
115 * Darwin forms the core set of components upon which Mac OS X, Apple TV, and iOS are based.
|
jpayne@69
|
116 * (Original description modified from WikiPedia.)
|
jpayne@69
|
117 * @internal
|
jpayne@69
|
118 */
|
jpayne@69
|
119 #define U_PF_DARWIN 3500
|
jpayne@69
|
120 /** iPhone OS (iOS) is a derivative of Mac OS X. @internal */
|
jpayne@69
|
121 #define U_PF_IPHONE 3550
|
jpayne@69
|
122 /** QNX is a commercial Unix-like real-time operating system related to BSD. @internal */
|
jpayne@69
|
123 #define U_PF_QNX 3700
|
jpayne@69
|
124 /** Linux is a Unix-like operating system. @internal */
|
jpayne@69
|
125 #define U_PF_LINUX 4000
|
jpayne@69
|
126 /**
|
jpayne@69
|
127 * Native Client is pretty close to Linux.
|
jpayne@69
|
128 * See https://developer.chrome.com/native-client and
|
jpayne@69
|
129 * http://www.chromium.org/nativeclient
|
jpayne@69
|
130 * @internal
|
jpayne@69
|
131 */
|
jpayne@69
|
132 #define U_PF_BROWSER_NATIVE_CLIENT 4020
|
jpayne@69
|
133 /** Android is based on Linux. @internal */
|
jpayne@69
|
134 #define U_PF_ANDROID 4050
|
jpayne@69
|
135 /** Fuchsia is a POSIX-ish platform. @internal */
|
jpayne@69
|
136 #define U_PF_FUCHSIA 4100
|
jpayne@69
|
137 /* Maximum value for Linux-based platform is 4499 */
|
jpayne@69
|
138 /**
|
jpayne@69
|
139 * Emscripten is a C++ transpiler for the Web that can target asm.js or
|
jpayne@69
|
140 * WebAssembly. It provides some POSIX-compatible wrappers and stubs and
|
jpayne@69
|
141 * some Linux-like functionality, but is not fully compatible with
|
jpayne@69
|
142 * either.
|
jpayne@69
|
143 * @internal
|
jpayne@69
|
144 */
|
jpayne@69
|
145 #define U_PF_EMSCRIPTEN 5010
|
jpayne@69
|
146 /** z/OS is the successor to OS/390 which was the successor to MVS. @internal */
|
jpayne@69
|
147 #define U_PF_OS390 9000
|
jpayne@69
|
148 /** "IBM i" is the current name of what used to be i5/OS and earlier OS/400. @internal */
|
jpayne@69
|
149 #define U_PF_OS400 9400
|
jpayne@69
|
150
|
jpayne@69
|
151 #ifdef U_PLATFORM
|
jpayne@69
|
152 /* Use the predefined value. */
|
jpayne@69
|
153 #elif defined(__MINGW32__)
|
jpayne@69
|
154 # define U_PLATFORM U_PF_MINGW
|
jpayne@69
|
155 #elif defined(__CYGWIN__)
|
jpayne@69
|
156 # define U_PLATFORM U_PF_CYGWIN
|
jpayne@69
|
157 #elif defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
|
jpayne@69
|
158 # define U_PLATFORM U_PF_WINDOWS
|
jpayne@69
|
159 #elif defined(__ANDROID__)
|
jpayne@69
|
160 # define U_PLATFORM U_PF_ANDROID
|
jpayne@69
|
161 /* Android wchar_t support depends on the API level. */
|
jpayne@69
|
162 # include <android/api-level.h>
|
jpayne@69
|
163 #elif defined(__pnacl__) || defined(__native_client__)
|
jpayne@69
|
164 # define U_PLATFORM U_PF_BROWSER_NATIVE_CLIENT
|
jpayne@69
|
165 #elif defined(__Fuchsia__)
|
jpayne@69
|
166 # define U_PLATFORM U_PF_FUCHSIA
|
jpayne@69
|
167 #elif defined(linux) || defined(__linux__) || defined(__linux)
|
jpayne@69
|
168 # define U_PLATFORM U_PF_LINUX
|
jpayne@69
|
169 #elif defined(__APPLE__) && defined(__MACH__)
|
jpayne@69
|
170 # include <TargetConditionals.h>
|
jpayne@69
|
171 # if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE /* variant of TARGET_OS_MAC */
|
jpayne@69
|
172 # define U_PLATFORM U_PF_IPHONE
|
jpayne@69
|
173 # else
|
jpayne@69
|
174 # define U_PLATFORM U_PF_DARWIN
|
jpayne@69
|
175 # endif
|
jpayne@69
|
176 #elif defined(BSD) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__MirBSD__)
|
jpayne@69
|
177 # if defined(__FreeBSD__)
|
jpayne@69
|
178 # include <sys/endian.h>
|
jpayne@69
|
179 # endif
|
jpayne@69
|
180 # define U_PLATFORM U_PF_BSD
|
jpayne@69
|
181 #elif defined(sun) || defined(__sun)
|
jpayne@69
|
182 /* Check defined(__SVR4) || defined(__svr4__) to distinguish Solaris from SunOS? */
|
jpayne@69
|
183 # define U_PLATFORM U_PF_SOLARIS
|
jpayne@69
|
184 # if defined(__GNUC__)
|
jpayne@69
|
185 /* Solaris/GCC needs this header file to get the proper endianness. Normally, this
|
jpayne@69
|
186 * header file is included with stddef.h but on Solairs/GCC, the GCC version of stddef.h
|
jpayne@69
|
187 * is included which does not include this header file.
|
jpayne@69
|
188 */
|
jpayne@69
|
189 # include <sys/isa_defs.h>
|
jpayne@69
|
190 # endif
|
jpayne@69
|
191 #elif defined(_AIX) || defined(__TOS_AIX__)
|
jpayne@69
|
192 # define U_PLATFORM U_PF_AIX
|
jpayne@69
|
193 #elif defined(_hpux) || defined(hpux) || defined(__hpux)
|
jpayne@69
|
194 # define U_PLATFORM U_PF_HPUX
|
jpayne@69
|
195 #elif defined(sgi) || defined(__sgi)
|
jpayne@69
|
196 # define U_PLATFORM U_PF_IRIX
|
jpayne@69
|
197 #elif defined(__QNX__) || defined(__QNXNTO__)
|
jpayne@69
|
198 # define U_PLATFORM U_PF_QNX
|
jpayne@69
|
199 #elif defined(__TOS_MVS__)
|
jpayne@69
|
200 # define U_PLATFORM U_PF_OS390
|
jpayne@69
|
201 #elif defined(__OS400__) || defined(__TOS_OS400__)
|
jpayne@69
|
202 # define U_PLATFORM U_PF_OS400
|
jpayne@69
|
203 #elif defined(__EMSCRIPTEN__)
|
jpayne@69
|
204 # define U_PLATFORM U_PF_EMSCRIPTEN
|
jpayne@69
|
205 #else
|
jpayne@69
|
206 # define U_PLATFORM U_PF_UNKNOWN
|
jpayne@69
|
207 #endif
|
jpayne@69
|
208
|
jpayne@69
|
209 /**
|
jpayne@69
|
210 * \def CYGWINMSVC
|
jpayne@69
|
211 * Defined if this is Windows with Cygwin, but using MSVC rather than gcc.
|
jpayne@69
|
212 * Otherwise undefined.
|
jpayne@69
|
213 * @internal
|
jpayne@69
|
214 */
|
jpayne@69
|
215 /* Commented out because this is already set in mh-cygwin-msvc
|
jpayne@69
|
216 #if U_PLATFORM == U_PF_CYGWIN && defined(_MSC_VER)
|
jpayne@69
|
217 # define CYGWINMSVC
|
jpayne@69
|
218 #endif
|
jpayne@69
|
219 */
|
jpayne@69
|
220 #ifdef U_IN_DOXYGEN
|
jpayne@69
|
221 # define CYGWINMSVC
|
jpayne@69
|
222 #endif
|
jpayne@69
|
223
|
jpayne@69
|
224 /**
|
jpayne@69
|
225 * \def U_PLATFORM_USES_ONLY_WIN32_API
|
jpayne@69
|
226 * Defines whether the platform uses only the Win32 API.
|
jpayne@69
|
227 * Set to 1 for Windows/MSVC and MinGW but not Cygwin.
|
jpayne@69
|
228 * @internal
|
jpayne@69
|
229 */
|
jpayne@69
|
230 #ifdef U_PLATFORM_USES_ONLY_WIN32_API
|
jpayne@69
|
231 /* Use the predefined value. */
|
jpayne@69
|
232 #elif (U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_MINGW) || defined(CYGWINMSVC)
|
jpayne@69
|
233 # define U_PLATFORM_USES_ONLY_WIN32_API 1
|
jpayne@69
|
234 #else
|
jpayne@69
|
235 /* Cygwin implements POSIX. */
|
jpayne@69
|
236 # define U_PLATFORM_USES_ONLY_WIN32_API 0
|
jpayne@69
|
237 #endif
|
jpayne@69
|
238
|
jpayne@69
|
239 /**
|
jpayne@69
|
240 * \def U_PLATFORM_HAS_WIN32_API
|
jpayne@69
|
241 * Defines whether the Win32 API is available on the platform.
|
jpayne@69
|
242 * Set to 1 for Windows/MSVC, MinGW and Cygwin.
|
jpayne@69
|
243 * @internal
|
jpayne@69
|
244 */
|
jpayne@69
|
245 #ifdef U_PLATFORM_HAS_WIN32_API
|
jpayne@69
|
246 /* Use the predefined value. */
|
jpayne@69
|
247 #elif U_PF_WINDOWS <= U_PLATFORM && U_PLATFORM <= U_PF_CYGWIN
|
jpayne@69
|
248 # define U_PLATFORM_HAS_WIN32_API 1
|
jpayne@69
|
249 #else
|
jpayne@69
|
250 # define U_PLATFORM_HAS_WIN32_API 0
|
jpayne@69
|
251 #endif
|
jpayne@69
|
252
|
jpayne@69
|
253 /**
|
jpayne@69
|
254 * \def U_PLATFORM_HAS_WINUWP_API
|
jpayne@69
|
255 * Defines whether target is intended for Universal Windows Platform API
|
jpayne@69
|
256 * Set to 1 for Windows10 Release Solution Configuration
|
jpayne@69
|
257 * @internal
|
jpayne@69
|
258 */
|
jpayne@69
|
259 #ifdef U_PLATFORM_HAS_WINUWP_API
|
jpayne@69
|
260 /* Use the predefined value. */
|
jpayne@69
|
261 #else
|
jpayne@69
|
262 # define U_PLATFORM_HAS_WINUWP_API 0
|
jpayne@69
|
263 #endif
|
jpayne@69
|
264
|
jpayne@69
|
265 /**
|
jpayne@69
|
266 * \def U_PLATFORM_IMPLEMENTS_POSIX
|
jpayne@69
|
267 * Defines whether the platform implements (most of) the POSIX API.
|
jpayne@69
|
268 * Set to 1 for Cygwin and most other platforms.
|
jpayne@69
|
269 * @internal
|
jpayne@69
|
270 */
|
jpayne@69
|
271 #ifdef U_PLATFORM_IMPLEMENTS_POSIX
|
jpayne@69
|
272 /* Use the predefined value. */
|
jpayne@69
|
273 #elif U_PLATFORM_USES_ONLY_WIN32_API
|
jpayne@69
|
274 # define U_PLATFORM_IMPLEMENTS_POSIX 0
|
jpayne@69
|
275 #else
|
jpayne@69
|
276 # define U_PLATFORM_IMPLEMENTS_POSIX 1
|
jpayne@69
|
277 #endif
|
jpayne@69
|
278
|
jpayne@69
|
279 /**
|
jpayne@69
|
280 * \def U_PLATFORM_IS_LINUX_BASED
|
jpayne@69
|
281 * Defines whether the platform is Linux or one of its derivatives.
|
jpayne@69
|
282 * @internal
|
jpayne@69
|
283 */
|
jpayne@69
|
284 #ifdef U_PLATFORM_IS_LINUX_BASED
|
jpayne@69
|
285 /* Use the predefined value. */
|
jpayne@69
|
286 #elif U_PF_LINUX <= U_PLATFORM && U_PLATFORM <= 4499
|
jpayne@69
|
287 # define U_PLATFORM_IS_LINUX_BASED 1
|
jpayne@69
|
288 #else
|
jpayne@69
|
289 # define U_PLATFORM_IS_LINUX_BASED 0
|
jpayne@69
|
290 #endif
|
jpayne@69
|
291
|
jpayne@69
|
292 /**
|
jpayne@69
|
293 * \def U_PLATFORM_IS_DARWIN_BASED
|
jpayne@69
|
294 * Defines whether the platform is Darwin or one of its derivatives.
|
jpayne@69
|
295 * @internal
|
jpayne@69
|
296 */
|
jpayne@69
|
297 #ifdef U_PLATFORM_IS_DARWIN_BASED
|
jpayne@69
|
298 /* Use the predefined value. */
|
jpayne@69
|
299 #elif U_PF_DARWIN <= U_PLATFORM && U_PLATFORM <= U_PF_IPHONE
|
jpayne@69
|
300 # define U_PLATFORM_IS_DARWIN_BASED 1
|
jpayne@69
|
301 #else
|
jpayne@69
|
302 # define U_PLATFORM_IS_DARWIN_BASED 0
|
jpayne@69
|
303 #endif
|
jpayne@69
|
304
|
jpayne@69
|
305 /**
|
jpayne@69
|
306 * \def U_HAVE_STDINT_H
|
jpayne@69
|
307 * Defines whether stdint.h is available. It is a C99 standard header.
|
jpayne@69
|
308 * We used to include inttypes.h which includes stdint.h but we usually do not need
|
jpayne@69
|
309 * the additional definitions from inttypes.h.
|
jpayne@69
|
310 * @internal
|
jpayne@69
|
311 */
|
jpayne@69
|
312 #ifdef U_HAVE_STDINT_H
|
jpayne@69
|
313 /* Use the predefined value. */
|
jpayne@69
|
314 #elif U_PLATFORM_USES_ONLY_WIN32_API
|
jpayne@69
|
315 # if defined(__BORLANDC__) || U_PLATFORM == U_PF_MINGW || (defined(_MSC_VER) && _MSC_VER>=1600)
|
jpayne@69
|
316 /* Windows Visual Studio 9 and below do not have stdint.h & inttypes.h, but VS 2010 adds them. */
|
jpayne@69
|
317 # define U_HAVE_STDINT_H 1
|
jpayne@69
|
318 # else
|
jpayne@69
|
319 # define U_HAVE_STDINT_H 0
|
jpayne@69
|
320 # endif
|
jpayne@69
|
321 #elif U_PLATFORM == U_PF_SOLARIS
|
jpayne@69
|
322 /* Solaris has inttypes.h but not stdint.h. */
|
jpayne@69
|
323 # define U_HAVE_STDINT_H 0
|
jpayne@69
|
324 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
|
jpayne@69
|
325 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
|
jpayne@69
|
326 # define U_HAVE_STDINT_H 0
|
jpayne@69
|
327 #else
|
jpayne@69
|
328 # define U_HAVE_STDINT_H 1
|
jpayne@69
|
329 #endif
|
jpayne@69
|
330
|
jpayne@69
|
331 /**
|
jpayne@69
|
332 * \def U_HAVE_INTTYPES_H
|
jpayne@69
|
333 * Defines whether inttypes.h is available. It is a C99 standard header.
|
jpayne@69
|
334 * We include inttypes.h where it is available but stdint.h is not.
|
jpayne@69
|
335 * @internal
|
jpayne@69
|
336 */
|
jpayne@69
|
337 #ifdef U_HAVE_INTTYPES_H
|
jpayne@69
|
338 /* Use the predefined value. */
|
jpayne@69
|
339 #elif U_PLATFORM == U_PF_SOLARIS
|
jpayne@69
|
340 /* Solaris has inttypes.h but not stdint.h. */
|
jpayne@69
|
341 # define U_HAVE_INTTYPES_H 1
|
jpayne@69
|
342 #elif U_PLATFORM == U_PF_AIX && !defined(_AIX51) && defined(_POWER)
|
jpayne@69
|
343 /* PPC AIX <= 4.3 has inttypes.h but not stdint.h. */
|
jpayne@69
|
344 # define U_HAVE_INTTYPES_H 1
|
jpayne@69
|
345 #else
|
jpayne@69
|
346 /* Most platforms have both inttypes.h and stdint.h, or neither. */
|
jpayne@69
|
347 # define U_HAVE_INTTYPES_H U_HAVE_STDINT_H
|
jpayne@69
|
348 #endif
|
jpayne@69
|
349
|
jpayne@69
|
350 /*===========================================================================*/
|
jpayne@69
|
351 /** @{ Compiler and environment features */
|
jpayne@69
|
352 /*===========================================================================*/
|
jpayne@69
|
353
|
jpayne@69
|
354 /**
|
jpayne@69
|
355 * \def U_GCC_MAJOR_MINOR
|
jpayne@69
|
356 * Indicates whether the compiler is gcc (test for != 0),
|
jpayne@69
|
357 * and if so, contains its major (times 100) and minor version numbers.
|
jpayne@69
|
358 * If the compiler is not gcc, then U_GCC_MAJOR_MINOR == 0.
|
jpayne@69
|
359 *
|
jpayne@69
|
360 * For example, for testing for whether we have gcc, and whether it's 4.6 or higher,
|
jpayne@69
|
361 * use "#if U_GCC_MAJOR_MINOR >= 406".
|
jpayne@69
|
362 * @internal
|
jpayne@69
|
363 */
|
jpayne@69
|
364 #ifdef __GNUC__
|
jpayne@69
|
365 # define U_GCC_MAJOR_MINOR (__GNUC__ * 100 + __GNUC_MINOR__)
|
jpayne@69
|
366 #else
|
jpayne@69
|
367 # define U_GCC_MAJOR_MINOR 0
|
jpayne@69
|
368 #endif
|
jpayne@69
|
369
|
jpayne@69
|
370 /**
|
jpayne@69
|
371 * \def U_IS_BIG_ENDIAN
|
jpayne@69
|
372 * Determines the endianness of the platform.
|
jpayne@69
|
373 * @internal
|
jpayne@69
|
374 */
|
jpayne@69
|
375 #ifdef U_IS_BIG_ENDIAN
|
jpayne@69
|
376 /* Use the predefined value. */
|
jpayne@69
|
377 #elif defined(BYTE_ORDER) && defined(BIG_ENDIAN)
|
jpayne@69
|
378 # define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
|
jpayne@69
|
379 #elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
|
jpayne@69
|
380 /* gcc */
|
jpayne@69
|
381 # define U_IS_BIG_ENDIAN (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
jpayne@69
|
382 #elif defined(__BIG_ENDIAN__) || defined(_BIG_ENDIAN)
|
jpayne@69
|
383 # define U_IS_BIG_ENDIAN 1
|
jpayne@69
|
384 #elif defined(__LITTLE_ENDIAN__) || defined(_LITTLE_ENDIAN)
|
jpayne@69
|
385 # define U_IS_BIG_ENDIAN 0
|
jpayne@69
|
386 #elif U_PLATFORM == U_PF_OS390 || U_PLATFORM == U_PF_OS400 || defined(__s390__) || defined(__s390x__)
|
jpayne@69
|
387 /* These platforms do not appear to predefine any endianness macros. */
|
jpayne@69
|
388 # define U_IS_BIG_ENDIAN 1
|
jpayne@69
|
389 #elif defined(_PA_RISC1_0) || defined(_PA_RISC1_1) || defined(_PA_RISC2_0)
|
jpayne@69
|
390 /* HPPA do not appear to predefine any endianness macros. */
|
jpayne@69
|
391 # define U_IS_BIG_ENDIAN 1
|
jpayne@69
|
392 #elif defined(sparc) || defined(__sparc) || defined(__sparc__)
|
jpayne@69
|
393 /* Some sparc based systems (e.g. Linux) do not predefine any endianness macros. */
|
jpayne@69
|
394 # define U_IS_BIG_ENDIAN 1
|
jpayne@69
|
395 #else
|
jpayne@69
|
396 # define U_IS_BIG_ENDIAN 0
|
jpayne@69
|
397 #endif
|
jpayne@69
|
398
|
jpayne@69
|
399 /**
|
jpayne@69
|
400 * \def U_HAVE_PLACEMENT_NEW
|
jpayne@69
|
401 * Determines whether to override placement new and delete for STL.
|
jpayne@69
|
402 * @stable ICU 2.6
|
jpayne@69
|
403 */
|
jpayne@69
|
404 #ifdef U_HAVE_PLACEMENT_NEW
|
jpayne@69
|
405 /* Use the predefined value. */
|
jpayne@69
|
406 #elif defined(__BORLANDC__)
|
jpayne@69
|
407 # define U_HAVE_PLACEMENT_NEW 0
|
jpayne@69
|
408 #else
|
jpayne@69
|
409 # define U_HAVE_PLACEMENT_NEW 1
|
jpayne@69
|
410 #endif
|
jpayne@69
|
411
|
jpayne@69
|
412 /**
|
jpayne@69
|
413 * \def U_HAVE_DEBUG_LOCATION_NEW
|
jpayne@69
|
414 * Define this to define the MFC debug version of the operator new.
|
jpayne@69
|
415 *
|
jpayne@69
|
416 * @stable ICU 3.4
|
jpayne@69
|
417 */
|
jpayne@69
|
418 #ifdef U_HAVE_DEBUG_LOCATION_NEW
|
jpayne@69
|
419 /* Use the predefined value. */
|
jpayne@69
|
420 #elif defined(_MSC_VER)
|
jpayne@69
|
421 # define U_HAVE_DEBUG_LOCATION_NEW 1
|
jpayne@69
|
422 #else
|
jpayne@69
|
423 # define U_HAVE_DEBUG_LOCATION_NEW 0
|
jpayne@69
|
424 #endif
|
jpayne@69
|
425
|
jpayne@69
|
426 /* Compatibility with compilers other than clang: http://clang.llvm.org/docs/LanguageExtensions.html */
|
jpayne@69
|
427 #ifdef __has_attribute
|
jpayne@69
|
428 # define UPRV_HAS_ATTRIBUTE(x) __has_attribute(x)
|
jpayne@69
|
429 #else
|
jpayne@69
|
430 # define UPRV_HAS_ATTRIBUTE(x) 0
|
jpayne@69
|
431 #endif
|
jpayne@69
|
432 #ifdef __has_cpp_attribute
|
jpayne@69
|
433 # define UPRV_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
|
jpayne@69
|
434 #else
|
jpayne@69
|
435 # define UPRV_HAS_CPP_ATTRIBUTE(x) 0
|
jpayne@69
|
436 #endif
|
jpayne@69
|
437 #ifdef __has_declspec_attribute
|
jpayne@69
|
438 # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) __has_declspec_attribute(x)
|
jpayne@69
|
439 #else
|
jpayne@69
|
440 # define UPRV_HAS_DECLSPEC_ATTRIBUTE(x) 0
|
jpayne@69
|
441 #endif
|
jpayne@69
|
442 #ifdef __has_builtin
|
jpayne@69
|
443 # define UPRV_HAS_BUILTIN(x) __has_builtin(x)
|
jpayne@69
|
444 #else
|
jpayne@69
|
445 # define UPRV_HAS_BUILTIN(x) 0
|
jpayne@69
|
446 #endif
|
jpayne@69
|
447 #ifdef __has_feature
|
jpayne@69
|
448 # define UPRV_HAS_FEATURE(x) __has_feature(x)
|
jpayne@69
|
449 #else
|
jpayne@69
|
450 # define UPRV_HAS_FEATURE(x) 0
|
jpayne@69
|
451 #endif
|
jpayne@69
|
452 #ifdef __has_extension
|
jpayne@69
|
453 # define UPRV_HAS_EXTENSION(x) __has_extension(x)
|
jpayne@69
|
454 #else
|
jpayne@69
|
455 # define UPRV_HAS_EXTENSION(x) 0
|
jpayne@69
|
456 #endif
|
jpayne@69
|
457 #ifdef __has_warning
|
jpayne@69
|
458 # define UPRV_HAS_WARNING(x) __has_warning(x)
|
jpayne@69
|
459 #else
|
jpayne@69
|
460 # define UPRV_HAS_WARNING(x) 0
|
jpayne@69
|
461 #endif
|
jpayne@69
|
462
|
jpayne@69
|
463 /**
|
jpayne@69
|
464 * \def U_MALLOC_ATTR
|
jpayne@69
|
465 * Attribute to mark functions as malloc-like
|
jpayne@69
|
466 * @internal
|
jpayne@69
|
467 */
|
jpayne@69
|
468 #if defined(__GNUC__) && __GNUC__>=3
|
jpayne@69
|
469 # define U_MALLOC_ATTR __attribute__ ((__malloc__))
|
jpayne@69
|
470 #else
|
jpayne@69
|
471 # define U_MALLOC_ATTR
|
jpayne@69
|
472 #endif
|
jpayne@69
|
473
|
jpayne@69
|
474 /**
|
jpayne@69
|
475 * \def U_ALLOC_SIZE_ATTR
|
jpayne@69
|
476 * Attribute to specify the size of the allocated buffer for malloc-like functions
|
jpayne@69
|
477 * @internal
|
jpayne@69
|
478 */
|
jpayne@69
|
479 #if (defined(__GNUC__) && \
|
jpayne@69
|
480 (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) || \
|
jpayne@69
|
481 UPRV_HAS_ATTRIBUTE(alloc_size)
|
jpayne@69
|
482 # define U_ALLOC_SIZE_ATTR(X) __attribute__ ((alloc_size(X)))
|
jpayne@69
|
483 # define U_ALLOC_SIZE_ATTR2(X,Y) __attribute__ ((alloc_size(X,Y)))
|
jpayne@69
|
484 #else
|
jpayne@69
|
485 # define U_ALLOC_SIZE_ATTR(X)
|
jpayne@69
|
486 # define U_ALLOC_SIZE_ATTR2(X,Y)
|
jpayne@69
|
487 #endif
|
jpayne@69
|
488
|
jpayne@69
|
489 /**
|
jpayne@69
|
490 * \def U_CPLUSPLUS_VERSION
|
jpayne@69
|
491 * 0 if no C++; 1, 11, 14, ... if C++.
|
jpayne@69
|
492 * Support for specific features cannot always be determined by the C++ version alone.
|
jpayne@69
|
493 * @internal
|
jpayne@69
|
494 */
|
jpayne@69
|
495 #ifdef U_CPLUSPLUS_VERSION
|
jpayne@69
|
496 # if U_CPLUSPLUS_VERSION != 0 && !defined(__cplusplus)
|
jpayne@69
|
497 # undef U_CPLUSPLUS_VERSION
|
jpayne@69
|
498 # define U_CPLUSPLUS_VERSION 0
|
jpayne@69
|
499 # endif
|
jpayne@69
|
500 /* Otherwise use the predefined value. */
|
jpayne@69
|
501 #elif !defined(__cplusplus)
|
jpayne@69
|
502 # define U_CPLUSPLUS_VERSION 0
|
jpayne@69
|
503 #elif __cplusplus >= 201402L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
|
jpayne@69
|
504 # define U_CPLUSPLUS_VERSION 14
|
jpayne@69
|
505 #elif __cplusplus >= 201103L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201103L)
|
jpayne@69
|
506 # define U_CPLUSPLUS_VERSION 11
|
jpayne@69
|
507 #else
|
jpayne@69
|
508 // C++98 or C++03
|
jpayne@69
|
509 # define U_CPLUSPLUS_VERSION 1
|
jpayne@69
|
510 #endif
|
jpayne@69
|
511
|
jpayne@69
|
512 #if (U_PLATFORM == U_PF_AIX || U_PLATFORM == U_PF_OS390) && defined(__cplusplus) &&(U_CPLUSPLUS_VERSION < 11)
|
jpayne@69
|
513 // add in std::nullptr_t
|
jpayne@69
|
514 namespace std {
|
jpayne@69
|
515 typedef decltype(nullptr) nullptr_t;
|
jpayne@69
|
516 };
|
jpayne@69
|
517 #endif
|
jpayne@69
|
518
|
jpayne@69
|
519 /**
|
jpayne@69
|
520 * \def U_NOEXCEPT
|
jpayne@69
|
521 * "noexcept" if supported, otherwise empty.
|
jpayne@69
|
522 * Some code, especially STL containers, uses move semantics of objects only
|
jpayne@69
|
523 * if the move constructor and the move operator are declared as not throwing exceptions.
|
jpayne@69
|
524 * @internal
|
jpayne@69
|
525 */
|
jpayne@69
|
526 #ifdef U_NOEXCEPT
|
jpayne@69
|
527 /* Use the predefined value. */
|
jpayne@69
|
528 #else
|
jpayne@69
|
529 # define U_NOEXCEPT noexcept
|
jpayne@69
|
530 #endif
|
jpayne@69
|
531
|
jpayne@69
|
532 /**
|
jpayne@69
|
533 * \def U_FALLTHROUGH
|
jpayne@69
|
534 * Annotate intentional fall-through between switch labels.
|
jpayne@69
|
535 * http://clang.llvm.org/docs/AttributeReference.html#fallthrough-clang-fallthrough
|
jpayne@69
|
536 * @internal
|
jpayne@69
|
537 */
|
jpayne@69
|
538 #ifndef __cplusplus
|
jpayne@69
|
539 // Not for C.
|
jpayne@69
|
540 #elif defined(U_FALLTHROUGH)
|
jpayne@69
|
541 // Use the predefined value.
|
jpayne@69
|
542 #elif defined(__clang__)
|
jpayne@69
|
543 // Test for compiler vs. feature separately.
|
jpayne@69
|
544 // Other compilers might choke on the feature test.
|
jpayne@69
|
545 # if UPRV_HAS_CPP_ATTRIBUTE(clang::fallthrough) || \
|
jpayne@69
|
546 (UPRV_HAS_FEATURE(cxx_attributes) && \
|
jpayne@69
|
547 UPRV_HAS_WARNING("-Wimplicit-fallthrough"))
|
jpayne@69
|
548 # define U_FALLTHROUGH [[clang::fallthrough]]
|
jpayne@69
|
549 # endif
|
jpayne@69
|
550 #elif defined(__GNUC__) && (__GNUC__ >= 7)
|
jpayne@69
|
551 # define U_FALLTHROUGH __attribute__((fallthrough))
|
jpayne@69
|
552 #endif
|
jpayne@69
|
553
|
jpayne@69
|
554 #ifndef U_FALLTHROUGH
|
jpayne@69
|
555 # define U_FALLTHROUGH
|
jpayne@69
|
556 #endif
|
jpayne@69
|
557
|
jpayne@69
|
558 /** @} */
|
jpayne@69
|
559
|
jpayne@69
|
560 /*===========================================================================*/
|
jpayne@69
|
561 /** @{ Character data types */
|
jpayne@69
|
562 /*===========================================================================*/
|
jpayne@69
|
563
|
jpayne@69
|
564 /**
|
jpayne@69
|
565 * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform.
|
jpayne@69
|
566 * @stable ICU 2.0
|
jpayne@69
|
567 */
|
jpayne@69
|
568 #define U_ASCII_FAMILY 0
|
jpayne@69
|
569
|
jpayne@69
|
570 /**
|
jpayne@69
|
571 * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform.
|
jpayne@69
|
572 * @stable ICU 2.0
|
jpayne@69
|
573 */
|
jpayne@69
|
574 #define U_EBCDIC_FAMILY 1
|
jpayne@69
|
575
|
jpayne@69
|
576 /**
|
jpayne@69
|
577 * \def U_CHARSET_FAMILY
|
jpayne@69
|
578 *
|
jpayne@69
|
579 * <p>These definitions allow to specify the encoding of text
|
jpayne@69
|
580 * in the char data type as defined by the platform and the compiler.
|
jpayne@69
|
581 * It is enough to determine the code point values of "invariant characters",
|
jpayne@69
|
582 * which are the ones shared by all encodings that are in use
|
jpayne@69
|
583 * on a given platform.</p>
|
jpayne@69
|
584 *
|
jpayne@69
|
585 * <p>Those "invariant characters" should be all the uppercase and lowercase
|
jpayne@69
|
586 * latin letters, the digits, the space, and "basic punctuation".
|
jpayne@69
|
587 * Also, '\\n', '\\r', '\\t' should be available.</p>
|
jpayne@69
|
588 *
|
jpayne@69
|
589 * <p>The list of "invariant characters" is:<br>
|
jpayne@69
|
590 * \code
|
jpayne@69
|
591 * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _
|
jpayne@69
|
592 * \endcode
|
jpayne@69
|
593 * <br>
|
jpayne@69
|
594 * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p>
|
jpayne@69
|
595 *
|
jpayne@69
|
596 * <p>This matches the IBM Syntactic Character Set (CS 640).</p>
|
jpayne@69
|
597 *
|
jpayne@69
|
598 * <p>In other words, all the graphic characters in 7-bit ASCII should
|
jpayne@69
|
599 * be safely accessible except the following:</p>
|
jpayne@69
|
600 *
|
jpayne@69
|
601 * \code
|
jpayne@69
|
602 * '\' <backslash>
|
jpayne@69
|
603 * '[' <left bracket>
|
jpayne@69
|
604 * ']' <right bracket>
|
jpayne@69
|
605 * '{' <left brace>
|
jpayne@69
|
606 * '}' <right brace>
|
jpayne@69
|
607 * '^' <circumflex>
|
jpayne@69
|
608 * '~' <tilde>
|
jpayne@69
|
609 * '!' <exclamation mark>
|
jpayne@69
|
610 * '#' <number sign>
|
jpayne@69
|
611 * '|' <vertical line>
|
jpayne@69
|
612 * '$' <dollar sign>
|
jpayne@69
|
613 * '@' <commercial at>
|
jpayne@69
|
614 * '`' <grave accent>
|
jpayne@69
|
615 * \endcode
|
jpayne@69
|
616 * @stable ICU 2.0
|
jpayne@69
|
617 */
|
jpayne@69
|
618 #ifdef U_CHARSET_FAMILY
|
jpayne@69
|
619 /* Use the predefined value. */
|
jpayne@69
|
620 #elif U_PLATFORM == U_PF_OS390 && (!defined(__CHARSET_LIB) || !__CHARSET_LIB)
|
jpayne@69
|
621 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
|
jpayne@69
|
622 #elif U_PLATFORM == U_PF_OS400 && !defined(__UTF32__)
|
jpayne@69
|
623 # define U_CHARSET_FAMILY U_EBCDIC_FAMILY
|
jpayne@69
|
624 #else
|
jpayne@69
|
625 # define U_CHARSET_FAMILY U_ASCII_FAMILY
|
jpayne@69
|
626 #endif
|
jpayne@69
|
627
|
jpayne@69
|
628 /**
|
jpayne@69
|
629 * \def U_CHARSET_IS_UTF8
|
jpayne@69
|
630 *
|
jpayne@69
|
631 * Hardcode the default charset to UTF-8.
|
jpayne@69
|
632 *
|
jpayne@69
|
633 * If this is set to 1, then
|
jpayne@69
|
634 * - ICU will assume that all non-invariant char*, StringPiece, std::string etc.
|
jpayne@69
|
635 * contain UTF-8 text, regardless of what the system API uses
|
jpayne@69
|
636 * - some ICU code will use fast functions like u_strFromUTF8()
|
jpayne@69
|
637 * rather than the more general and more heavy-weight conversion API (ucnv.h)
|
jpayne@69
|
638 * - ucnv_getDefaultName() always returns "UTF-8"
|
jpayne@69
|
639 * - ucnv_setDefaultName() is disabled and will not change the default charset
|
jpayne@69
|
640 * - static builds of ICU are smaller
|
jpayne@69
|
641 * - more functionality is available with the UCONFIG_NO_CONVERSION build-time
|
jpayne@69
|
642 * configuration option (see unicode/uconfig.h)
|
jpayne@69
|
643 * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable
|
jpayne@69
|
644 *
|
jpayne@69
|
645 * @stable ICU 4.2
|
jpayne@69
|
646 * @see UCONFIG_NO_CONVERSION
|
jpayne@69
|
647 */
|
jpayne@69
|
648 #ifdef U_CHARSET_IS_UTF8
|
jpayne@69
|
649 /* Use the predefined value. */
|
jpayne@69
|
650 #elif U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED || \
|
jpayne@69
|
651 U_PLATFORM == U_PF_EMSCRIPTEN
|
jpayne@69
|
652 # define U_CHARSET_IS_UTF8 1
|
jpayne@69
|
653 #else
|
jpayne@69
|
654 # define U_CHARSET_IS_UTF8 0
|
jpayne@69
|
655 #endif
|
jpayne@69
|
656
|
jpayne@69
|
657 /** @} */
|
jpayne@69
|
658
|
jpayne@69
|
659 /*===========================================================================*/
|
jpayne@69
|
660 /** @{ Information about wchar support */
|
jpayne@69
|
661 /*===========================================================================*/
|
jpayne@69
|
662
|
jpayne@69
|
663 /**
|
jpayne@69
|
664 * \def U_HAVE_WCHAR_H
|
jpayne@69
|
665 * Indicates whether <wchar.h> is available (1) or not (0). Set to 1 by default.
|
jpayne@69
|
666 *
|
jpayne@69
|
667 * @stable ICU 2.0
|
jpayne@69
|
668 */
|
jpayne@69
|
669 #ifdef U_HAVE_WCHAR_H
|
jpayne@69
|
670 /* Use the predefined value. */
|
jpayne@69
|
671 #elif U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9
|
jpayne@69
|
672 /*
|
jpayne@69
|
673 * Android before Gingerbread (Android 2.3, API level 9) did not support wchar_t.
|
jpayne@69
|
674 * The type and header existed, but the library functions did not work as expected.
|
jpayne@69
|
675 * The size of wchar_t was 1 but L"xyz" string literals had 32-bit units anyway.
|
jpayne@69
|
676 */
|
jpayne@69
|
677 # define U_HAVE_WCHAR_H 0
|
jpayne@69
|
678 #else
|
jpayne@69
|
679 # define U_HAVE_WCHAR_H 1
|
jpayne@69
|
680 #endif
|
jpayne@69
|
681
|
jpayne@69
|
682 /**
|
jpayne@69
|
683 * \def U_SIZEOF_WCHAR_T
|
jpayne@69
|
684 * U_SIZEOF_WCHAR_T==sizeof(wchar_t)
|
jpayne@69
|
685 *
|
jpayne@69
|
686 * @stable ICU 2.0
|
jpayne@69
|
687 */
|
jpayne@69
|
688 #ifdef U_SIZEOF_WCHAR_T
|
jpayne@69
|
689 /* Use the predefined value. */
|
jpayne@69
|
690 #elif (U_PLATFORM == U_PF_ANDROID && __ANDROID_API__ < 9)
|
jpayne@69
|
691 /*
|
jpayne@69
|
692 * Classic Mac OS and Mac OS X before 10.3 (Panther) did not support wchar_t or wstring.
|
jpayne@69
|
693 * Newer Mac OS X has size 4.
|
jpayne@69
|
694 */
|
jpayne@69
|
695 # define U_SIZEOF_WCHAR_T 1
|
jpayne@69
|
696 #elif U_PLATFORM_HAS_WIN32_API || U_PLATFORM == U_PF_CYGWIN
|
jpayne@69
|
697 # define U_SIZEOF_WCHAR_T 2
|
jpayne@69
|
698 #elif U_PLATFORM == U_PF_AIX
|
jpayne@69
|
699 /*
|
jpayne@69
|
700 * AIX 6.1 information, section "Wide character data representation":
|
jpayne@69
|
701 * "... the wchar_t datatype is 32-bit in the 64-bit environment and
|
jpayne@69
|
702 * 16-bit in the 32-bit environment."
|
jpayne@69
|
703 * and
|
jpayne@69
|
704 * "All locales use Unicode for their wide character code values (process code),
|
jpayne@69
|
705 * except the IBM-eucTW codeset."
|
jpayne@69
|
706 */
|
jpayne@69
|
707 # ifdef __64BIT__
|
jpayne@69
|
708 # define U_SIZEOF_WCHAR_T 4
|
jpayne@69
|
709 # else
|
jpayne@69
|
710 # define U_SIZEOF_WCHAR_T 2
|
jpayne@69
|
711 # endif
|
jpayne@69
|
712 #elif U_PLATFORM == U_PF_OS390
|
jpayne@69
|
713 /*
|
jpayne@69
|
714 * z/OS V1R11 information center, section "LP64 | ILP32":
|
jpayne@69
|
715 * "In 31-bit mode, the size of long and pointers is 4 bytes and the size of wchar_t is 2 bytes.
|
jpayne@69
|
716 * Under LP64, the size of long and pointer is 8 bytes and the size of wchar_t is 4 bytes."
|
jpayne@69
|
717 */
|
jpayne@69
|
718 # ifdef _LP64
|
jpayne@69
|
719 # define U_SIZEOF_WCHAR_T 4
|
jpayne@69
|
720 # else
|
jpayne@69
|
721 # define U_SIZEOF_WCHAR_T 2
|
jpayne@69
|
722 # endif
|
jpayne@69
|
723 #elif U_PLATFORM == U_PF_OS400
|
jpayne@69
|
724 # if defined(__UTF32__)
|
jpayne@69
|
725 /*
|
jpayne@69
|
726 * LOCALETYPE(*LOCALEUTF) is specified.
|
jpayne@69
|
727 * Wide-character strings are in UTF-32,
|
jpayne@69
|
728 * narrow-character strings are in UTF-8.
|
jpayne@69
|
729 */
|
jpayne@69
|
730 # define U_SIZEOF_WCHAR_T 4
|
jpayne@69
|
731 # elif defined(__UCS2__)
|
jpayne@69
|
732 /*
|
jpayne@69
|
733 * LOCALETYPE(*LOCALEUCS2) is specified.
|
jpayne@69
|
734 * Wide-character strings are in UCS-2,
|
jpayne@69
|
735 * narrow-character strings are in EBCDIC.
|
jpayne@69
|
736 */
|
jpayne@69
|
737 # define U_SIZEOF_WCHAR_T 2
|
jpayne@69
|
738 # else
|
jpayne@69
|
739 /*
|
jpayne@69
|
740 * LOCALETYPE(*CLD) or LOCALETYPE(*LOCALE) is specified.
|
jpayne@69
|
741 * Wide-character strings are in 16-bit EBCDIC,
|
jpayne@69
|
742 * narrow-character strings are in EBCDIC.
|
jpayne@69
|
743 */
|
jpayne@69
|
744 # define U_SIZEOF_WCHAR_T 2
|
jpayne@69
|
745 # endif
|
jpayne@69
|
746 #else
|
jpayne@69
|
747 # define U_SIZEOF_WCHAR_T 4
|
jpayne@69
|
748 #endif
|
jpayne@69
|
749
|
jpayne@69
|
750 #ifndef U_HAVE_WCSCPY
|
jpayne@69
|
751 #define U_HAVE_WCSCPY U_HAVE_WCHAR_H
|
jpayne@69
|
752 #endif
|
jpayne@69
|
753
|
jpayne@69
|
754 /** @} */
|
jpayne@69
|
755
|
jpayne@69
|
756 /**
|
jpayne@69
|
757 * \def U_HAVE_CHAR16_T
|
jpayne@69
|
758 * Defines whether the char16_t type is available for UTF-16
|
jpayne@69
|
759 * and u"abc" UTF-16 string literals are supported.
|
jpayne@69
|
760 * This is a new standard type and standard string literal syntax in C++0x
|
jpayne@69
|
761 * but has been available in some compilers before.
|
jpayne@69
|
762 * @internal
|
jpayne@69
|
763 */
|
jpayne@69
|
764 #ifdef U_HAVE_CHAR16_T
|
jpayne@69
|
765 /* Use the predefined value. */
|
jpayne@69
|
766 #else
|
jpayne@69
|
767 /*
|
jpayne@69
|
768 * Notes:
|
jpayne@69
|
769 * Visual Studio 2010 (_MSC_VER==1600) defines char16_t as a typedef
|
jpayne@69
|
770 * and does not support u"abc" string literals.
|
jpayne@69
|
771 * Visual Studio 2015 (_MSC_VER>=1900) and above adds support for
|
jpayne@69
|
772 * both char16_t and u"abc" string literals.
|
jpayne@69
|
773 * gcc 4.4 defines the __CHAR16_TYPE__ macro to a usable type but
|
jpayne@69
|
774 * does not support u"abc" string literals.
|
jpayne@69
|
775 * C++11 and C11 require support for UTF-16 literals
|
jpayne@69
|
776 * TODO: Fix for plain C. Doesn't work on Mac.
|
jpayne@69
|
777 */
|
jpayne@69
|
778 # if U_CPLUSPLUS_VERSION >= 11 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
jpayne@69
|
779 # define U_HAVE_CHAR16_T 1
|
jpayne@69
|
780 # else
|
jpayne@69
|
781 # define U_HAVE_CHAR16_T 0
|
jpayne@69
|
782 # endif
|
jpayne@69
|
783 #endif
|
jpayne@69
|
784
|
jpayne@69
|
785 /**
|
jpayne@69
|
786 * @{
|
jpayne@69
|
787 * \def U_DECLARE_UTF16
|
jpayne@69
|
788 * Do not use this macro because it is not defined on all platforms.
|
jpayne@69
|
789 * Use the UNICODE_STRING or U_STRING_DECL macros instead.
|
jpayne@69
|
790 * @internal
|
jpayne@69
|
791 */
|
jpayne@69
|
792 #ifdef U_DECLARE_UTF16
|
jpayne@69
|
793 /* Use the predefined value. */
|
jpayne@69
|
794 #elif U_HAVE_CHAR16_T \
|
jpayne@69
|
795 || (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
|
jpayne@69
|
796 || (defined(__HP_aCC) && __HP_aCC >= 035000) \
|
jpayne@69
|
797 || (defined(__HP_cc) && __HP_cc >= 111106) \
|
jpayne@69
|
798 || (defined(U_IN_DOXYGEN))
|
jpayne@69
|
799 # define U_DECLARE_UTF16(string) u ## string
|
jpayne@69
|
800 #elif U_SIZEOF_WCHAR_T == 2 \
|
jpayne@69
|
801 && (U_CHARSET_FAMILY == 0 || (U_PF_OS390 <= U_PLATFORM && U_PLATFORM <= U_PF_OS400 && defined(__UCS2__)))
|
jpayne@69
|
802 # define U_DECLARE_UTF16(string) L ## string
|
jpayne@69
|
803 #else
|
jpayne@69
|
804 /* Leave U_DECLARE_UTF16 undefined. See unistr.h. */
|
jpayne@69
|
805 #endif
|
jpayne@69
|
806
|
jpayne@69
|
807 /** @} */
|
jpayne@69
|
808
|
jpayne@69
|
809 /*===========================================================================*/
|
jpayne@69
|
810 /** @{ Symbol import-export control */
|
jpayne@69
|
811 /*===========================================================================*/
|
jpayne@69
|
812
|
jpayne@69
|
813 #ifdef U_EXPORT
|
jpayne@69
|
814 /* Use the predefined value. */
|
jpayne@69
|
815 #elif defined(U_STATIC_IMPLEMENTATION)
|
jpayne@69
|
816 # define U_EXPORT
|
jpayne@69
|
817 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \
|
jpayne@69
|
818 UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
|
jpayne@69
|
819 # define U_EXPORT __declspec(dllexport)
|
jpayne@69
|
820 #elif defined(__GNUC__)
|
jpayne@69
|
821 # define U_EXPORT __attribute__((visibility("default")))
|
jpayne@69
|
822 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
|
jpayne@69
|
823 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
|
jpayne@69
|
824 # define U_EXPORT __global
|
jpayne@69
|
825 /*#elif defined(__HP_aCC) || defined(__HP_cc)
|
jpayne@69
|
826 # define U_EXPORT __declspec(dllexport)*/
|
jpayne@69
|
827 #else
|
jpayne@69
|
828 # define U_EXPORT
|
jpayne@69
|
829 #endif
|
jpayne@69
|
830
|
jpayne@69
|
831 /* U_CALLCONV is related to U_EXPORT2 */
|
jpayne@69
|
832 #ifdef U_EXPORT2
|
jpayne@69
|
833 /* Use the predefined value. */
|
jpayne@69
|
834 #elif defined(_MSC_VER)
|
jpayne@69
|
835 # define U_EXPORT2 __cdecl
|
jpayne@69
|
836 #else
|
jpayne@69
|
837 # define U_EXPORT2
|
jpayne@69
|
838 #endif
|
jpayne@69
|
839
|
jpayne@69
|
840 #ifdef U_IMPORT
|
jpayne@69
|
841 /* Use the predefined value. */
|
jpayne@69
|
842 #elif defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(dllexport) && \
|
jpayne@69
|
843 UPRV_HAS_DECLSPEC_ATTRIBUTE(dllimport))
|
jpayne@69
|
844 /* Windows needs to export/import data. */
|
jpayne@69
|
845 # define U_IMPORT __declspec(dllimport)
|
jpayne@69
|
846 #else
|
jpayne@69
|
847 # define U_IMPORT
|
jpayne@69
|
848 #endif
|
jpayne@69
|
849
|
jpayne@69
|
850 /**
|
jpayne@69
|
851 * \def U_CALLCONV
|
jpayne@69
|
852 * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary
|
jpayne@69
|
853 * in callback function typedefs to make sure that the calling convention
|
jpayne@69
|
854 * is compatible.
|
jpayne@69
|
855 *
|
jpayne@69
|
856 * This is only used for non-ICU-API functions.
|
jpayne@69
|
857 * When a function is a public ICU API,
|
jpayne@69
|
858 * you must use the U_CAPI and U_EXPORT2 qualifiers.
|
jpayne@69
|
859 *
|
jpayne@69
|
860 * Please note, you need to use U_CALLCONV after the *.
|
jpayne@69
|
861 *
|
jpayne@69
|
862 * NO : "static const char U_CALLCONV *func( . . . )"
|
jpayne@69
|
863 * YES: "static const char* U_CALLCONV func( . . . )"
|
jpayne@69
|
864 *
|
jpayne@69
|
865 * @stable ICU 2.0
|
jpayne@69
|
866 */
|
jpayne@69
|
867 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
|
jpayne@69
|
868 # define U_CALLCONV __cdecl
|
jpayne@69
|
869 #else
|
jpayne@69
|
870 # define U_CALLCONV U_EXPORT2
|
jpayne@69
|
871 #endif
|
jpayne@69
|
872
|
jpayne@69
|
873 /**
|
jpayne@69
|
874 * \def U_CALLCONV_FPTR
|
jpayne@69
|
875 * Similar to U_CALLCONV, but only used on function pointers.
|
jpayne@69
|
876 * @internal
|
jpayne@69
|
877 */
|
jpayne@69
|
878 #if U_PLATFORM == U_PF_OS390 && defined(__cplusplus)
|
jpayne@69
|
879 # define U_CALLCONV_FPTR U_CALLCONV
|
jpayne@69
|
880 #else
|
jpayne@69
|
881 # define U_CALLCONV_FPTR
|
jpayne@69
|
882 #endif
|
jpayne@69
|
883 /* @} */
|
jpayne@69
|
884
|
jpayne@69
|
885 #endif // _PLATFORM_H
|