1/* 2****************************************************************************** 3* 4* Copyright (C) 1997-2009, International Business Machines 5* Corporation and others. All Rights Reserved. 6* 7****************************************************************************** 8* 9* FILE NAME : platform.h 10* 11* Date Name Description 12* 05/13/98 nos Creation (content moved here from ptypes.h). 13* 03/02/99 stephen Added AS400 support. 14* 03/30/99 stephen Added Linux support. 15* 04/13/99 stephen Reworked for autoconf. 16****************************************************************************** 17*/ 18 19#ifndef _PLATFORM_H 20#define _PLATFORM_H 21 22/** 23 * \file 24 * \brief Basic types for the platform 25 */ 26 27/* Define the platform we're on. */ 28#ifndef U_LINUX 29#define U_LINUX 30#endif 31 32/** 33 * \def U_HAVE_DIRENT_H 34 * Define whether dirent.h is available */ 35#ifndef U_HAVE_DIRENT_H 36#define U_HAVE_DIRENT_H 1 37#endif 38 39/** Define whether inttypes.h is available */ 40#ifndef U_HAVE_INTTYPES_H 41#define U_HAVE_INTTYPES_H 1 42#endif 43 44/** 45 * Define what support for C++ streams is available. 46 * If U_IOSTREAM_SOURCE is set to 199711, then <iostream> is available 47 * (1997711 is the date the ISO/IEC C++ FDIS was published), and then 48 * one should qualify streams using the std namespace in ICU header 49 * files. 50 * If U_IOSTREAM_SOURCE is set to 198506, then <iostream.h> is 51 * available instead (198506 is the date when Stroustrup published 52 * "An Extensible I/O Facility for C++" at the summer USENIX conference). 53 * If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and 54 * support for them will be silently suppressed in ICU. 55 * 56 */ 57 58#ifndef U_IOSTREAM_SOURCE 59#define U_IOSTREAM_SOURCE 199711 60#endif 61 62/** 63 * \def U_HAVE_STD_STRING 64 * Define whether the standard C++ (STL) <string> header is available. 65 * For platforms that do not use platform.h and do not define this constant 66 * in their platform-specific headers, std_string.h defaults 67 * U_HAVE_STD_STRING to 1. 68 * @draft ICU 4.2 69 */ 70#ifdef HAVE_ANDROID_OS 71#define U_HAVE_STD_STRING 0 72#else 73#ifndef U_HAVE_STD_STRING 74#define U_HAVE_STD_STRING 1 75#endif 76#endif 77 78/** @{ Determines whether specific types are available */ 79#ifndef U_HAVE_INT8_T 80#define U_HAVE_INT8_T 1 81#endif 82 83#ifndef U_HAVE_UINT8_T 84#define U_HAVE_UINT8_T 1 85#endif 86 87#ifndef U_HAVE_INT16_T 88#define U_HAVE_INT16_T 1 89#endif 90 91#ifndef U_HAVE_UINT16_T 92#define U_HAVE_UINT16_T 1 93#endif 94 95#ifndef U_HAVE_INT32_T 96#define U_HAVE_INT32_T 1 97#endif 98 99#ifndef U_HAVE_UINT32_T 100#define U_HAVE_UINT32_T 1 101#endif 102 103#ifndef U_HAVE_INT64_T 104#define U_HAVE_INT64_T 1 105#endif 106 107#ifndef U_HAVE_UINT64_T 108#define U_HAVE_UINT64_T 1 109#endif 110 111/** @} */ 112 113/*===========================================================================*/ 114/** @{ Generic data types */ 115/*===========================================================================*/ 116 117#include <sys/types.h> 118 119/* If your platform does not have the <inttypes.h> header, you may 120 need to edit the typedefs below. */ 121#if U_HAVE_INTTYPES_H 122 123/* autoconf 2.13 sometimes can't properly find the data types in <inttypes.h> */ 124/* os/390 needs <inttypes.h>, but it doesn't have int8_t, and it sometimes */ 125/* doesn't have uint8_t depending on the OS version. */ 126/* So we have this work around. */ 127#ifdef OS390 128/* The features header is needed to get (u)int64_t sometimes. */ 129#include <features.h> 130#if ! U_HAVE_INT8_T 131typedef signed char int8_t; 132#endif 133#if !defined(__uint8_t) 134#define __uint8_t 1 135typedef unsigned char uint8_t; 136#endif 137#endif /* OS390 */ 138 139#include <inttypes.h> 140 141#else /* U_HAVE_INTTYPES_H */ 142 143#if ! U_HAVE_INT8_T 144typedef signed char int8_t; 145#endif 146 147#if ! U_HAVE_UINT8_T 148typedef unsigned char uint8_t; 149#endif 150 151#if ! U_HAVE_INT16_T 152typedef signed short int16_t; 153#endif 154 155#if ! U_HAVE_UINT16_T 156typedef unsigned short uint16_t; 157#endif 158 159#if ! U_HAVE_INT32_T 160typedef signed int int32_t; 161#endif 162 163#if ! U_HAVE_UINT32_T 164typedef unsigned int uint32_t; 165#endif 166 167#if ! U_HAVE_INT64_T 168 typedef signed long long int64_t; 169/* else we may not have a 64-bit type */ 170#endif 171 172#if ! U_HAVE_UINT64_T 173 typedef unsigned long long uint64_t; 174/* else we may not have a 64-bit type */ 175#endif 176 177#endif 178 179/** @} */ 180 181/*===========================================================================*/ 182/** @{ Compiler and environment features */ 183/*===========================================================================*/ 184 185/* Define whether namespace is supported */ 186#ifndef U_HAVE_NAMESPACE 187#define U_HAVE_NAMESPACE 1 188#endif 189 190/* Determines the endianness of the platform 191 It's done this way in case multiple architectures are being built at once. 192 For example, Darwin supports fat binaries, which can be both PPC and x86 based. */ 193#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) 194#define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN) 195#else 196#define U_IS_BIG_ENDIAN 0 197#endif 198 199/* 1 or 0 to enable or disable threads. If undefined, default is: enable threads. */ 200#define ICU_USE_THREADS 1 201 202/* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */ 203#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) 204#define UMTX_STRONG_MEMORY_MODEL 1 205#endif 206 207#ifndef U_DEBUG 208#define U_DEBUG 0 209#endif 210 211#ifndef U_RELEASE 212#define U_RELEASE 1 213#endif 214 215/* Determine whether to disable renaming or not. This overrides the 216 setting in umachine.h which is for all platforms. */ 217#ifndef U_DISABLE_RENAMING 218#define U_DISABLE_RENAMING 0 219#endif 220 221/* Determine whether to override new and delete. */ 222#ifndef U_OVERRIDE_CXX_ALLOCATION 223#define U_OVERRIDE_CXX_ALLOCATION 1 224#endif 225/* Determine whether to override placement new and delete for STL. */ 226#ifndef U_HAVE_PLACEMENT_NEW 227#define U_HAVE_PLACEMENT_NEW 1 228#endif 229 230/* Determine whether to enable tracing. */ 231#ifndef U_ENABLE_TRACING 232#define U_ENABLE_TRACING 0 233#endif 234 235/* Do we allow ICU users to use the draft APIs by default? */ 236#ifndef U_DEFAULT_SHOW_DRAFT 237#define U_DEFAULT_SHOW_DRAFT 1 238#endif 239 240/* Define the library suffix in a C syntax. */ 241#define U_HAVE_LIB_SUFFIX 0 242#define U_LIB_SUFFIX_C_NAME 243#define U_LIB_SUFFIX_C_NAME_STRING "" 244 245/** @} */ 246 247/*===========================================================================*/ 248/** @{ Character data types */ 249/*===========================================================================*/ 250 251#if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400) 252# define U_CHARSET_FAMILY 1 253#endif 254 255/** @} */ 256 257/*===========================================================================*/ 258/** @{ Information about wchar support */ 259/*===========================================================================*/ 260// BEGIN android-note 261// We changed "ARM_FLAG" to "HAVE_ANDROID_OS" immediately below. 262// Consensus seems to be that the intent of ARM_FLAG is actually that 263// it represent whether we are compiling for Android, and if that's 264// the case then we might as well use the standard definition instead. 265// END android-note 266#if HAVE_ANDROID_OS 267#define U_HAVE_WCHAR_H 0 268#define U_SIZEOF_WCHAR_T 1 269 270#define U_HAVE_WCSCPY 0 271 272#else 273 274#ifndef U_HAVE_WCHAR_H 275#define U_HAVE_WCHAR_H 1 276#endif 277 278#ifndef U_SIZEOF_WCHAR_T 279#define U_SIZEOF_WCHAR_T 4 280#endif 281 282#ifndef U_HAVE_WCSCPY 283#define U_HAVE_WCSCPY 1 284#endif 285 286#endif 287 288/** @} */ 289 290/** 291 * @{ 292 * \def U_DECLARE_UTF16 293 * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros 294 * instead. 295 * @internal 296 */ 297#if 1 || defined(U_CHECK_UTF16_STRING) 298#if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \ 299 || (defined(__HP_aCC) && __HP_aCC >= 035000) \ 300 || (defined(__HP_cc) && __HP_cc >= 111106) 301#define U_DECLARE_UTF16(string) u ## string 302#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) 303/* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */ 304/* Sun's C compiler has issues with this notation, and it's unreliable. */ 305#define U_DECLARE_UTF16(string) U ## string 306#elif U_SIZEOF_WCHAR_T == 2 \ 307 && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__))) 308#define U_DECLARE_UTF16(string) L ## string 309#endif 310#endif 311 312/** @} */ 313 314/*===========================================================================*/ 315/** @{ Information about POSIX support */ 316/*===========================================================================*/ 317// BEGIN android-note 318// See Android comment above. 319// END android-note 320#if !HAVE_ANDROID_OS 321#define U_HAVE_NL_LANGINFO 1 322 323#ifndef U_HAVE_NL_LANGINFO_CODESET 324#define U_HAVE_NL_LANGINFO_CODESET 1 325#endif 326 327#endif 328 329#ifndef U_NL_LANGINFO_CODESET 330#define U_NL_LANGINFO_CODESET CODESET 331#endif 332 333#if !HAVE_ANDROID_OS 334#if 1 335#define U_TZSET tzset 336#endif 337#if 1 338#define U_TIMEZONE timezone 339#endif 340#if 1 341#define U_TZNAME tzname 342#endif 343#endif 344 345#define U_HAVE_MMAP 1 346#define U_HAVE_POPEN 1 347 348/** @} */ 349 350/*===========================================================================*/ 351/** @{ Symbol import-export control */ 352/*===========================================================================*/ 353 354#if 1 355#define U_EXPORT __attribute__((visibility("default"))) 356#elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \ 357 || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550) 358#define U_EXPORT __global 359/*#elif defined(__HP_aCC) || defined(__HP_cc) 360#define U_EXPORT __declspec(dllexport)*/ 361#else 362#define U_EXPORT 363#endif 364 365/* U_CALLCONV is releated to U_EXPORT2 */ 366#define U_EXPORT2 367 368/* cygwin needs to export/import data */ 369#ifdef U_CYGWIN 370#define U_IMPORT __declspec(dllimport) 371#else 372#define U_IMPORT 373#endif 374 375/* @} */ 376 377/*===========================================================================*/ 378/** @{ Code alignment and C function inlining */ 379/*===========================================================================*/ 380 381#ifndef U_INLINE 382# ifdef __cplusplus 383# define U_INLINE inline 384# else 385# define U_INLINE inline 386# endif 387#endif 388 389#ifndef U_ALIGN_CODE 390#define U_ALIGN_CODE(n) 391#endif 392 393/** @} */ 394 395/*===========================================================================*/ 396/** @{ Programs used by ICU code */ 397/*===========================================================================*/ 398 399/** 400 * \def U_MAKE 401 * What program to execute to run 'make' 402 */ 403#ifndef U_MAKE 404#define U_MAKE "make" 405#endif 406 407/** @} */ 408#endif 409