• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 ******************************************************************************
3 *
4 *   Copyright (C) 1997-2010, International Business Machines
5 *   Corporation and others.  All Rights Reserved.
6 *
7 ******************************************************************************
8 *
9 * Note: autoconf creates platform.h from platform.h.in at configure time.
10 *
11 ******************************************************************************
12 *
13 *  FILE NAME : platform.h
14 *
15 *   Date        Name        Description
16 *   05/13/98    nos         Creation (content moved here from ptypes.h).
17 *   03/02/99    stephen     Added AS400 support.
18 *   03/30/99    stephen     Added Linux support.
19 *   04/13/99    stephen     Reworked for autoconf.
20 ******************************************************************************
21 */
22 
23 #ifndef _PLATFORM_H
24 #define _PLATFORM_H
25 
26 /**
27  * \file
28  * \brief Basic types for the platform
29  */
30 
31 /* This file should be included before uvernum.h. */
32 #if defined(UVERNUM_H)
33 # error Do not include unicode/uvernum.h before #including unicode/platform.h.  Instead of unicode/uvernum.h, #include unicode/uversion.h
34 #endif
35 
36 /**
37  * Determine wheter to enable auto cleanup of libraries.
38  * @internal
39  */
40 #ifndef UCLN_NO_AUTO_CLEANUP
41 #define UCLN_NO_AUTO_CLEANUP 1
42 #endif
43 
44 /* Need platform.h when using CYGWINMSVC to get definitions above. Ignore everything else. */
45 #ifndef CYGWINMSVC
46 
47 /** Define the platform we're on. */
48 #ifndef U_DARWIN
49 #define U_DARWIN
50 #endif
51 
52 #include <AvailabilityMacros.h>
53 #include <TargetConditionals.h>
54 
55 /**
56  * Add a second platform define to handle differences between Mac OS X and iOS
57  */
58 #if TARGET_OS_IPHONE
59 #ifndef U_IOS
60 #define U_IOS
61 #endif
62 #endif
63 
64 /**
65  * \def U_HAVE_DIRENT_H
66  * Define whether dirent.h is available
67  * @internal
68  */
69 #ifndef U_HAVE_DIRENT_H
70 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
71 #define U_HAVE_DIRENT_H 0
72 #else
73 #define U_HAVE_DIRENT_H 1
74 #endif
75 #endif
76 
77 /** Define whether inttypes.h is available */
78 #ifndef U_HAVE_INTTYPES_H
79 #define U_HAVE_INTTYPES_H 1
80 #endif
81 
82 /**
83  * Define what support for C++ streams is available.
84  *     If U_IOSTREAM_SOURCE is set to 199711, then &lt;iostream&gt; is available
85  * (1997711 is the date the ISO/IEC C++ FDIS was published), and then
86  * one should qualify streams using the std namespace in ICU header
87  * files.
88  *     If U_IOSTREAM_SOURCE is set to 198506, then &lt;iostream.h&gt; is
89  * available instead (198506 is the date when Stroustrup published
90  * "An Extensible I/O Facility for C++" at the summer USENIX conference).
91  *     If U_IOSTREAM_SOURCE is 0, then C++ streams are not available and
92  * support for them will be silently suppressed in ICU.
93  *
94  */
95 
96 #ifndef U_IOSTREAM_SOURCE
97 #define U_IOSTREAM_SOURCE 199711
98 #endif
99 
100 /**
101  * \def U_HAVE_STD_STRING
102  * Define whether the standard C++ (STL) &lt;string&gt; header is available.
103  * For platforms that do not use platform.h and do not define this constant
104  * in their platform-specific headers, std_string.h defaults
105  * U_HAVE_STD_STRING to 1.
106  * @internal
107  */
108 #ifndef U_HAVE_STD_STRING
109 #define U_HAVE_STD_STRING 1
110 #endif
111 
112 /** @{ Determines whether specific types are available */
113 #ifndef U_HAVE_INT8_T
114 #define U_HAVE_INT8_T 1
115 #endif
116 
117 #ifndef U_HAVE_UINT8_T
118 #define U_HAVE_UINT8_T 1
119 #endif
120 
121 #ifndef U_HAVE_INT16_T
122 #define U_HAVE_INT16_T 1
123 #endif
124 
125 #ifndef U_HAVE_UINT16_T
126 #define U_HAVE_UINT16_T 1
127 #endif
128 
129 #ifndef U_HAVE_INT32_T
130 #define U_HAVE_INT32_T 1
131 #endif
132 
133 #ifndef U_HAVE_UINT32_T
134 #define U_HAVE_UINT32_T 1
135 #endif
136 
137 #ifndef U_HAVE_INT64_T
138 #define U_HAVE_INT64_T 1
139 #endif
140 
141 #ifndef U_HAVE_UINT64_T
142 #define U_HAVE_UINT64_T 1
143 #endif
144 
145 /** @} */
146 
147 /*===========================================================================*/
148 /** @{ Compiler and environment features                                     */
149 /*===========================================================================*/
150 
151 /* Define whether namespace is supported */
152 #ifndef U_HAVE_NAMESPACE
153 #define U_HAVE_NAMESPACE 1
154 #endif
155 
156 /* Determines the endianness of the platform
157    It's done this way in case multiple architectures are being built at once.
158    For example, Darwin supports fat binaries, which can be both PPC and x86 based. */
159 #if defined(BYTE_ORDER) && defined(BIG_ENDIAN)
160 #define U_IS_BIG_ENDIAN (BYTE_ORDER == BIG_ENDIAN)
161 #else
162 #define U_IS_BIG_ENDIAN 0
163 #endif
164 
165 /* 1 or 0 to enable or disable threads.  If undefined, default is: enable threads. */
166 #ifndef ICU_USE_THREADS
167 #define ICU_USE_THREADS 1
168 #endif
169 
170 /* On strong memory model CPUs (e.g. x86 CPUs), we use a safe & quick double check lock. */
171 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
172 #define UMTX_STRONG_MEMORY_MODEL 1
173 #endif
174 
175 #ifndef U_DEBUG
176 #define U_DEBUG 0
177 #endif
178 
179 #ifndef U_RELEASE
180 #define U_RELEASE 1
181 #endif
182 
183 /* Determine whether to disable renaming or not. This overrides the
184    setting in umachine.h which is for all platforms. */
185 #ifndef U_DISABLE_RENAMING
186 #define U_DISABLE_RENAMING 0
187 #endif
188 
189 /* Determine whether to override new and delete. */
190 #ifndef U_OVERRIDE_CXX_ALLOCATION
191 #define U_OVERRIDE_CXX_ALLOCATION 1
192 #endif
193 /* Determine whether to override placement new and delete for STL. */
194 #ifndef U_HAVE_PLACEMENT_NEW
195 #define U_HAVE_PLACEMENT_NEW 1
196 #endif
197 
198 /* Determine whether to enable tracing. */
199 #ifndef U_ENABLE_TRACING
200 #define U_ENABLE_TRACING 0
201 #endif
202 
203 /**
204  * Whether to enable Dynamic loading in ICU
205  * @internal
206  */
207 #ifndef U_ENABLE_DYLOAD
208 #define U_ENABLE_DYLOAD 1
209 #endif
210 
211 /**
212  * Whether to test Dynamic loading as an OS capabilty
213  * @internal
214  */
215 #ifndef U_CHECK_DYLOAD
216 #define U_CHECK_DYLOAD 1
217 #endif
218 
219 
220 /** Do we allow ICU users to use the draft APIs by default? */
221 #ifndef U_DEFAULT_SHOW_DRAFT
222 #define U_DEFAULT_SHOW_DRAFT 1
223 #endif
224 
225 /** @} */
226 
227 /*===========================================================================*/
228 /** @{ Character data types                                                      */
229 /*===========================================================================*/
230 
231 #if ((defined(OS390) && (!defined(__CHARSET_LIB) || !__CHARSET_LIB))) || defined(OS400)
232 #   define U_CHARSET_FAMILY 1
233 #endif
234 
235 /** @} */
236 
237 /*===========================================================================*/
238 /** @{ Information about wchar support                                           */
239 /*===========================================================================*/
240 
241 #ifndef U_HAVE_WCHAR_H
242 #define U_HAVE_WCHAR_H      1
243 #endif
244 
245 #ifndef U_SIZEOF_WCHAR_T
246 #define U_SIZEOF_WCHAR_T    4
247 #endif
248 
249 #ifndef U_HAVE_WCSCPY
250 #define U_HAVE_WCSCPY       1
251 #endif
252 
253 /** @} */
254 
255 /**
256  * @{
257  * \def U_DECLARE_UTF16
258  * Do not use this macro. Use the UNICODE_STRING or U_STRING_DECL macros
259  * instead.
260  * @internal
261  *
262  * \def U_GNUC_UTF16_STRING
263  * @internal
264  */
265 #ifndef U_GNUC_UTF16_STRING
266 #define U_GNUC_UTF16_STRING 0
267 #endif
268 #if 1 || defined(U_CHECK_UTF16_STRING)
269 #if (defined(__xlC__) && defined(__IBM_UTF_LITERAL) && U_SIZEOF_WCHAR_T != 2) \
270     || (defined(__HP_aCC) && __HP_aCC >= 035000) \
271     || (defined(__HP_cc) && __HP_cc >= 111106) \
272     || U_GNUC_UTF16_STRING
273 #define U_DECLARE_UTF16(string) u ## string
274 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550)
275 /* || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x580) */
276 /* Sun's C compiler has issues with this notation, and it's unreliable. */
277 #define U_DECLARE_UTF16(string) U ## string
278 #elif U_SIZEOF_WCHAR_T == 2 \
279     && (U_CHARSET_FAMILY == 0 || ((defined(OS390) || defined(OS400)) && defined(__UCS2__)))
280 #define U_DECLARE_UTF16(string) L ## string
281 #endif
282 #endif
283 
284 /** @} */
285 
286 /*===========================================================================*/
287 /** @{ Information about POSIX support                                           */
288 /*===========================================================================*/
289 
290 #ifndef U_HAVE_NL_LANGINFO_CODESET
291 #define U_HAVE_NL_LANGINFO_CODESET  1
292 #endif
293 
294 #ifndef U_NL_LANGINFO_CODESET
295 #define U_NL_LANGINFO_CODESET       CODESET
296 #endif
297 
298 #if 1
299 #define U_TZSET         tzset
300 #endif
301 #ifndef U_IOS
302 /* The iOS version of timezone is busted (at least in the simulator, it is
303    never set to anything useful). Leave it undefined to avoid a code path
304    in putil.c. */
305 #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
306 #define U_TIMEZONE 0
307 #else
308 #define U_TIMEZONE timezone
309 #endif
310 #endif  // !U_IOS
311 #if 1
312 #define U_TZNAME        tzname
313 #endif
314 
315 #define U_HAVE_MMAP     1
316 #define U_HAVE_POPEN    1
317 
318 /** @} */
319 
320 /*===========================================================================*/
321 /** @{ Symbol import-export control                                              */
322 /*===========================================================================*/
323 
324 #ifdef U_STATIC_IMPLEMENTATION
325 #define U_EXPORT
326 #elif 1
327 #define U_EXPORT __attribute__((visibility("default")))
328 #elif (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x550) \
329    || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x550)
330 #define U_EXPORT __global
331 /*#elif defined(__HP_aCC) || defined(__HP_cc)
332 #define U_EXPORT __declspec(dllexport)*/
333 #else
334 #define U_EXPORT
335 #endif
336 
337 /* U_CALLCONV is releated to U_EXPORT2 */
338 #define U_EXPORT2
339 
340 /* cygwin needs to export/import data */
341 #if defined(U_CYGWIN) && !defined(__GNUC__)
342 #define U_IMPORT __declspec(dllimport)
343 #else
344 #define U_IMPORT
345 #endif
346 
347 /* @} */
348 
349 /*===========================================================================*/
350 /** @{ Code alignment and C function inlining                                    */
351 /*===========================================================================*/
352 
353 #ifndef U_INLINE
354 #   ifdef __cplusplus
355 #       define U_INLINE inline
356 #   else
357 #       define U_INLINE __inline__
358 #   endif
359 #endif
360 
361 #ifndef U_ALIGN_CODE
362 #define U_ALIGN_CODE(n)
363 #endif
364 
365 /** @} */
366 
367 /*===========================================================================*/
368 /** @{ GCC built in functions for atomic memory operations                       */
369 /*===========================================================================*/
370 
371 /**
372  * \def U_HAVE_GCC_ATOMICS
373  * @internal
374  */
375 #ifndef U_HAVE_GCC_ATOMICS
376 #define U_HAVE_GCC_ATOMICS 1
377 #endif
378 
379 /** @} */
380 
381 /*===========================================================================*/
382 /** @{ Programs used by ICU code                                                 */
383 /*===========================================================================*/
384 
385 /**
386  * \def U_MAKE
387  * What program to execute to run 'make'
388  */
389 #ifndef U_MAKE
390 #define U_MAKE  "/usr/bin/gnumake"
391 #endif
392 
393 /** @} */
394 
395 #endif /* CYGWINMSVC */
396 
397 /*===========================================================================*/
398 /* Custom icu entry point renaming                                                  */
399 /*===========================================================================*/
400 
401 /**
402  * Define the library suffix with C syntax.
403  * @internal
404  */
405 # define U_LIB_SUFFIX_C_NAME
406 /**
407  * Define the library suffix as a string with C syntax
408  * @internal
409  */
410 # define U_LIB_SUFFIX_C_NAME_STRING ""
411 /**
412  * 1 if a custom library suffix is set
413  * @internal
414  */
415 # define U_HAVE_LIB_SUFFIX 0
416 
417 #if U_HAVE_LIB_SUFFIX
418 # ifndef U_ICU_ENTRY_POINT_RENAME
419 /* Renaming pattern:    u_strcpy_41_suffix */
420 #  define U_ICU_ENTRY_POINT_RENAME(x)    x ## _ ## 46 ##
421 #  define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt####major##minor##_dat
422 
423 # endif
424 #endif
425 
426 /*===========================================================================*/
427 /* Local defines                                                             */
428 /*===========================================================================*/
429 
430 /* On the Mac, we define U_WCHAR_IS_UTF32 to treat wchar_t as though it
431    contains UTF-32 at all times.  Strictly speaking, that's not entirely
432    correct given Mac's libc (__STDC_ISO_10646__ is not defined) , but provided
433    that we ignore libc's locale support (by not calling setlocale) and its
434    multibyte string support, this should be fine.  Our codebase makes enough
435    other assumptions about a UTF-8 locale and UTF-32 wchar_t strings for this
436    to make sense. */
437 #define U_WCHAR_IS_UTF32
438 
439 #endif
440