Imported Upstream version 1.0.0
[platform/upstream/js.git] / js / src / assembler / wtf / Platform.h
1 /*
2  * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
3  * Copyright (C) 2007-2009 Torch Mobile, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
15  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
18  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  */
26
27 #ifndef WTF_Platform_h
28 #define WTF_Platform_h
29
30 /* Either XX(YY) --> WTF_XX_YY  or  XX(YY) --> XX_YY, depending on XX
31
32    PLATFORM(YY) --> WTF_PLATFORM_YY
33    COMPILER(YY) --> WTF_COMPILER_YY
34    CPU(YY)      --> WTF_CPU_YY
35    OS(YY)       --> WTF_OS_YY
36    USE(YY)      --> WTF_USE_YY
37
38    HAVE(YY)     --> HAVE_YY
39    ENABLE(YY)   --> ENABLE_YY
40 */
41
42 /* ==== PLATFORM handles OS, operating environment, graphics API, and
43    CPU. This macro will be phased out in favor of platform adaptation
44    macros, policy decision macros, and top-level port definitions. ==== */
45 //#define PLATFORM(WTF_FEATURE) (defined(WTF_PLATFORM_##WTF_FEATURE)  && WTF_PLATFORM_##WTF_FEATURE)
46
47
48 /* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
49
50 /* COMPILER() - the compiler being used to build the project */
51 //#define COMPILER(WTF_FEATURE) (defined(WTF_COMPILER_##WTF_FEATURE)  && WTF_COMPILER_##WTF_FEATURE)
52 /* CPU() - the target CPU architecture */
53 //#define CPU(WTF_FEATURE) (defined(WTF_CPU_##WTF_FEATURE)  && WTF_CPU_##WTF_FEATURE)
54 /* HAVE() - specific system features (headers, functions or similar) that are present or not */
55 //#define HAVE(WTF_FEATURE) (defined(HAVE_##WTF_FEATURE)  && HAVE_##WTF_FEATURE)
56 /* OS() - underlying operating system; only to be used for mandated low-level services like 
57    virtual memory, not to choose a GUI toolkit */
58 //#define OS(WTF_FEATURE) (defined(WTF_OS_##WTF_FEATURE)  && WTF_OS_##WTF_FEATURE)
59
60
61 /* ==== Policy decision macros: these define policy choices for a particular port. ==== */
62
63 /* USE() - use a particular third-party library or optional OS service */
64 //#define USE(WTF_FEATURE) (defined(WTF_USE_##WTF_FEATURE)  && WTF_USE_##WTF_FEATURE)
65 /* ENABLE() - turn on a specific feature of WebKit */
66 //#define ENABLE(WTF_FEATURE) (defined(ENABLE_##WTF_FEATURE)  && ENABLE_##WTF_FEATURE)
67
68
69
70 /* ==== COMPILER() - the compiler being used to build the project ==== */
71
72 /* COMPILER(MSVC) Microsoft Visual C++ */
73 /* COMPILER(MSVC7) Microsoft Visual C++ v7 or lower*/
74 #if defined(_MSC_VER)
75 #define WTF_COMPILER_MSVC 1
76 #if _MSC_VER < 1400
77 #define WTF_COMPILER_MSVC7 1
78 #endif
79 #endif
80
81 /* COMPILER(RVCT)  - ARM RealView Compilation Tools */
82 #if defined(__CC_ARM) || defined(__ARMCC__)
83 #define WTF_COMPILER_RVCT 1
84 #endif
85
86 /* COMPILER(GCC) - GNU Compiler Collection */
87 /* --gnu option of the RVCT compiler also defines __GNUC__ */
88 #if defined(__GNUC__) && !WTF_COMPILER_RVCT
89 #define WTF_COMPILER_GCC 1
90 #define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
91 #endif
92
93 /* COMPILER(MINGW) - MinGW GCC */
94 #if defined(MINGW) || defined(__MINGW32__)
95 #define WTF_COMPILER_MINGW 1
96 #endif
97
98 /* COMPILER(WINSCW) - CodeWarrior for Symbian emulator */
99 #if defined(__WINSCW__)
100 #define WTF_COMPILER_WINSCW 1
101 #endif
102
103 /* COMPILER(SUNPRO) - Sun Studio for Solaris */
104 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
105 #define WTF_COMPILER_SUNPRO 1
106 #endif
107
108
109 /* ==== CPU() - the target CPU architecture ==== */
110
111 /* This also defines CPU(BIG_ENDIAN) or CPU(MIDDLE_ENDIAN) or neither, as appropriate. */
112
113
114 /* CPU(ALPHA) - DEC Alpha */
115 #if defined(__alpha__)
116 #define WTF_CPU_ALPHA 1
117 #endif
118
119 /* CPU(IA64) - Itanium / IA-64 */
120 #if defined(__ia64__)
121 #define WTF_CPU_IA64 1
122 #endif
123
124 /* CPU(PPC) - PowerPC 32-bit */
125 #if   defined(__ppc__)     \
126    || defined(__PPC__)     \
127    || defined(__powerpc__) \
128    || defined(__powerpc)   \
129    || defined(__POWERPC__) \
130    || defined(_M_PPC)      \
131    || defined(__PPC)
132 #define WTF_CPU_PPC 1
133 #define WTF_CPU_BIG_ENDIAN 1
134 #endif
135
136 /* CPU(PPC64) - PowerPC 64-bit */
137 #if   defined(__ppc64__) \
138    || defined(__PPC64__)
139 #define WTF_CPU_PPC64 1
140 #define WTF_CPU_BIG_ENDIAN 1
141 #endif
142
143 /* CPU(SH4) - SuperH SH-4 */
144 #if defined(__SH4__)
145 #define WTF_CPU_SH4 1
146 #endif
147
148 /* CPU(SPARC32) - SPARC 32-bit */
149 #if defined(__sparc) && !defined(__arch64__) || defined(__sparcv8)
150 #define WTF_CPU_SPARC32 1
151 #define WTF_CPU_BIG_ENDIAN 1
152 #endif
153
154 /* CPU(SPARC64) - SPARC 64-bit */
155 #if defined(__sparc__) && defined(__arch64__) || defined (__sparcv9)
156 #define WTF_CPU_SPARC64 1
157 #define WTF_CPU_BIG_ENDIAN 1
158 #endif
159
160 /* CPU(SPARC) - any SPARC, true for CPU(SPARC32) and CPU(SPARC64) */
161 #if WTF_CPU_SPARC32 || WTF_CPU_SPARC64
162 #define WTF_CPU_SPARC
163 #endif
164
165 /* CPU(X86) - i386 / x86 32-bit */
166 #if   defined(__i386__) \
167    || defined(i386)     \
168    || defined(_M_IX86)  \
169    || defined(_X86_)    \
170    || defined(__THW_INTEL)
171 #define WTF_CPU_X86 1
172 #endif
173
174 /* CPU(X86_64) - AMD64 / Intel64 / x86_64 64-bit */
175 #if   defined(__x86_64__) \
176    || defined(_M_X64)
177 #define WTF_CPU_X86_64 1
178 #endif
179
180 /* CPU(ARM) - ARM, any version*/
181 #if   defined(arm) \
182    || defined(__arm__)
183 #define WTF_CPU_ARM 1
184
185 #if defined(__ARMEB__)
186 #define WTF_CPU_BIG_ENDIAN 1
187
188 #elif !defined(__ARM_EABI__) \
189    && !defined(__EABI__) \
190    && !defined(__VFP_FP__) \
191    && !defined(ANDROID)
192 #define WTF_CPU_MIDDLE_ENDIAN 1
193
194 #endif
195
196 #define WTF_ARM_ARCH_AT_LEAST(N) (WTF_CPU_ARM && WTF_ARM_ARCH_VERSION >= N)
197
198 /* Set WTF_ARM_ARCH_VERSION */
199 #if   defined(__ARM_ARCH_4__) \
200    || defined(__ARM_ARCH_4T__) \
201    || defined(__MARM_ARMV4__) \
202    || defined(_ARMV4I_)
203 #define WTF_ARM_ARCH_VERSION 4
204
205 #elif defined(__ARM_ARCH_5__) \
206    || defined(__ARM_ARCH_5T__) \
207    || defined(__ARM_ARCH_5E__) \
208    || defined(__ARM_ARCH_5TE__) \
209    || defined(__ARM_ARCH_5TEJ__) \
210    || defined(__MARM_ARMV5__)
211 #define WTF_ARM_ARCH_VERSION 5
212
213 #elif defined(__ARM_ARCH_6__) \
214    || defined(__ARM_ARCH_6J__) \
215    || defined(__ARM_ARCH_6K__) \
216    || defined(__ARM_ARCH_6Z__) \
217    || defined(__ARM_ARCH_6ZK__) \
218    || defined(__ARM_ARCH_6T2__) \
219    || defined(__ARMV6__)
220 #define WTF_ARM_ARCH_VERSION 6
221
222 #elif defined(__ARM_ARCH_7A__) \
223    || defined(__ARM_ARCH_7R__)
224 #define WTF_ARM_ARCH_VERSION 7
225
226 /* RVCT sets _TARGET_ARCH_ARM */
227 #elif defined(__TARGET_ARCH_ARM)
228 #define WTF_ARM_ARCH_VERSION __TARGET_ARCH_ARM
229
230 #else
231 #define WTF_ARM_ARCH_VERSION 0
232
233 #endif
234
235 /* Set WTF_THUMB_ARCH_VERSION */
236 #if   defined(__ARM_ARCH_4T__)
237 #define WTF_THUMB_ARCH_VERSION 1
238
239 #elif defined(__ARM_ARCH_5T__) \
240    || defined(__ARM_ARCH_5TE__) \
241    || defined(__ARM_ARCH_5TEJ__)
242 #define WTF_THUMB_ARCH_VERSION 2
243
244 #elif defined(__ARM_ARCH_6J__) \
245    || defined(__ARM_ARCH_6K__) \
246    || defined(__ARM_ARCH_6Z__) \
247    || defined(__ARM_ARCH_6ZK__) \
248    || defined(__ARM_ARCH_6M__)
249 #define WTF_THUMB_ARCH_VERSION 3
250
251 #elif defined(__ARM_ARCH_6T2__) \
252    || defined(__ARM_ARCH_7__) \
253    || defined(__ARM_ARCH_7A__) \
254    || defined(__ARM_ARCH_7R__) \
255    || defined(__ARM_ARCH_7M__)
256 #define WTF_THUMB_ARCH_VERSION 4
257
258 /* RVCT sets __TARGET_ARCH_THUMB */
259 #elif defined(__TARGET_ARCH_THUMB)
260 #define WTF_THUMB_ARCH_VERSION __TARGET_ARCH_THUMB
261
262 #else
263 #define WTF_THUMB_ARCH_VERSION 0
264 #endif
265
266
267 /* CPU(ARMV5_OR_LOWER) - ARM instruction set v5 or earlier */
268 /* On ARMv5 and below the natural alignment is required. 
269    And there are some other differences for v5 or earlier. */
270 #if !defined(ARMV5_OR_LOWER) /* && !CPU_ARM_ARCH_AT_LEAST(6) */
271 #define WTF_CPU_ARMV5_OR_LOWER 1
272 #endif
273
274
275 /* CPU(ARM_TRADITIONAL) - Thumb2 is not available, only traditional ARM (v4 or greater) */
276 /* CPU(ARM_THUMB2) - Thumb2 instruction set is available */
277 /* Only one of these will be defined. */
278 #if !defined(WTF_CPU_ARM_TRADITIONAL) && !defined(WTF_CPU_ARM_THUMB2)
279 #  if defined(thumb2) || defined(__thumb2__) \
280   || ((defined(__thumb) || defined(__thumb__)) && WTF_THUMB_ARCH_VERSION == 4)
281 #    define WTF_CPU_ARM_TRADITIONAL 1
282 #    define WTF_CPU_ARM_THUMB2 0
283 #  elif WTF_ARM_ARCH_AT_LEAST(4)
284 #    define WTF_CPU_ARM_TRADITIONAL 1
285 #    define WTF_CPU_ARM_THUMB2 0
286 #  else
287 #    error "Not supported ARM architecture"
288 #  endif
289 #elif WTF_CPU_ARM_TRADITIONAL && WTF_CPU_ARM_THUMB2 /* Sanity Check */
290 #  error "Cannot use both of WTF_CPU_ARM_TRADITIONAL and WTF_CPU_ARM_THUMB2 platforms"
291 #endif // !defined(WTF_CPU_ARM_TRADITIONAL) && !defined(WTF_CPU_ARM_THUMB2)
292
293 #endif /* ARM */
294
295
296
297 /* Operating systems - low-level dependencies */
298
299 /* PLATFORM(DARWIN) */
300 /* Operating system level dependencies for Mac OS X / Darwin that should */
301 /* be used regardless of operating environment */
302 #ifdef __APPLE__
303 #define WTF_PLATFORM_DARWIN 1
304 #include <AvailabilityMacros.h>
305 #if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
306 #define BUILDING_ON_TIGER 1
307 #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
308 #define BUILDING_ON_LEOPARD 1
309 #elif !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
310 #define BUILDING_ON_SNOW_LEOPARD 1
311 #endif
312 #if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5
313 #define TARGETING_TIGER 1
314 #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_6
315 #define TARGETING_LEOPARD 1
316 #elif !defined(MAC_OS_X_VERSION_10_7) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7
317 #define TARGETING_SNOW_LEOPARD 1
318 #endif
319 #include <TargetConditionals.h>
320 #endif
321
322 /* PLATFORM(WIN_OS) */
323 /* Operating system level dependencies for Windows that should be used */
324 /* regardless of operating environment */
325 #if defined(WIN32) || defined(_WIN32)
326 #define WTF_PLATFORM_WIN_OS 1
327 #endif
328
329 /* PLATFORM(WINCE) */
330 /* Operating system level dependencies for Windows CE that should be used */
331 /* regardless of operating environment */
332 /* Note that for this platform PLATFORM(WIN_OS) is also defined. */
333 #if defined(_WIN32_WCE)
334 #define WTF_PLATFORM_WINCE 1
335 #endif
336
337 /* PLATFORM(LINUX) */
338 /* Operating system level dependencies for Linux-like systems that */
339 /* should be used regardless of operating environment */
340 #ifdef __linux__
341 #define WTF_PLATFORM_LINUX 1
342 #endif
343
344 /* PLATFORM(FREEBSD) */
345 /* Operating system level dependencies for FreeBSD-like systems that */
346 /* should be used regardless of operating environment */
347 #ifdef __FreeBSD__
348 #define WTF_PLATFORM_FREEBSD 1
349 #endif
350
351 /* PLATFORM(OPENBSD) */
352 /* Operating system level dependencies for OpenBSD systems that */
353 /* should be used regardless of operating environment */
354 #ifdef __OpenBSD__
355 #define WTF_PLATFORM_OPENBSD 1
356 #endif
357
358 /* PLATFORM(SOLARIS) */
359 /* Operating system level dependencies for Solaris that should be used */
360 /* regardless of operating environment */
361 #if defined(sun) || defined(__sun)
362 #define WTF_PLATFORM_SOLARIS 1
363 #endif
364
365 /* PLATFORM(OS2) */
366 /* Operating system level dependencies for OS/2 that should be used */
367 /* regardless of operating environment */
368 #if defined(OS2) || defined(__OS2__)
369 #define WTF_PLATFORM_OS2 1
370 #endif
371
372 #if defined (__SYMBIAN32__)
373 /* we are cross-compiling, it is not really windows */
374 #undef WTF_PLATFORM_WIN_OS
375 #undef WTF_PLATFORM_WIN
376 #define WTF_PLATFORM_SYMBIAN 1
377 #endif
378
379
380 /* PLATFORM(NETBSD) */
381 /* Operating system level dependencies for NetBSD that should be used */
382 /* regardless of operating environment */
383 #if defined(__NetBSD__)
384 #define WTF_PLATFORM_NETBSD 1
385 #endif
386
387 /* PLATFORM(QNX) */
388 /* Operating system level dependencies for QNX that should be used */
389 /* regardless of operating environment */
390 #if defined(__QNXNTO__)
391 #define WTF_PLATFORM_QNX 1
392 #endif
393
394 /* PLATFORM(UNIX) */
395 /* Operating system level dependencies for Unix-like systems that */
396 /* should be used regardless of operating environment */
397 #if   WTF_PLATFORM_DARWIN     \
398    || WTF_PLATFORM_FREEBSD    \
399    || WTF_PLATFORM_SYMBIAN    \
400    || WTF_PLATFORM_NETBSD     \
401    || defined(unix)        \
402    || defined(__unix)      \
403    || defined(__unix__)    \
404    || defined(_AIX)        \
405    || defined(__HAIKU__)   \
406    || defined(__QNXNTO__)  \
407    || defined(ANDROID)
408 #define WTF_PLATFORM_UNIX 1
409 #endif
410
411 /* Operating environments */
412
413 /* PLATFORM(CHROMIUM) */
414 /* PLATFORM(QT) */
415 /* PLATFORM(WX) */
416 /* PLATFORM(GTK) */
417 /* PLATFORM(HAIKU) */
418 /* PLATFORM(MAC) */
419 /* PLATFORM(WIN) */
420 #if defined(BUILDING_CHROMIUM__)
421 #define WTF_PLATFORM_CHROMIUM 1
422 #elif defined(BUILDING_QT__)
423 #define WTF_PLATFORM_QT 1
424 #elif defined(BUILDING_WX__)
425 #define WTF_PLATFORM_WX 1
426 #elif defined(BUILDING_GTK__)
427 #define WTF_PLATFORM_GTK 1
428 #elif defined(BUILDING_HAIKU__)
429 #define WTF_PLATFORM_HAIKU 1
430 #elif WTF_PLATFORM_DARWIN
431 #define WTF_PLATFORM_MAC 1
432 #elif WTF_PLATFORM_WIN_OS
433 #define WTF_PLATFORM_WIN 1
434 #endif
435
436 /* PLATFORM(IPHONE) */
437 #if (defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
438 #define WTF_PLATFORM_IPHONE 1
439 #endif
440
441 /* PLATFORM(IPHONE_SIMULATOR) */
442 #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
443 #define WTF_PLATFORM_IPHONE 1
444 #define WTF_PLATFORM_IPHONE_SIMULATOR 1
445 #else
446 #define WTF_PLATFORM_IPHONE_SIMULATOR 0
447 #endif
448
449 #if !defined(WTF_PLATFORM_IPHONE)
450 #define WTF_PLATFORM_IPHONE 0
451 #endif
452
453 /* PLATFORM(ANDROID) */
454 #if defined(ANDROID)
455 #define WTF_PLATFORM_ANDROID 1
456 #endif
457
458 /* Graphics engines */
459
460 /* PLATFORM(CG) and PLATFORM(CI) */
461 #if WTF_PLATFORM_MAC || WTF_PLATFORM_IPHONE
462 #define WTF_PLATFORM_CG 1
463 #endif
464 #if WTF_PLATFORM_MAC && !WTF_PLATFORM_IPHONE
465 #define WTF_PLATFORM_CI 1
466 #endif
467
468 /* PLATFORM(SKIA) for Win/Linux, CG/CI for Mac */
469 #if WTF_PLATFORM_CHROMIUM
470 #if WTF_PLATFORM_DARWIN
471 #define WTF_PLATFORM_CG 1
472 #define WTF_PLATFORM_CI 1
473 #define WTF_USE_ATSUI 1
474 #define WTF_USE_CORE_TEXT 1
475 #else
476 #define WTF_PLATFORM_SKIA 1
477 #endif
478 #endif
479
480 #if WTF_PLATFORM_GTK
481 #define WTF_PLATFORM_CAIRO 1
482 #endif
483
484
485 /* PLATFORM(WINCE) && PLATFORM(QT)
486    We can not determine the endianess at compile time. For
487    Qt for Windows CE the endianess is specified in the
488    device specific makespec
489 */
490 #if WTF_PLATFORM_WINCE && WTF_PLATFORM_QT
491 #   include <QtGlobal>
492 #   undef WTF_PLATFORM_BIG_ENDIAN
493 #   undef WTF_PLATFORM_MIDDLE_ENDIAN
494 #   if Q_BYTE_ORDER == Q_BIG_EDIAN
495 #       define WTF_PLATFORM_BIG_ENDIAN 1
496 #   endif
497
498 #   include <ce_time.h>
499 #endif
500
501 #if (WTF_PLATFORM_IPHONE || WTF_PLATFORM_MAC || WTF_PLATFORM_WIN || WTF_PLATFORM_OS2 || (WTF_PLATFORM_QT && WTF_PLATFORM_DARWIN && !ENABLE_SINGLE_THREADED)) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
502 #define ENABLE_JSC_MULTIPLE_THREADS 1
503 #endif
504
505 /* On Windows, use QueryPerformanceCounter by default */
506 #if WTF_PLATFORM_WIN_OS
507 #define WTF_USE_QUERY_PERFORMANCE_COUNTER  1
508 #endif
509
510 #if WTF_PLATFORM_WINCE && !WTF_PLATFORM_QT
511 #undef ENABLE_JSC_MULTIPLE_THREADS
512 #define ENABLE_JSC_MULTIPLE_THREADS        0
513 #define USE_SYSTEM_MALLOC                  0
514 #define ENABLE_ICONDATABASE                0
515 #define ENABLE_JAVASCRIPT_DEBUGGER         0
516 #define ENABLE_FTPDIR                      0
517 #define ENABLE_PAN_SCROLLING               0
518 #define ENABLE_WML                         1
519 #define HAVE_ACCESSIBILITY                 0
520
521 #define NOMINMAX       // Windows min and max conflict with standard macros
522 #define NOSHLWAPI      // shlwapi.h not available on WinCe
523
524 // MSDN documentation says these functions are provided with uspce.lib.  But we cannot find this file.
525 #define __usp10__      // disable "usp10.h"
526
527 #define _INC_ASSERT    // disable "assert.h"
528 #define assert(x)
529
530 // _countof is only included in CE6; for CE5 we need to define it ourself
531 #ifndef _countof
532 #define _countof(x) (sizeof(x) / sizeof((x)[0]))
533 #endif
534
535 #endif  /* PLATFORM(WINCE) && !PLATFORM(QT) */
536
537 #if WTF_PLATFORM_QT
538 #define WTF_USE_QT4_UNICODE 1
539 #elif WTF_PLATFORM_WINCE
540 #define WTF_USE_WINCE_UNICODE 1
541 #elif WTF_PLATFORM_GTK
542 /* The GTK+ Unicode backend is configurable */
543 #else
544 #define WTF_USE_ICU_UNICODE 1
545 #endif
546
547 #if WTF_PLATFORM_MAC && !WTF_PLATFORM_IPHONE
548 #define WTF_PLATFORM_CF 1
549 #define WTF_USE_PTHREADS 1
550 #define HAVE_PTHREAD_RWLOCK 1
551 #if !defined(BUILDING_ON_LEOPARD) && !defined(BUILDING_ON_TIGER) && WTF_CPU_X86_64
552 #define WTF_USE_PLUGIN_HOST_PROCESS 1
553 #endif
554 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
555 #define ENABLE_MAC_JAVA_BRIDGE 1
556 #endif
557 #if !defined(ENABLE_DASHBOARD_SUPPORT)
558 #define ENABLE_DASHBOARD_SUPPORT 1
559 #endif
560 #define HAVE_READLINE 1
561 #define HAVE_RUNLOOP_TIMER 1
562 #endif /* PLATFORM(MAC) && !PLATFORM(IPHONE) */
563
564 #if WTF_PLATFORM_CHROMIUM && WTF_PLATFORM_DARWIN
565 #define WTF_PLATFORM_CF 1
566 #define WTF_USE_PTHREADS 1
567 #define HAVE_PTHREAD_RWLOCK 1
568 #endif
569
570 #if WTF_PLATFORM_QT && WTF_PLATFORM_DARWIN
571 #define WTF_PLATFORM_CF 1
572 #endif
573
574 #if WTF_PLATFORM_IPHONE
575 #define ENABLE_CONTEXT_MENUS 0
576 #define ENABLE_DRAG_SUPPORT 0
577 #define ENABLE_FTPDIR 1
578 #define ENABLE_GEOLOCATION 1
579 #define ENABLE_ICONDATABASE 0
580 #define ENABLE_INSPECTOR 0
581 #define ENABLE_MAC_JAVA_BRIDGE 0
582 #define ENABLE_NETSCAPE_PLUGIN_API 0
583 #define ENABLE_ORIENTATION_EVENTS 1
584 #define ENABLE_REPAINT_THROTTLING 1
585 #define HAVE_READLINE 1
586 #define WTF_PLATFORM_CF 1
587 #define WTF_USE_PTHREADS 1
588 #define HAVE_PTHREAD_RWLOCK 1
589 #endif
590
591 #if WTF_PLATFORM_ANDROID
592 #define WTF_USE_PTHREADS 1
593 #define WTF_PLATFORM_SGL 1
594 #define USE_SYSTEM_MALLOC 1
595 #define ENABLE_MAC_JAVA_BRIDGE 1
596 #define LOG_DISABLED 1
597 // Prevents Webkit from drawing the caret in textfields and textareas
598 // This prevents unnecessary invals.
599 #define ENABLE_TEXT_CARET 1
600 #define ENABLE_JAVASCRIPT_DEBUGGER 0
601 #endif
602
603 #if WTF_PLATFORM_WIN
604 #define WTF_USE_WININET 1
605 #endif
606
607 #if WTF_PLATFORM_WX
608 #define ENABLE_ASSEMBLER 1
609 #if WTF_PLATFORM_DARWIN
610 #define WTF_PLATFORM_CF 1
611 #endif
612 #endif
613
614 #if WTF_PLATFORM_GTK
615 #if HAVE_PTHREAD_H
616 #define WTF_USE_PTHREADS 1
617 #define HAVE_PTHREAD_RWLOCK 1
618 #endif
619 #endif
620
621 #if WTF_PLATFORM_HAIKU
622 #define HAVE_POSIX_MEMALIGN 1
623 #define WTF_USE_CURL 1
624 #define WTF_USE_PTHREADS 1
625 #define HAVE_PTHREAD_RWLOCK 1
626 #define USE_SYSTEM_MALLOC 1
627 #define ENABLE_NETSCAPE_PLUGIN_API 0
628 #endif
629
630 #if !defined(HAVE_ACCESSIBILITY)
631 #if WTF_PLATFORM_IPHONE || WTF_PLATFORM_MAC || WTF_PLATFORM_WIN || WTF_PLATFORM_GTK || WTF_PLATFORM_CHROMIUM
632 #define HAVE_ACCESSIBILITY 1
633 #endif
634 #endif /* !defined(HAVE_ACCESSIBILITY) */
635
636 #if WTF_PLATFORM_UNIX && !WTF_PLATFORM_SYMBIAN
637 #define HAVE_SIGNAL_H 1
638 #endif
639
640 #if !WTF_PLATFORM_WIN_OS && !WTF_PLATFORM_SOLARIS && !WTF_PLATFORM_QNX \
641     && !WTF_PLATFORM_SYMBIAN && !WTF_PLATFORM_HAIKU && !WTF_COMPILER_RVCT \
642     && !WTF_PLATFORM_ANDROID && !WTF_PLATFORM_OS2
643 #define HAVE_TM_GMTOFF 1
644 #define HAVE_TM_ZONE 1
645 #define HAVE_TIMEGM 1
646 #endif     
647
648 #if WTF_PLATFORM_DARWIN
649
650 #define HAVE_ERRNO_H 1
651 #define HAVE_LANGINFO_H 1
652 #define HAVE_MMAP 1
653 #define HAVE_MERGESORT 1
654 #define HAVE_SBRK 1
655 #define HAVE_STRINGS_H 1
656 #define HAVE_SYS_PARAM_H 1
657 #define HAVE_SYS_TIME_H 1
658 #define HAVE_SYS_TIMEB_H 1
659
660 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD) && !WTF_PLATFORM_IPHONE && !WTF_PLATFORM_QT
661 #define HAVE_MADV_FREE_REUSE 1
662 #define HAVE_MADV_FREE 1
663 #define HAVE_PTHREAD_SETNAME_NP 1
664 #endif
665
666 #if WTF_PLATFORM_IPHONE
667 #define HAVE_MADV_FREE 1
668 #endif
669
670 #elif WTF_PLATFORM_WIN_OS
671
672 #if WTF_PLATFORM_WINCE
673 #define HAVE_ERRNO_H 0
674 #else
675 #define HAVE_SYS_TIMEB_H 1
676 #endif
677 #define HAVE_VIRTUALALLOC 1
678
679 #elif WTF_PLATFORM_SYMBIAN
680
681 #define HAVE_ERRNO_H 1
682 #define HAVE_MMAP 0
683 #define HAVE_SBRK 1
684
685 #define HAVE_SYS_TIME_H 1
686 #define HAVE_STRINGS_H 1
687
688 #if !WTF_COMPILER_RVCT
689 #define HAVE_SYS_PARAM_H 1
690 #endif
691
692 #elif WTF_PLATFORM_QNX
693
694 #define HAVE_ERRNO_H 1
695 #define HAVE_MMAP 1
696 #define HAVE_SBRK 1
697 #define HAVE_STRINGS_H 1
698 #define HAVE_SYS_PARAM_H 1
699 #define HAVE_SYS_TIME_H 1
700
701 #elif WTF_PLATFORM_ANDROID
702
703 #define HAVE_ERRNO_H 1
704 #define HAVE_LANGINFO_H 0
705 #define HAVE_MMAP 1
706 #define HAVE_SBRK 1
707 #define HAVE_STRINGS_H 1
708 #define HAVE_SYS_PARAM_H 1
709 #define HAVE_SYS_TIME_H 1
710
711 #elif WTF_PLATFORM_OS2
712
713 #define HAVE_MMAP 1
714 #define ENABLE_ASSEMBLER 1
715 #define HAVE_ERRNO_H 1
716 #define HAVE_STRINGS_H 1
717 #define HAVE_SYS_PARAM_H 1
718 #define HAVE_SYS_TIME_H 1
719 #define HAVE_SYS_TIMEB_H 1
720
721 #else
722
723 /* FIXME: is this actually used or do other platforms generate their own config.h? */
724
725 #define HAVE_ERRNO_H 1
726 /* As long as Haiku doesn't have a complete support of locale this will be disabled. */
727 #if !WTF_PLATFORM_HAIKU
728 #define HAVE_LANGINFO_H 1
729 #endif
730 #define HAVE_MMAP 1
731 #define HAVE_SBRK 1
732 #define HAVE_STRINGS_H 1
733 #define HAVE_SYS_PARAM_H 1
734 #define HAVE_SYS_TIME_H 1
735
736 #endif
737
738 /* ENABLE macro defaults */
739
740 /* fastMalloc match validation allows for runtime verification that
741    new is matched by delete, fastMalloc is matched by fastFree, etc. */
742 #if !defined(ENABLE_FAST_MALLOC_MATCH_VALIDATION)
743 #define ENABLE_FAST_MALLOC_MATCH_VALIDATION 0
744 #endif
745
746 #if !defined(ENABLE_ICONDATABASE)
747 #define ENABLE_ICONDATABASE 1
748 #endif
749
750 #if !defined(ENABLE_DATABASE)
751 #define ENABLE_DATABASE 1
752 #endif
753
754 #if !defined(ENABLE_JAVASCRIPT_DEBUGGER)
755 #define ENABLE_JAVASCRIPT_DEBUGGER 1
756 #endif
757
758 #if !defined(ENABLE_FTPDIR)
759 #define ENABLE_FTPDIR 1
760 #endif
761
762 #if !defined(ENABLE_CONTEXT_MENUS)
763 #define ENABLE_CONTEXT_MENUS 1
764 #endif
765
766 #if !defined(ENABLE_DRAG_SUPPORT)
767 #define ENABLE_DRAG_SUPPORT 1
768 #endif
769
770 #if !defined(ENABLE_DASHBOARD_SUPPORT)
771 #define ENABLE_DASHBOARD_SUPPORT 0
772 #endif
773
774 #if !defined(ENABLE_INSPECTOR)
775 #define ENABLE_INSPECTOR 1
776 #endif
777
778 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
779 #define ENABLE_MAC_JAVA_BRIDGE 0
780 #endif
781
782 #if !defined(ENABLE_NETSCAPE_PLUGIN_API)
783 #define ENABLE_NETSCAPE_PLUGIN_API 1
784 #endif
785
786 #if !defined(WTF_USE_PLUGIN_HOST_PROCESS)
787 #define WTF_USE_PLUGIN_HOST_PROCESS 0
788 #endif
789
790 #if !defined(ENABLE_ORIENTATION_EVENTS)
791 #define ENABLE_ORIENTATION_EVENTS 0
792 #endif
793
794 #if !defined(ENABLE_OPCODE_STATS)
795 #define ENABLE_OPCODE_STATS 0
796 #endif
797
798 #define ENABLE_SAMPLING_COUNTERS 0
799 #define ENABLE_SAMPLING_FLAGS 0
800 #define ENABLE_OPCODE_SAMPLING 0
801 #define ENABLE_CODEBLOCK_SAMPLING 0
802 #if ENABLE_CODEBLOCK_SAMPLING && !ENABLE_OPCODE_SAMPLING
803 #error "CODEBLOCK_SAMPLING requires OPCODE_SAMPLING"
804 #endif
805 #if ENABLE_OPCODE_SAMPLING || ENABLE_SAMPLING_FLAGS
806 #define ENABLE_SAMPLING_THREAD 1
807 #endif
808
809 #if !defined(ENABLE_GEOLOCATION)
810 #define ENABLE_GEOLOCATION 0
811 #endif
812
813 #if !defined(ENABLE_NOTIFICATIONS)
814 #define ENABLE_NOTIFICATIONS 0
815 #endif
816
817 #if !defined(ENABLE_TEXT_CARET)
818 #define ENABLE_TEXT_CARET 1
819 #endif
820
821 #if !defined(ENABLE_ON_FIRST_TEXTAREA_FOCUS_SELECT_ALL)
822 #define ENABLE_ON_FIRST_TEXTAREA_FOCUS_SELECT_ALL 0
823 #endif
824
825 #if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64)
826 #if (WTF_CPU_X86_64 && (WTF_PLATFORM_UNIX || WTF_PLATFORM_WIN_OS)) || WTF_CPU_IA64 || WTF_CPU_ALPHA
827 #define WTF_USE_JSVALUE64 1
828 #elif WTF_CPU_ARM || WTF_CPU_PPC64
829 #define WTF_USE_JSVALUE32 1
830 #elif WTF_PLATFORM_WIN_OS && WTF_COMPILER_MINGW
831 /* Using JSVALUE32_64 causes padding/alignement issues for JITStubArg
832 on MinGW. See https://bugs.webkit.org/show_bug.cgi?id=29268 */
833 #define WTF_USE_JSVALUE32 1
834 #else
835 #define WTF_USE_JSVALUE32_64 1
836 #endif
837 #endif /* !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64) */
838
839 #if !defined(ENABLE_REPAINT_THROTTLING)
840 #define ENABLE_REPAINT_THROTTLING 0
841 #endif
842
843 #if !defined(ENABLE_JIT)
844
845 /* The JIT is tested & working on x86_64 Mac */
846 #if WTF_CPU_X86_64 && WTF_PLATFORM_MAC
847     #define ENABLE_JIT 1
848 /* The JIT is tested & working on x86 Mac */
849 #elif WTF_CPU_X86 && WTF_PLATFORM_MAC
850     #define ENABLE_JIT 1
851     #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
852 #elif WTF_CPU_ARM_THUMB2 && WTF_PLATFORM_IPHONE
853     #define ENABLE_JIT 1
854 /* The JIT is tested & working on x86 OS/2 */
855 #elif WTF_CPU_X86 && WTF_PLATFORM_OS2
856     #define ENABLE_JIT 1
857 /* The JIT is tested & working on x86 Windows */
858 #elif WTF_CPU_X86 && WTF_PLATFORM_WIN
859     #define ENABLE_JIT 1
860 #endif
861
862 #if WTF_PLATFORM_QT
863 #if WTF_CPU_X86_64 && WTF_PLATFORM_DARWIN
864     #define ENABLE_JIT 1
865 #elif WTF_CPU_X86 && WTF_PLATFORM_DARWIN
866     #define ENABLE_JIT 1
867     #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
868 #elif WTF_CPU_X86 && WTF_PLATFORM_WIN_OS && WTF_COMPILER_MINGW && GCC_VERSION >= 40100
869     #define ENABLE_JIT 1
870     #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
871 #elif WTF_CPU_X86 && WTF_PLATFORM_WIN_OS && WTF_COMPILER_MSVC
872     #define ENABLE_JIT 1
873     #define WTF_USE_JIT_STUB_ARGUMENT_REGISTER 1
874 #elif WTF_CPU_X86 && WTF_PLATFORM_LINUX && GCC_VERSION >= 40100
875     #define ENABLE_JIT 1
876     #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
877 #elif WTF_CPU_ARM_TRADITIONAL && WTF_PLATFORM_LINUX
878     #define ENABLE_JIT 1
879 #endif
880 #endif /* PLATFORM(QT) */
881
882 #endif /* !defined(ENABLE_JIT) */
883
884 #if ENABLE_JIT
885 #ifndef ENABLE_JIT_OPTIMIZE_CALL
886 #define ENABLE_JIT_OPTIMIZE_CALL 1
887 #endif
888 #ifndef ENABLE_JIT_OPTIMIZE_NATIVE_CALL
889 #define ENABLE_JIT_OPTIMIZE_NATIVE_CALL 1
890 #endif
891 #ifndef ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS
892 #define ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS 1
893 #endif
894 #ifndef ENABLE_JIT_OPTIMIZE_METHOD_CALLS
895 #define ENABLE_JIT_OPTIMIZE_METHOD_CALLS 1
896 #endif
897 #endif
898
899 #if WTF_CPU_X86 && WTF_COMPILER_MSVC
900 #define JSC_HOST_CALL __fastcall
901 #elif WTF_CPU_X86 && WTF_COMPILER_GCC
902 #define JSC_HOST_CALL __attribute__ ((fastcall))
903 #else
904 #define JSC_HOST_CALL
905 #endif
906
907 #if WTF_COMPILER_GCC && !ENABLE_JIT
908 #define HAVE_COMPUTED_GOTO 1
909 #endif
910
911 #if ENABLE_JIT && defined(COVERAGE)
912     #define WTF_USE_INTERPRETER 0
913 #else
914     #define WTF_USE_INTERPRETER 1
915 #endif
916
917 /* Yet Another Regex Runtime. */
918 #if !defined(ENABLE_YARR_JIT)
919
920 /* YARR supports x86 & x86-64, and has been tested on Mac and Windows. */
921 #if (WTF_CPU_X86 \
922  || WTF_CPU_X86_64 \
923  || WTF_CPU_ARM_TRADITIONAL \
924  || WTF_CPU_ARM_THUMB2 \
925  || WTF_CPU_X86)
926 #define ENABLE_YARR_JIT 1
927 #else
928 #define ENABLE_YARR_JIT 0
929 #endif
930
931 #endif /* !defined(ENABLE_YARR_JIT) */
932
933 #if (ENABLE_JIT || ENABLE_YARR_JIT)
934 #define ENABLE_ASSEMBLER 1
935 #endif
936 /* Setting this flag prevents the assembler from using RWX memory; this may improve
937    security but currectly comes at a significant performance cost. */
938 #if WTF_PLATFORM_IPHONE
939 #define ENABLE_ASSEMBLER_WX_EXCLUSIVE 1
940 #else
941 #define ENABLE_ASSEMBLER_WX_EXCLUSIVE 0
942 #endif
943
944 #if !defined(ENABLE_PAN_SCROLLING) && WTF_PLATFORM_WIN_OS
945 #define ENABLE_PAN_SCROLLING 1
946 #endif
947
948 /* Use the QXmlStreamReader implementation for XMLTokenizer */
949 /* Use the QXmlQuery implementation for XSLTProcessor */
950 #if WTF_PLATFORM_QT
951 #define WTF_USE_QXMLSTREAM 1
952 #define WTF_USE_QXMLQUERY 1
953 #endif
954
955 #if !WTF_PLATFORM_QT
956 #define WTF_USE_FONT_FAST_PATH 1
957 #endif
958
959 /* Accelerated compositing */
960 #if WTF_PLATFORM_MAC
961 #if !defined(BUILDING_ON_TIGER)
962 #define WTF_USE_ACCELERATED_COMPOSITING 1
963 #endif
964 #endif
965
966 #if WTF_PLATFORM_IPHONE
967 #define WTF_USE_ACCELERATED_COMPOSITING 1
968 #endif
969
970 /* FIXME: Defining ENABLE_3D_RENDERING here isn't really right, but it's always used with
971    with WTF_USE_ACCELERATED_COMPOSITING, and it allows the feature to be turned on and
972    off in one place. */
973 //#if WTF_PLATFORM_WIN
974 //#include "QuartzCorePresent.h"
975 //#if QUARTZCORE_PRESENT
976 //#define WTF_USE_ACCELERATED_COMPOSITING 1
977 //#define ENABLE_3D_RENDERING 1
978 //#endif
979 //#endif
980
981 #if WTF_COMPILER_GCC
982 #define WARN_UNUSED_RETURN __attribute__ ((warn_unused_result))
983 #else
984 #define WARN_UNUSED_RETURN
985 #endif
986
987 #if !ENABLE_NETSCAPE_PLUGIN_API || (ENABLE_NETSCAPE_PLUGIN_API && ((WTF_PLATFORM_UNIX && (WTF_PLATFORM_QT || WTF_PLATFORM_WX)) || WTF_PLATFORM_GTK))
988 #define ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH 1
989 #endif
990
991 /* Set up a define for a common error that is intended to cause a build error -- thus the space after Error. */
992 #define WTF_PLATFORM_CFNETWORK Error USE_macro_should_be_used_with_CFNETWORK
993
994 #define ENABLE_JSC_ZOMBIES 0
995
996 #endif /* WTF_Platform_h */