intl/icu/source/common/unicode/platform.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial