]>
git.saurik.com Git - apple/javascriptcore.git/blob - wtf/Platform.h
e4d41fe8c4688408004b1756257cab169544b439
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef WTF_Platform_h
27 #define WTF_Platform_h
29 /* PLATFORM handles OS, operating environment, graphics API, and CPU */
30 #define PLATFORM(WTF_FEATURE) (defined( WTF_PLATFORM_##WTF_FEATURE ) && WTF_PLATFORM_##WTF_FEATURE)
31 #define COMPILER(WTF_FEATURE) (defined( WTF_COMPILER_##WTF_FEATURE ) && WTF_COMPILER_##WTF_FEATURE)
32 #define HAVE(WTF_FEATURE) (defined( HAVE_##WTF_FEATURE ) && HAVE_##WTF_FEATURE)
33 #define USE(WTF_FEATURE) (defined( WTF_USE_##WTF_FEATURE ) && WTF_USE_##WTF_FEATURE)
34 #define ENABLE(WTF_FEATURE) (defined( ENABLE_##WTF_FEATURE ) && ENABLE_##WTF_FEATURE)
36 /* Operating systems - low-level dependencies */
38 /* PLATFORM(DARWIN) */
39 /* Operating system level dependencies for Mac OS X / Darwin that should */
40 /* be used regardless of operating environment */
42 #define WTF_PLATFORM_DARWIN 1
43 #include <AvailabilityMacros.h>
44 #if !defined(MAC_OS_X_VERSION_10_5) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5
45 #define BUILDING_ON_TIGER 1
46 #elif !defined(MAC_OS_X_VERSION_10_6) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6
47 #define BUILDING_ON_LEOPARD 1
49 #include <Availability.h>
50 #include <TargetConditionals.h>
53 /* PLATFORM(WIN_OS) */
54 /* Operating system level dependencies for Windows that should be used */
55 /* regardless of operating environment */
56 #if defined(WIN32) || defined(_WIN32)
57 #define WTF_PLATFORM_WIN_OS 1
61 /* Operating system level dependencies for Windows CE that should be used */
62 /* regardless of operating environment */
63 /* Note that for this platform PLATFORM(WIN_OS) is also defined. */
64 #if defined(_WIN32_WCE)
65 #define WTF_PLATFORM_WINCE 1
69 /* Operating system level dependencies for Linux-like systems that */
70 /* should be used regardless of operating environment */
72 #define WTF_PLATFORM_LINUX 1
75 /* PLATFORM(FREEBSD) */
76 /* Operating system level dependencies for FreeBSD-like systems that */
77 /* should be used regardless of operating environment */
79 #define WTF_PLATFORM_FREEBSD 1
82 /* PLATFORM(OPENBSD) */
83 /* Operating system level dependencies for OpenBSD systems that */
84 /* should be used regardless of operating environment */
86 #define WTF_PLATFORM_OPENBSD 1
89 /* PLATFORM(SOLARIS) */
90 /* Operating system level dependencies for Solaris that should be used */
91 /* regardless of operating environment */
92 #if defined(sun) || defined(__sun)
93 #define WTF_PLATFORM_SOLARIS 1
96 #if defined (__S60__) || defined (__SYMBIAN32__)
97 /* we are cross-compiling, it is not really windows */
98 #undef WTF_PLATFORM_WIN_OS
99 #undef WTF_PLATFORM_WIN
100 #undef WTF_PLATFORM_CAIRO
101 #define WTF_PLATFORM_S60 1
102 #define WTF_PLATFORM_SYMBIAN 1
106 /* PLATFORM(NETBSD) */
107 /* Operating system level dependencies for NetBSD that should be used */
108 /* regardless of operating environment */
109 #if defined(__NetBSD__)
110 #define WTF_PLATFORM_NETBSD 1
114 /* Operating system level dependencies for Unix-like systems that */
115 /* should be used regardless of operating environment */
116 #if PLATFORM(DARWIN) \
117 || PLATFORM(FREEBSD) \
119 || PLATFORM(NETBSD) \
122 || defined(__unix__) \
124 #define WTF_PLATFORM_UNIX 1
127 /* Operating environments */
129 /* PLATFORM(CHROMIUM) */
134 #if defined(BUILDING_CHROMIUM__)
135 #define WTF_PLATFORM_CHROMIUM 1
136 #elif defined(BUILDING_QT__)
137 #define WTF_PLATFORM_QT 1
140 #if defined(BUILDING_KDE__)
141 #define WTF_PLATFORM_KDE 1
144 #elif defined(BUILDING_WX__)
145 #define WTF_PLATFORM_WX 1
146 #elif defined(BUILDING_GTK__)
147 #define WTF_PLATFORM_GTK 1
148 #elif PLATFORM(DARWIN)
149 #define WTF_PLATFORM_MAC 1
150 #elif PLATFORM(WIN_OS)
151 #define WTF_PLATFORM_WIN 1
154 /* PLATFORM(IPHONE) */
155 #if (defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
156 #define WTF_PLATFORM_IPHONE 1
159 /* PLATFORM(IPHONE_SIMULATOR) */
160 #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
161 #define WTF_PLATFORM_IPHONE 1
162 #define WTF_PLATFORM_IPHONE_SIMULATOR 1
164 #define WTF_PLATFORM_IPHONE_SIMULATOR 0
167 #if !defined(WTF_PLATFORM_IPHONE)
168 #define WTF_PLATFORM_IPHONE 0
171 /* Graphics engines */
173 /* PLATFORM(CG) and PLATFORM(CI) */
174 #define WTF_PLATFORM_CG 1
176 /* PLATFORM(SKIA) for Win/Linux, CG/CI for Mac */
177 #if PLATFORM(CHROMIUM)
179 #define WTF_PLATFORM_CG 1
180 #define WTF_PLATFORM_CI 1
181 #define WTF_USE_ATSUI 1
183 #define WTF_PLATFORM_SKIA 1
187 /* Makes PLATFORM(WIN) default to PLATFORM(CAIRO) */
188 /* FIXME: This should be changed from a blacklist to a whitelist */
189 #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM)
190 #define WTF_PLATFORM_CAIRO 1
196 #if defined(__ppc__) \
197 || defined(__PPC__) \
198 || defined(__powerpc__) \
199 || defined(__powerpc) \
200 || defined(__POWERPC__) \
203 #define WTF_PLATFORM_PPC 1
204 #define WTF_PLATFORM_BIG_ENDIAN 1
207 /* PLATFORM(PPC64) */
208 #if defined(__ppc64__) \
209 || defined(__PPC64__)
210 #define WTF_PLATFORM_PPC64 1
211 #define WTF_PLATFORM_BIG_ENDIAN 1
217 #define WTF_PLATFORM_ARM 1
218 #if defined(__ARMEB__)
219 #define WTF_PLATFORM_BIG_ENDIAN 1
220 #elif !defined(__ARM_EABI__) && !defined(__ARMEB__) && !defined(__VFP_FP__)
221 #define WTF_PLATFORM_MIDDLE_ENDIAN 1
223 #if !defined(__ARM_EABI__)
224 #define WTF_PLATFORM_FORCE_PACK 1
226 #define ARM_ARCH_VERSION 3
227 #if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__)
228 #undef ARM_ARCH_VERSION
229 #define ARM_ARCH_VERSION 4
231 #if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
232 || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
233 || defined(__ARM_ARCH_5TEJ__)
234 #undef ARM_ARCH_VERSION
235 #define ARM_ARCH_VERSION 5
237 #if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
238 || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
239 || defined(__ARM_ARCH_6ZK__)
240 #undef ARM_ARCH_VERSION
241 #define ARM_ARCH_VERSION 6
243 #if defined(__ARM_ARCH_7A__)
244 #undef ARM_ARCH_VERSION
245 #define ARM_ARCH_VERSION 7
248 #define PLATFORM_ARM_ARCH(N) (PLATFORM(ARM) && ARM_ARCH_VERSION >= N)
251 #if defined(__i386__) \
253 || defined(_M_IX86) \
255 || defined(__THW_INTEL)
256 #define WTF_PLATFORM_X86 1
259 /* PLATFORM(X86_64) */
260 #if defined(__x86_64__) \
262 #define WTF_PLATFORM_X86_64 1
267 #define WTF_PLATFORM_SH4 1
270 /* PLATFORM(SPARC64) */
271 #if defined(__sparc64__)
272 #define WTF_PLATFORM_SPARC64 1
273 #define WTF_PLATFORM_BIG_ENDIAN 1
276 /* PLATFORM(WINCE) && PLATFORM(QT)
277 We can not determine the endianess at compile time. For
278 Qt for Windows CE the endianess is specified in the
279 device specific makespec
281 #if PLATFORM(WINCE) && PLATFORM(QT)
283 # undef WTF_PLATFORM_BIG_ENDIAN
284 # undef WTF_PLATFORM_MIDDLE_ENDIAN
285 # if Q_BYTE_ORDER == Q_BIG_EDIAN
286 # define WTF_PLATFORM_BIG_ENDIAN 1
293 #if defined(_MSC_VER)
294 #define WTF_COMPILER_MSVC 1
296 #define WTF_COMPILER_MSVC7 1
301 #if defined(__CC_ARM) || defined(__ARMCC__)
302 #define WTF_COMPILER_RVCT 1
306 /* --gnu option of the RVCT compiler also defines __GNUC__ */
307 #if defined(__GNUC__) && !COMPILER(RVCT)
308 #define WTF_COMPILER_GCC 1
311 /* COMPILER(MINGW) */
312 #if defined(MINGW) || defined(__MINGW32__)
313 #define WTF_COMPILER_MINGW 1
316 /* COMPILER(BORLAND) */
317 /* not really fully supported - is this relevant any more? */
318 #if defined(__BORLANDC__)
319 #define WTF_COMPILER_BORLAND 1
322 /* COMPILER(CYGWIN) */
323 /* not really fully supported - is this relevant any more? */
324 #if defined(__CYGWIN__)
325 #define WTF_COMPILER_CYGWIN 1
328 /* COMPILER(WINSCW) */
329 #if defined(__WINSCW__)
330 #define WTF_COMPILER_WINSCW 1
333 #if (PLATFORM(IPHONE) || PLATFORM(MAC) || PLATFORM(WIN)) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
334 #define ENABLE_JSC_MULTIPLE_THREADS 1
337 /* for Unicode, KDE uses Qt */
338 #if PLATFORM(KDE) || PLATFORM(QT)
339 #define WTF_USE_QT4_UNICODE 1
340 #elif PLATFORM(SYMBIAN)
341 #define WTF_USE_SYMBIAN_UNICODE 1
343 /* The GTK+ Unicode backend is configurable */
345 #define WTF_USE_ICU_UNICODE 1
349 #if PLATFORM(CHROMIUM) && PLATFORM(DARWIN)
350 #define WTF_PLATFORM_CF 1
351 #define WTF_USE_PTHREADS 1
354 #define DONT_FINALIZE_ON_MAIN_THREAD 1
355 #define ENABLE_CONTEXT_MENUS 0
356 #define ENABLE_DRAG_SUPPORT 0
357 #define ENABLE_FTPDIR 1
358 #define ENABLE_GEOLOCATION 1
359 #define ENABLE_ICONDATABASE 0
360 #define ENABLE_INSPECTOR 0
362 #define ENABLE_MAC_JAVA_BRIDGE 0
363 #define ENABLE_NETSCAPE_PLUGIN_API 0
364 #define ENABLE_ORIENTATION_EVENTS 1
365 #define ENABLE_REPAINT_THROTTLING 1
366 #define ENABLE_RESPECT_EXIF_ORIENTATION 1
367 #define HAVE_READLINE 1
368 #define HAVE_RUNLOOP_TIMER 0
369 #define WTF_PLATFORM_CF 1
370 #define WTF_USE_PTHREADS 1
373 #define WTF_USE_WININET 1
377 #define ENABLE_ASSEMBLER 1
378 #define WTF_USE_CURL 1
379 #define WTF_USE_PTHREADS 1
384 #define WTF_USE_PTHREADS 1
388 #if !defined(HAVE_ACCESSIBILITY)
389 #define HAVE_ACCESSIBILITY 1
390 #endif /* !defined(HAVE_ACCESSIBILITY) */
392 #if PLATFORM(UNIX) && !PLATFORM(SYMBIAN)
393 #define HAVE_SIGNAL_H 1
398 #define HAVE_ERRNO_H 1
399 #define HAVE_LANGINFO_H 1
401 #define HAVE_MERGESORT 1
403 #define HAVE_STRINGS_H 1
404 #define HAVE_SYS_PARAM_H 1
405 #define HAVE_SYS_TIME_H 1
406 #define HAVE_SYS_TIMEB_H 1
409 #define HAVE_MADV_FREE 1
411 #elif PLATFORM(WIN_OS)
413 #define HAVE_FLOAT_H 1
415 #define HAVE_ERRNO_H 0
417 #define HAVE_SYS_TIMEB_H 1
419 #define HAVE_VIRTUALALLOC 1
421 #elif PLATFORM(SYMBIAN)
423 #define HAVE_ERRNO_H 1
427 #define HAVE_SYS_TIME_H 1
428 #define HAVE_STRINGS_H 1
431 #define HAVE_SYS_PARAM_H 1
436 /* FIXME: is this actually used or do other platforms generate their own config.h? */
438 #define HAVE_ERRNO_H 1
439 #define HAVE_LANGINFO_H 1
442 #define HAVE_STRINGS_H 1
443 #define HAVE_SYS_PARAM_H 1
444 #define HAVE_SYS_TIME_H 1
448 /* ENABLE macro defaults */
450 /* fastMalloc match validation allows for runtime verification that
451 new is matched by delete, fastMalloc is matched by fastFree, etc. */
452 #if !defined(ENABLE_FAST_MALLOC_MATCH_VALIDATION)
453 #define ENABLE_FAST_MALLOC_MATCH_VALIDATION 0
456 #if !defined(ENABLE_ICONDATABASE)
457 #define ENABLE_ICONDATABASE 1
460 #if !defined(ENABLE_DATABASE)
461 #define ENABLE_DATABASE 1
464 #if !defined(ENABLE_JAVASCRIPT_DEBUGGER)
465 #define ENABLE_JAVASCRIPT_DEBUGGER 1
468 #if !defined(ENABLE_FTPDIR)
469 #define ENABLE_FTPDIR 1
472 #if !defined(ENABLE_DASHBOARD_SUPPORT)
473 #define ENABLE_DASHBOARD_SUPPORT 0
476 #if !defined(ENABLE_CONTEXT_MENUS)
477 #define ENABLE_CONTEXT_MENUS 1
480 #if !defined(ENABLE_DRAG_SUPPORT)
481 #define ENABLE_DRAG_SUPPORT 1
484 #if !defined(ENABLE_INSPECTOR)
485 #define ENABLE_INSPECTOR 1
488 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
489 #define ENABLE_MAC_JAVA_BRIDGE 0
492 #if !defined(ENABLE_NETSCAPE_PLUGIN_API)
493 #define ENABLE_NETSCAPE_PLUGIN_API 1
496 #if !defined(WTF_USE_PLUGIN_HOST_PROCESS)
497 #define WTF_USE_PLUGIN_HOST_PROCESS 0
500 #if !defined(ENABLE_ORIENTATION_EVENTS)
501 #define ENABLE_ORIENTATION_EVENTS 0
504 #if !defined(ENABLE_RESPECT_EXIF_ORIENTATION)
505 #define ENABLE_RESPECT_EXIF_ORIENTATION 0
508 #if !defined(ENABLE_OPCODE_STATS)
509 #define ENABLE_OPCODE_STATS 0
512 #define ENABLE_SAMPLING_COUNTERS 0
513 #define ENABLE_SAMPLING_FLAGS 0
514 #define ENABLE_OPCODE_SAMPLING 0
515 #define ENABLE_CODEBLOCK_SAMPLING 0
516 #if ENABLE(CODEBLOCK_SAMPLING) && !ENABLE(OPCODE_SAMPLING)
517 #error "CODEBLOCK_SAMPLING requires OPCODE_SAMPLING"
519 #if ENABLE(OPCODE_SAMPLING) || ENABLE(SAMPLING_FLAGS)
520 #define ENABLE_SAMPLING_THREAD 1
523 #if !defined(ENABLE_GEOLOCATION)
524 #define ENABLE_GEOLOCATION 0
527 #if !defined(ENABLE_TEXT_CARET)
528 #define ENABLE_TEXT_CARET 1
531 #if !defined(ENABLE_ON_FIRST_TEXTAREA_FOCUS_SELECT_ALL)
532 #define ENABLE_ON_FIRST_TEXTAREA_FOCUS_SELECT_ALL 0
535 #if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64)
536 #if PLATFORM(X86_64) && PLATFORM(MAC)
537 #define WTF_USE_JSVALUE64 1
538 #elif PLATFORM(PPC64) || PLATFORM(QT) || (PLATFORM(IPHONE) && PLATFORM_ARM_ARCH(6) && !defined(__llvm__))
539 // FIXME: <rdar://problem/7478149> gcc-4.2 compiler bug with USE(JSVALUE32_64) and armv6 target
540 #define WTF_USE_JSVALUE32 1
542 #define WTF_USE_JSVALUE32_64 1
544 #endif // !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32) && !defined(WTF_USE_JSVALUE32_64)
546 #if !defined(ENABLE_REPAINT_THROTTLING)
547 #define ENABLE_REPAINT_THROTTLING 0
550 #if !defined(ENABLE_JIT)
551 /* The JIT is tested & working on x86_64 Mac */
552 #if PLATFORM(X86_64) && PLATFORM(MAC)
554 /* The JIT is tested & working on x86 Mac */
555 #elif PLATFORM(X86) && PLATFORM(MAC)
557 #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
558 #elif PLATFORM_ARM_ARCH(7) && PLATFORM(IPHONE)
559 /* Under development, temporarily disabled until 16Mb link range limit in assembler is fixed. */
561 #define ENABLE_JIT_OPTIMIZE_NATIVE_CALL 0
562 /* The JIT is tested & working on x86 Windows */
563 #elif PLATFORM(X86) && PLATFORM(WIN)
569 #ifndef ENABLE_JIT_OPTIMIZE_CALL
570 #define ENABLE_JIT_OPTIMIZE_CALL 1
572 #ifndef ENABLE_JIT_OPTIMIZE_NATIVE_CALL
573 #define ENABLE_JIT_OPTIMIZE_NATIVE_CALL 1
575 #ifndef ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS
576 #define ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS 1
578 #ifndef ENABLE_JIT_OPTIMIZE_METHOD_CALLS
579 #define ENABLE_JIT_OPTIMIZE_METHOD_CALLS 1
583 #if PLATFORM(X86) && COMPILER(MSVC)
584 #define JSC_HOST_CALL __fastcall
585 #elif PLATFORM(X86) && COMPILER(GCC)
586 #define JSC_HOST_CALL __attribute__ ((fastcall))
588 #define JSC_HOST_CALL
591 #if COMPILER(GCC) && !ENABLE(JIT)
592 #define HAVE_COMPUTED_GOTO 1
595 #if ENABLE(JIT) && defined(COVERAGE)
596 #define WTF_USE_INTERPRETER 0
598 #define WTF_USE_INTERPRETER 1
601 /* Yet Another Regex Runtime. */
602 /* YARR supports x86 & x86-64, and has been tested on Mac and Windows. */
603 #if (!defined(ENABLE_YARR_JIT) && PLATFORM(X86) && PLATFORM(MAC)) \
604 || (!defined(ENABLE_YARR_JIT) && PLATFORM(X86_64) && PLATFORM(MAC)) \
605 /* Under development, temporarily disabled until 16Mb link range limit in assembler is fixed. */ \
606 || (!defined(ENABLE_YARR_JIT) && PLATFORM_ARM_ARCH(7) && PLATFORM(IPHONE) && 0) \
607 || (!defined(ENABLE_YARR_JIT) && PLATFORM(X86) && PLATFORM(WIN))
608 #define ENABLE_YARR 1
609 #define ENABLE_YARR_JIT 1
612 #if ENABLE(YARR_JIT) && !ENABLE(YARR)
613 #error "YARR_JIT requires YARR"
616 #if ENABLE(JIT) || ENABLE(YARR_JIT)
617 #define ENABLE_ASSEMBLER 1
619 /* Setting this flag prevents the assembler from using RWX memory; this may improve
620 security but currectly comes at a significant performance cost. */
621 #if PLATFORM_ARM_ARCH(7) && PLATFORM(IPHONE)
622 #define ENABLE_ASSEMBLER_WX_EXCLUSIVE 1
624 #define ENABLE_ASSEMBLER_WX_EXCLUSIVE 0
627 #if !defined(ENABLE_PAN_SCROLLING) && PLATFORM(WIN_OS)
628 #define ENABLE_PAN_SCROLLING 1
631 #if !defined(ENABLE_ACTIVEX_TYPE_CONVERSION_WMPLAYER)
632 #define ENABLE_ACTIVEX_TYPE_CONVERSION_WMPLAYER 1
635 /* Use the QtXmlStreamReader implementation for XMLTokenizer */
638 #define WTF_USE_QXMLSTREAM 1
643 #define WTF_USE_FONT_FAST_PATH 1
646 /* Accelerated compositing */
648 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
649 #define WTF_USE_ACCELERATED_COMPOSITING 1
653 #define WTF_USE_ACCELERATED_COMPOSITING 1
655 #endif /* WTF_Platform_h */