]> git.saurik.com Git - apple/javascriptcore.git/blob - wtf/Platform.h
JavaScriptCore-525.tar.gz
[apple/javascriptcore.git] / wtf / Platform.h
1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
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.
12 *
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.
24 */
25
26 #ifndef WTF_Platform_h
27 #define WTF_Platform_h
28
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)
35
36 /* Operating systems - low-level dependencies */
37
38 /* PLATFORM(DARWIN) */
39 /* Operating system level dependencies for Mac OS X / Darwin that should */
40 /* be used regardless of operating environment */
41 #ifdef __APPLE__
42 #define WTF_PLATFORM_DARWIN 1
43 #include <TargetConditionals.h>
44 #endif
45
46 /* PLATFORM(WIN_OS) */
47 /* Operating system level dependencies for Windows that should be used */
48 /* regardless of operating environment */
49 #if defined(WIN32) || defined(_WIN32)
50 #define WTF_PLATFORM_WIN_OS 1
51 #endif
52
53 /* PLATFORM(WIN_CE) */
54 /* Operating system level dependencies for Windows CE that should be used */
55 /* regardless of operating environment */
56 /* Note that for this platform PLATFORM(WIN_OS) is also defined. */
57 #if defined(_WIN32_WCE)
58 #define WTF_PLATFORM_WIN_CE 1
59 #endif
60
61 /* PLATFORM(FREEBSD) */
62 /* Operating system level dependencies for FreeBSD-like systems that */
63 /* should be used regardless of operating environment */
64 #ifdef __FreeBSD__
65 #define WTF_PLATFORM_FREEBSD 1
66 #endif
67
68 /* PLATFORM(OPENBSD) */
69 /* Operating system level dependencies for OpenBSD systems that */
70 /* should be used regardless of operating environment */
71 #ifdef __OpenBSD__
72 #define WTF_PLATFORM_OPENBSD 1
73 #endif
74
75 /* PLATFORM(SOLARIS) */
76 /* Operating system level dependencies for Solaris that should be used */
77 /* regardless of operating environment */
78 #if defined(sun) || defined(__sun)
79 #define WTF_PLATFORM_SOLARIS 1
80 #endif
81
82 #if defined (__S60__) || defined (__SYMBIAN32__)
83 /* we are cross-compiling, it is not really windows */
84 #undef WTF_PLATFORM_WIN_OS
85 #undef WTF_PLATFORM_WIN
86 #undef WTF_PLATFORM_CAIRO
87 #define WTF_PLATFORM_S60 1
88 #define WTF_PLATFORM_SYMBIAN 1
89 #endif
90
91
92 /* PLATFORM(NETBSD) */
93 /* Operating system level dependencies for NetBSD that should be used */
94 /* regardless of operating environment */
95 #if defined(__NetBSD__)
96 #define WTF_PLATFORM_NETBSD 1
97 #endif
98
99 /* PLATFORM(UNIX) */
100 /* Operating system level dependencies for Unix-like systems that */
101 /* should be used regardless of operating environment */
102 #if PLATFORM(DARWIN) \
103 || PLATFORM(FREEBSD) \
104 || PLATFORM(S60) \
105 || PLATFORM(NETBSD) \
106 || defined(unix) \
107 || defined(__unix) \
108 || defined(__unix__) \
109 || defined(_AIX)
110 #define WTF_PLATFORM_UNIX 1
111 #endif
112
113 /* Operating environments */
114
115 /* PLATFORM(CHROMIUM) */
116 /* PLATFORM(QT) */
117 /* PLATFORM(GTK) */
118 /* PLATFORM(MAC) */
119 /* PLATFORM(WIN) */
120 #if defined(BUILDING_CHROMIUM__)
121 #define WTF_PLATFORM_CHROMIUM 1
122 #elif defined(BUILDING_QT__)
123 #define WTF_PLATFORM_QT 1
124
125 /* PLATFORM(KDE) */
126 #if defined(BUILDING_KDE__)
127 #define WTF_PLATFORM_KDE 1
128 #endif
129
130 #elif defined(BUILDING_WX__)
131 #define WTF_PLATFORM_WX 1
132 #elif defined(BUILDING_GTK__)
133 #define WTF_PLATFORM_GTK 1
134 #elif PLATFORM(DARWIN)
135 #define WTF_PLATFORM_MAC 1
136 #elif PLATFORM(WIN_OS)
137 #define WTF_PLATFORM_WIN 1
138 #endif
139
140 /* PLATFORM(IPHONE) */
141 #if TARGET_OS_EMBEDDED || TARGET_OS_IPHONE
142 #define WTF_PLATFORM_IPHONE 1
143 #endif
144
145 /* PLATFORM(IPHONE_SIMULATOR) */
146 #if TARGET_IPHONE_SIMULATOR
147 #define WTF_PLATFORM_IPHONE 1
148 #define WTF_PLATFORM_IPHONE_SIMULATOR 1
149 #else
150 #define WTF_PLATFORM_IPHONE_SIMULATOR 0
151 #endif
152
153 #if !defined(WTF_PLATFORM_IPHONE)
154 #define WTF_PLATFORM_IPHONE 0
155 #endif
156
157 /* Graphics engines */
158
159 /* PLATFORM(CG) and PLATFORM(CI) */
160 #define WTF_PLATFORM_CG 1
161
162 /* PLATFORM(SKIA) for Win/Linux, CG/CI for Mac */
163 #if PLATFORM(CHROMIUM)
164 #if PLATFORM(DARWIN)
165 #define WTF_PLATFORM_CG 1
166 #define WTF_PLATFORM_CI 1
167 #define WTF_USE_ATSUI 1
168 #else
169 #define WTF_PLATFORM_SKIA 1
170 #endif
171 #endif
172
173 /* Makes PLATFORM(WIN) default to PLATFORM(CAIRO) */
174 /* FIXME: This should be changed from a blacklist to a whitelist */
175 #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM)
176 #define WTF_PLATFORM_CAIRO 1
177 #endif
178
179 /* CPU */
180
181 /* PLATFORM(PPC) */
182 #if defined(__ppc__) \
183 || defined(__PPC__) \
184 || defined(__powerpc__) \
185 || defined(__powerpc) \
186 || defined(__POWERPC__) \
187 || defined(_M_PPC) \
188 || defined(__PPC)
189 #define WTF_PLATFORM_PPC 1
190 #define WTF_PLATFORM_BIG_ENDIAN 1
191 #endif
192
193 /* PLATFORM(PPC64) */
194 #if defined(__ppc64__) \
195 || defined(__PPC64__)
196 #define WTF_PLATFORM_PPC64 1
197 #define WTF_PLATFORM_BIG_ENDIAN 1
198 #endif
199
200 /* PLATFORM(ARM) */
201 #if defined(arm) \
202 || defined(__arm__)
203 #define WTF_PLATFORM_ARM 1
204 #if defined(__ARMEB__)
205 #define WTF_PLATFORM_BIG_ENDIAN 1
206 #elif !defined(__ARM_EABI__) && !defined(__ARMEB__) && !defined(__VFP_FP__)
207 #define WTF_PLATFORM_MIDDLE_ENDIAN 1
208 #endif
209 #if !defined(__ARM_EABI__)
210 #define WTF_PLATFORM_FORCE_PACK 1
211 #endif
212 #endif
213
214 /* PLATFORM(X86) */
215 #if defined(__i386__) \
216 || defined(i386) \
217 || defined(_M_IX86) \
218 || defined(_X86_) \
219 || defined(__THW_INTEL)
220 #define WTF_PLATFORM_X86 1
221 #endif
222
223 /* PLATFORM(X86_64) */
224 #if defined(__x86_64__) \
225 || defined(__ia64__) \
226 || defined(_M_X64)
227 #define WTF_PLATFORM_X86_64 1
228 #endif
229
230 /* PLATFORM(SPARC64) */
231 #if defined(__sparc64__)
232 #define WTF_PLATFORM_SPARC64 1
233 #define WTF_PLATFORM_BIG_ENDIAN 1
234 #endif
235
236 /* PLATFORM(WIN_CE) && PLATFORM(QT)
237 We can not determine the endianess at compile time. For
238 Qt for Windows CE the endianess is specified in the
239 device specific makespec
240 */
241 #if PLATFORM(WIN_CE) && PLATFORM(QT)
242 # include <QtGlobal>
243 # undef WTF_PLATFORM_BIG_ENDIAN
244 # undef WTF_PLATFORM_MIDDLE_ENDIAN
245 # if Q_BYTE_ORDER == Q_BIG_EDIAN
246 # define WTF_PLATFORM_BIG_ENDIAN 1
247 # endif
248 #endif
249
250 /* Compiler */
251
252 /* COMPILER(MSVC) */
253 #if defined(_MSC_VER)
254 #define WTF_COMPILER_MSVC 1
255 #if _MSC_VER < 1400
256 #define WTF_COMPILER_MSVC7 1
257 #endif
258 #endif
259
260 /* COMPILER(GCC) */
261 #if defined(__GNUC__)
262 #define WTF_COMPILER_GCC 1
263 #endif
264
265 /* COMPILER(MINGW) */
266 #if defined(MINGW) || defined(__MINGW32__)
267 #define WTF_COMPILER_MINGW 1
268 #endif
269
270 /* COMPILER(BORLAND) */
271 /* not really fully supported - is this relevant any more? */
272 #if defined(__BORLANDC__)
273 #define WTF_COMPILER_BORLAND 1
274 #endif
275
276 /* COMPILER(CYGWIN) */
277 /* not really fully supported - is this relevant any more? */
278 #if defined(__CYGWIN__)
279 #define WTF_COMPILER_CYGWIN 1
280 #endif
281
282 /* COMPILER(RVCT) */
283 #if defined(__CC_ARM) || defined(__ARMCC__)
284 #define WTF_COMPILER_RVCT 1
285 #endif
286
287 /* COMPILER(WINSCW) */
288 #if defined(__WINSCW__)
289 #define WTF_COMPILER_WINSCW 1
290 #endif
291
292 #if (PLATFORM(IPHONE) || PLATFORM(MAC) || PLATFORM(WIN)) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
293 #define ENABLE_JSC_MULTIPLE_THREADS 1
294 #endif
295
296 /* for Unicode, KDE uses Qt */
297 #if PLATFORM(KDE) || PLATFORM(QT)
298 #define WTF_USE_QT4_UNICODE 1
299 #elif PLATFORM(SYMBIAN)
300 #define WTF_USE_SYMBIAN_UNICODE 1
301 #elif PLATFORM(GTK)
302 /* The GTK+ Unicode backend is configurable */
303 #else
304 #define WTF_USE_ICU_UNICODE 1
305 #endif
306
307
308 #if PLATFORM(CHROMIUM) && PLATFORM(DARWIN)
309 #define WTF_PLATFORM_CF 1
310 #define WTF_USE_PTHREADS 1
311 #endif
312
313 #define WTF_PLATFORM_CF 1
314 #define WTF_USE_PTHREADS 1
315 #define ENABLE_FTPDIR 1
316 #define ENABLE_JIT 0
317 #define ENABLE_MAC_JAVA_BRIDGE 0
318 #define ENABLE_ICONDATABASE 0
319 #define ENABLE_TOUCH_EVENTS 1
320 #define ENABLE_IPHONE_PPT 1
321 #define ENABLE_GEOLOCATION 1
322 #define ENABLE_NETSCAPE_PLUGIN_API 0
323 #define HAVE_READLINE 1
324 #define DONT_FINALIZE_ON_MAIN_THREAD 1
325 #define HAVE_MADV_FREE 1
326 #define ENABLE_REPAINT_THROTTLING 1
327 #define ENABLE_RESPECT_EXIF_ORIENTATION 1
328
329 #if PLATFORM(WIN)
330 #define WTF_USE_WININET 1
331 #endif
332
333 #if PLATFORM(WX)
334 #define WTF_USE_CURL 1
335 #define WTF_USE_PTHREADS 1
336 #endif
337
338 #if PLATFORM(GTK)
339 #if HAVE(PTHREAD_H)
340 #define WTF_USE_PTHREADS 1
341 #endif
342 #endif
343
344 #if !defined(HAVE_ACCESSIBILITY)
345 #define HAVE_ACCESSIBILITY 1
346 #endif /* !defined(HAVE_ACCESSIBILITY) */
347
348 #if COMPILER(GCC)
349 #define HAVE_COMPUTED_GOTO 1
350 #endif
351
352 #if PLATFORM(DARWIN)
353
354 #define HAVE_ERRNO_H 1
355 #define HAVE_MMAP 1
356 #define HAVE_MERGESORT 1
357 #define HAVE_SBRK 1
358 #define HAVE_STRINGS_H 1
359 #define HAVE_SYS_PARAM_H 1
360 #define HAVE_SYS_TIME_H 1
361 #define HAVE_SYS_TIMEB_H 1
362
363 #elif PLATFORM(WIN_OS)
364
365 #define HAVE_FLOAT_H 1
366 #if PLATFORM(WIN_CE)
367 #define HAVE_ERRNO_H 0
368 #else
369 #define HAVE_SYS_TIMEB_H 1
370 #endif
371 #define HAVE_VIRTUALALLOC 1
372
373 #elif PLATFORM(SYMBIAN)
374
375 #define HAVE_ERRNO_H 1
376 #define HAVE_MMAP 0
377 #define HAVE_SBRK 1
378
379 #define HAVE_SYS_TIME_H 1
380 #define HAVE_STRINGS_H 1
381
382 #if !COMPILER(RVCT)
383 #define HAVE_SYS_PARAM_H 1
384 #endif
385
386 #else
387
388 /* FIXME: is this actually used or do other platforms generate their own config.h? */
389
390 #define HAVE_ERRNO_H 1
391 #define HAVE_MMAP 1
392 #define HAVE_SBRK 1
393 #define HAVE_STRINGS_H 1
394 #define HAVE_SYS_PARAM_H 1
395 #define HAVE_SYS_TIME_H 1
396
397 #endif
398
399 /* ENABLE macro defaults */
400
401 #if !defined(ENABLE_ICONDATABASE)
402 #define ENABLE_ICONDATABASE 1
403 #endif
404
405 #if !defined(ENABLE_DATABASE)
406 #define ENABLE_DATABASE 1
407 #endif
408
409 #if !defined(ENABLE_JAVASCRIPT_DEBUGGER)
410 #define ENABLE_JAVASCRIPT_DEBUGGER 1
411 #endif
412
413 #if !defined(ENABLE_FTPDIR)
414 #define ENABLE_FTPDIR 1
415 #endif
416
417 #if !defined(ENABLE_DASHBOARD_SUPPORT)
418 #define ENABLE_DASHBOARD_SUPPORT 0
419 #endif
420
421 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
422 #define ENABLE_MAC_JAVA_BRIDGE 0
423 #endif
424
425 #if !defined(ENABLE_NETSCAPE_PLUGIN_API)
426 #define ENABLE_NETSCAPE_PLUGIN_API 1
427 #endif
428
429 #if !defined(ENABLE_RESPECT_EXIF_ORIENTATION)
430 #define ENABLE_RESPECT_EXIF_ORIENTATION 0
431 #endif
432
433 #if !defined(ENABLE_TOUCH_EVENTS)
434 #define ENABLE_TOUCH_EVENTS 0
435 #endif
436
437 #if !defined(ENABLE_IPHONE_PPT)
438 #define ENABLE_IPHONE_PPT 0
439 #endif
440
441 #if !defined(ENABLE_OPCODE_STATS)
442 #define ENABLE_OPCODE_STATS 0
443 #endif
444
445 #if !defined(ENABLE_CODEBLOCK_SAMPLING)
446 #define ENABLE_CODEBLOCK_SAMPLING 0
447 #endif
448
449 #if ENABLE(CODEBLOCK_SAMPLING) && !defined(ENABLE_OPCODE_SAMPLING)
450 #define ENABLE_OPCODE_SAMPLING 1
451 #endif
452
453 #if !defined(ENABLE_OPCODE_SAMPLING)
454 #define ENABLE_OPCODE_SAMPLING 0
455 #endif
456
457 #if !defined(ENABLE_GEOLOCATION)
458 #define ENABLE_GEOLOCATION 0
459 #endif
460
461 #if !defined(ENABLE_TEXT_CARET)
462 #define ENABLE_TEXT_CARET 1
463 #endif
464
465 #if !defined(WTF_USE_ALTERNATE_JSIMMEDIATE) && PLATFORM(X86_64) && PLATFORM(MAC)
466 #define WTF_USE_ALTERNATE_JSIMMEDIATE 1
467 #endif
468
469 #if !defined(ENABLE_REPAINT_THROTTLING)
470 #define ENABLE_REPAINT_THROTTLING 0
471 #endif
472
473 #if !defined(ENABLE_JIT)
474 /* x86-64 support is under development. */
475 #if PLATFORM(X86_64) && PLATFORM(MAC)
476 #define ENABLE_JIT 0
477 #define WTF_USE_JIT_STUB_ARGUMENT_REGISTER 1
478 /* The JIT is tested & working on x86 Mac */
479 #elif PLATFORM(X86) && PLATFORM(MAC)
480 #define ENABLE_JIT 1
481 #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 1
482 /* The JIT is tested & working on x86 Windows */
483 #elif PLATFORM(X86) && PLATFORM(WIN)
484 #define ENABLE_JIT 1
485 #define WTF_USE_JIT_STUB_ARGUMENT_REGISTER 1
486 #endif
487 #define ENABLE_JIT_OPTIMIZE_CALL 1
488 #define ENABLE_JIT_OPTIMIZE_PROPERTY_ACCESS 1
489 #define ENABLE_JIT_OPTIMIZE_ARITHMETIC 1
490 #endif
491
492 #if ENABLE(JIT)
493 #if !(USE(JIT_STUB_ARGUMENT_VA_LIST) || USE(JIT_STUB_ARGUMENT_REGISTER) || USE(JIT_STUB_ARGUMENT_STACK))
494 #error Please define one of the JIT_STUB_ARGUMENT settings.
495 #elif (USE(JIT_STUB_ARGUMENT_VA_LIST) && USE(JIT_STUB_ARGUMENT_REGISTER)) \
496 || (USE(JIT_STUB_ARGUMENT_VA_LIST) && USE(JIT_STUB_ARGUMENT_STACK)) \
497 || (USE(JIT_STUB_ARGUMENT_REGISTER) && USE(JIT_STUB_ARGUMENT_STACK))
498 #error Please do not define more than one of the JIT_STUB_ARGUMENT settings.
499 #endif
500 #endif
501
502 /* WREC supports x86 & x86-64, and has been tested on Mac and Windows ('cept on 64-bit on Mac). */
503 #if (!defined(ENABLE_WREC) && PLATFORM(X86) && PLATFORM(MAC)) \
504 || (!defined(ENABLE_WREC) && PLATFORM(X86_64) && PLATFORM(MAC)) \
505 || (!defined(ENABLE_WREC) && PLATFORM(X86) && PLATFORM(WIN))
506 #define ENABLE_WREC 1
507 #endif
508
509 #if ENABLE(JIT) || ENABLE(WREC)
510 #define ENABLE_ASSEMBLER 1
511 #endif
512
513 #if !defined(ENABLE_PAN_SCROLLING) && PLATFORM(WIN_OS)
514 #define ENABLE_PAN_SCROLLING 1
515 #endif
516
517 #if !defined(ENABLE_ACTIVEX_TYPE_CONVERSION_WMPLAYER)
518 #define ENABLE_ACTIVEX_TYPE_CONVERSION_WMPLAYER 1
519 #endif
520
521 /* Use the QtXmlStreamReader implementation for XMLTokenizer */
522 #if PLATFORM(QT)
523 #if !ENABLE(XSLT)
524 #define WTF_USE_QXMLSTREAM 1
525 #endif
526 #endif
527
528 #if !PLATFORM(QT)
529 #define WTF_USE_FONT_FAST_PATH 1
530 #endif
531
532 #endif /* WTF_Platform_h */