• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #endif
44 
45 /* PLATFORM(WIN_OS) */
46 /* Operating system level dependencies for Windows that should be used */
47 /* regardless of operating environment */
48 #if defined(WIN32) || defined(_WIN32)
49 #define WTF_PLATFORM_WIN_OS 1
50 #endif
51 
52 /* PLATFORM(WIN_CE) */
53 /* Operating system level dependencies for Windows CE that should be used */
54 /* regardless of operating environment */
55 /* Note that for this platform PLATFORM(WIN_OS) is also defined. */
56 #if defined(_WIN32_WCE)
57 #define WTF_PLATFORM_WIN_CE 1
58 #endif
59 
60 /* PLATFORM(FREEBSD) */
61 /* Operating system level dependencies for FreeBSD-like systems that */
62 /* should be used regardless of operating environment */
63 #ifdef __FreeBSD__
64 #define WTF_PLATFORM_FREEBSD 1
65 #endif
66 
67 /* PLATFORM(OPENBSD) */
68 /* Operating system level dependencies for OpenBSD systems that */
69 /* should be used regardless of operating environment */
70 #ifdef __OpenBSD__
71 #define WTF_PLATFORM_OPENBSD 1
72 #endif
73 
74 /* PLATFORM(SOLARIS) */
75 /* Operating system level dependencies for Solaris that should be used */
76 /* regardless of operating environment */
77 #if defined(sun) || defined(__sun)
78 #define WTF_PLATFORM_SOLARIS 1
79 #endif
80 
81 #if defined (__S60__) || defined (__SYMBIAN32__)
82 /* we are cross-compiling, it is not really windows */
83 #undef WTF_PLATFORM_WIN_OS
84 #undef WTF_PLATFORM_WIN
85 #undef WTF_PLATFORM_CAIRO
86 #define WTF_PLATFORM_S60 1
87 #define WTF_PLATFORM_SYMBIAN 1
88 #endif
89 
90 
91 /* PLATFORM(NETBSD) */
92 /* Operating system level dependencies for NetBSD that should be used */
93 /* regardless of operating environment */
94 #if defined(__NetBSD__)
95 #define WTF_PLATFORM_NETBSD 1
96 #endif
97 
98 /* PLATFORM(UNIX) */
99 /* Operating system level dependencies for Unix-like systems that */
100 /* should be used regardless of operating environment */
101 #if   PLATFORM(DARWIN)     \
102    || PLATFORM(FREEBSD)    \
103    || PLATFORM(S60)        \
104    || PLATFORM(NETBSD)     \
105    || defined(unix)        \
106    || defined(__unix)      \
107    || defined(__unix__)    \
108    || defined(_AIX)
109 #define WTF_PLATFORM_UNIX 1
110 #endif
111 
112 /* Operating environments */
113 
114 /* PLATFORM(CHROMIUM) */
115 /* PLATFORM(QT) */
116 /* PLATFORM(GTK) */
117 /* PLATFORM(MAC) */
118 /* PLATFORM(WIN) */
119 #if defined(BUILDING_CHROMIUM__)
120 #define WTF_PLATFORM_CHROMIUM 1
121 #elif defined(BUILDING_QT__)
122 #define WTF_PLATFORM_QT 1
123 
124 /* PLATFORM(KDE) */
125 #if defined(BUILDING_KDE__)
126 #define WTF_PLATFORM_KDE 1
127 #endif
128 
129 #elif defined(BUILDING_WX__)
130 #define WTF_PLATFORM_WX 1
131 #elif defined(BUILDING_GTK__)
132 #define WTF_PLATFORM_GTK 1
133 #elif PLATFORM(DARWIN)
134 #define WTF_PLATFORM_MAC 1
135 #elif PLATFORM(WIN_OS)
136 #define WTF_PLATFORM_WIN 1
137 #endif
138 
139 /* Graphics engines */
140 
141 /* PLATFORM(CG) and PLATFORM(CI) */
142 #if PLATFORM(MAC)
143 #define WTF_PLATFORM_CG 1
144 #define WTF_PLATFORM_CI 1
145 #endif
146 
147 /* PLATFORM(SKIA) for Win/Linux, CG/CI for Mac */
148 #if PLATFORM(CHROMIUM)
149 #if PLATFORM(DARWIN)
150 #define WTF_PLATFORM_CG 1
151 #define WTF_PLATFORM_CI 1
152 #define WTF_USE_ATSUI 1
153 #else
154 #define WTF_PLATFORM_SKIA 1
155 #endif
156 #endif
157 
158 /* Makes PLATFORM(WIN) default to PLATFORM(CAIRO) */
159 /* FIXME: This should be changed from a blacklist to a whitelist */
160 #if !PLATFORM(MAC) && !PLATFORM(QT) && !PLATFORM(WX) && !PLATFORM(CHROMIUM)
161 #define WTF_PLATFORM_CAIRO 1
162 #endif
163 
164 #ifdef ANDROID
165 #define WTF_PLATFORM_ANDROID 1
166 #define WTF_PLATFORM_LINUX 1
167 //due to pthread code in collector.cpp, we need PLATFORM(DARWIN)
168 //#undef WTF_PLATFORM_DARWIN
169 #undef WTF_PLATFORM_MAC
170 #undef WTF_PLATFORM_WIN_OS
171 #undef WTF_PLATFORM_WIN
172 #undef WTF_PLATFORM_CG
173 #undef WTF_PLATFORM_CI
174 #undef WTF_PLATFORM_CAIRO
175 #define WTF_USE_PTHREADS 1
176 
177 #define WTF_PLATFORM_SGL 1
178 #define WTF_PLATFORM_UNIX 1
179 
180 #define USE_SYSTEM_MALLOC 1
181 #define ENABLE_MAC_JAVA_BRIDGE 1
182 #define LOG_DISABLED 1
183 // Prevents Webkit from drawing the caret in textfields and textareas
184 // This prevents unnecessary invals.
185 #define ENABLE_TEXT_CARET 0
186 #endif // ANDROID
187 
188 /* CPU */
189 
190 /* PLATFORM(PPC) */
191 #if   defined(__ppc__)     \
192    || defined(__PPC__)     \
193    || defined(__powerpc__) \
194    || defined(__powerpc)   \
195    || defined(__POWERPC__) \
196    || defined(_M_PPC)      \
197    || defined(__PPC)
198 #define WTF_PLATFORM_PPC 1
199 #define WTF_PLATFORM_BIG_ENDIAN 1
200 #endif
201 
202 /* PLATFORM(PPC64) */
203 #if   defined(__ppc64__) \
204    || defined(__PPC64__)
205 #define WTF_PLATFORM_PPC64 1
206 #define WTF_PLATFORM_BIG_ENDIAN 1
207 #endif
208 
209 /* PLATFORM(ARM) */
210 #if   defined(arm) \
211    || defined(__arm__)
212 #define WTF_PLATFORM_ARM 1
213 #if defined(__ARMEB__)
214 #define WTF_PLATFORM_BIG_ENDIAN 1
215 #elif !defined(__ARM_EABI__) && !defined(__ARMEB__) && !defined(__VFP_FP__)
216 #if !defined(ANDROID)
217 #define WTF_PLATFORM_MIDDLE_ENDIAN 1
218 #endif
219 #endif
220 #if !defined(__ARM_EABI__)
221 #define WTF_PLATFORM_FORCE_PACK 1
222 #endif
223 #endif
224 
225 /* PLATFORM(X86) */
226 #if   defined(__i386__) \
227    || defined(i386)     \
228    || defined(_M_IX86)  \
229    || defined(_X86_)    \
230    || defined(__THW_INTEL)
231 #define WTF_PLATFORM_X86 1
232 #endif
233 
234 /* PLATFORM(X86_64) */
235 #if   defined(__x86_64__) \
236    || defined(__ia64__) \
237    || defined(_M_X64)
238 #define WTF_PLATFORM_X86_64 1
239 #endif
240 
241 /* PLATFORM(SPARC64) */
242 #if defined(__sparc64__)
243 #define WTF_PLATFORM_SPARC64 1
244 #define WTF_PLATFORM_BIG_ENDIAN 1
245 #endif
246 
247 /* PLATFORM(WIN_CE) && PLATFORM(QT)
248    We can not determine the endianess at compile time. For
249    Qt for Windows CE the endianess is specified in the
250    device specific makespec
251 */
252 #if PLATFORM(WIN_CE) && PLATFORM(QT)
253 #   include <QtGlobal>
254 #   undef WTF_PLATFORM_BIG_ENDIAN
255 #   undef WTF_PLATFORM_MIDDLE_ENDIAN
256 #   if Q_BYTE_ORDER == Q_BIG_EDIAN
257 #       define WTF_PLATFORM_BIG_ENDIAN 1
258 #   endif
259 #endif
260 
261 /* Compiler */
262 
263 /* COMPILER(MSVC) */
264 #if defined(_MSC_VER)
265 #define WTF_COMPILER_MSVC 1
266 #if _MSC_VER < 1400
267 #define WTF_COMPILER_MSVC7 1
268 #endif
269 #endif
270 
271 /* COMPILER(GCC) */
272 #if defined(__GNUC__)
273 #define WTF_COMPILER_GCC 1
274 #endif
275 
276 /* COMPILER(MINGW) */
277 #if defined(MINGW) || defined(__MINGW32__)
278 #define WTF_COMPILER_MINGW 1
279 #endif
280 
281 /* COMPILER(BORLAND) */
282 /* not really fully supported - is this relevant any more? */
283 #if defined(__BORLANDC__)
284 #define WTF_COMPILER_BORLAND 1
285 #endif
286 
287 /* COMPILER(CYGWIN) */
288 /* not really fully supported - is this relevant any more? */
289 #if defined(__CYGWIN__)
290 #define WTF_COMPILER_CYGWIN 1
291 #endif
292 
293 /* COMPILER(RVCT) */
294 #if defined(__CC_ARM) || defined(__ARMCC__)
295 #define WTF_COMPILER_RVCT 1
296 #endif
297 
298 /* COMPILER(WINSCW) */
299 #if defined(__WINSCW__)
300 #define WTF_COMPILER_WINSCW 1
301 #endif
302 
303 #if (PLATFORM(MAC) || PLATFORM(WIN)) && !defined(ENABLE_JSC_MULTIPLE_THREADS)
304 #define ENABLE_JSC_MULTIPLE_THREADS 1
305 #endif
306 
307 /* for Unicode, KDE uses Qt */
308 #if PLATFORM(KDE) || PLATFORM(QT)
309 #define WTF_USE_QT4_UNICODE 1
310 #elif PLATFORM(SYMBIAN)
311 #define WTF_USE_SYMBIAN_UNICODE 1
312 #elif PLATFORM(GTK)
313 /* The GTK+ Unicode backend is configurable */
314 #else
315 #define WTF_USE_ICU_UNICODE 1
316 #endif
317 
318 #if PLATFORM(MAC)
319 #define WTF_PLATFORM_CF 1
320 #define WTF_USE_PTHREADS 1
321 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
322 #define ENABLE_MAC_JAVA_BRIDGE 1
323 #endif
324 #if !defined(ENABLE_DASHBOARD_SUPPORT)
325 #define ENABLE_DASHBOARD_SUPPORT 1
326 #endif
327 #define HAVE_READLINE 1
328 #if !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
329 #define HAVE_DTRACE 1
330 #endif
331 #endif
332 
333 #if PLATFORM(CHROMIUM) && PLATFORM(DARWIN)
334 #define WTF_PLATFORM_CF 1
335 #define WTF_USE_PTHREADS 1
336 #endif
337 
338 #if PLATFORM(WIN)
339 #define WTF_USE_WININET 1
340 #endif
341 
342 #if PLATFORM(WX)
343 #define WTF_USE_CURL 1
344 #define WTF_USE_PTHREADS 1
345 #endif
346 
347 #if PLATFORM(GTK)
348 #if HAVE(PTHREAD_H)
349 #define WTF_USE_PTHREADS 1
350 #endif
351 #endif
352 
353 #if !defined(HAVE_ACCESSIBILITY)
354 #if PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(CHROMIUM)
355 #define HAVE_ACCESSIBILITY 1
356 #endif
357 #endif /* !defined(HAVE_ACCESSIBILITY) */
358 
359 #if COMPILER(GCC)
360 #define HAVE_COMPUTED_GOTO 1
361 #endif
362 
363 #if PLATFORM(DARWIN)
364 
365 #define HAVE_ERRNO_H 1
366 #define HAVE_MMAP 1
367 #define HAVE_MERGESORT 1
368 #define HAVE_SBRK 1
369 #define HAVE_STRINGS_H 1
370 #define HAVE_SYS_PARAM_H 1
371 #define HAVE_SYS_TIME_H 1
372 #define HAVE_SYS_TIMEB_H 1
373 
374 #elif PLATFORM(WIN_OS)
375 
376 #define HAVE_FLOAT_H 1
377 #if PLATFORM(WIN_CE)
378 #define HAVE_ERRNO_H 0
379 #else
380 #define HAVE_SYS_TIMEB_H 1
381 #endif
382 #define HAVE_VIRTUALALLOC 1
383 
384 #elif PLATFORM(SYMBIAN)
385 
386 #define HAVE_ERRNO_H 1
387 #define HAVE_MMAP 0
388 #define HAVE_SBRK 1
389 
390 #define HAVE_SYS_TIME_H 1
391 #define HAVE_STRINGS_H 1
392 
393 #if !COMPILER(RVCT)
394 #define HAVE_SYS_PARAM_H 1
395 #endif
396 
397 #else
398 
399 /* FIXME: is this actually used or do other platforms generate their own config.h? */
400 
401 #define HAVE_ERRNO_H 1
402 #define HAVE_MMAP 1
403 #define HAVE_SBRK 1
404 #define HAVE_STRINGS_H 1
405 #define HAVE_SYS_PARAM_H 1
406 #define HAVE_SYS_TIME_H 1
407 
408 #endif
409 
410 /* ENABLE macro defaults */
411 
412 #if !defined(ENABLE_ICONDATABASE)
413 #define ENABLE_ICONDATABASE 1
414 #endif
415 
416 #if !defined(ENABLE_DATABASE)
417 #define ENABLE_DATABASE 1
418 #endif
419 
420 #if !defined(ENABLE_JAVASCRIPT_DEBUGGER)
421 #define ENABLE_JAVASCRIPT_DEBUGGER 1
422 #endif
423 
424 #if !defined(ENABLE_FTPDIR)
425 #define ENABLE_FTPDIR 1
426 #endif
427 
428 #if !defined(ENABLE_DASHBOARD_SUPPORT)
429 #define ENABLE_DASHBOARD_SUPPORT 0
430 #endif
431 
432 #if !defined(ENABLE_MAC_JAVA_BRIDGE)
433 #define ENABLE_MAC_JAVA_BRIDGE 0
434 #endif
435 
436 #if !defined(ENABLE_NETSCAPE_PLUGIN_API)
437 #define ENABLE_NETSCAPE_PLUGIN_API 1
438 #endif
439 
440 #if !defined(ENABLE_OPCODE_STATS)
441 #define ENABLE_OPCODE_STATS 0
442 #endif
443 
444 #if !defined(ENABLE_CODEBLOCK_SAMPLING)
445 #define ENABLE_CODEBLOCK_SAMPLING 0
446 #endif
447 
448 #if ENABLE(CODEBLOCK_SAMPLING) && !defined(ENABLE_OPCODE_SAMPLING)
449 #define ENABLE_OPCODE_SAMPLING 1
450 #endif
451 
452 #if !defined(ENABLE_OPCODE_SAMPLING)
453 #define ENABLE_OPCODE_SAMPLING 0
454 #endif
455 
456 #if !defined(ENABLE_GEOLOCATION)
457 #define ENABLE_GEOLOCATION 0
458 #endif
459 
460 #if !defined(ENABLE_TEXT_CARET)
461 #define ENABLE_TEXT_CARET 1
462 #endif
463 
464 // ANDROID addition: allow web archive to be disabled
465 #if !defined(ENABLE_ARCHIVE)
466 #define ENABLE_ARCHIVE 1
467 #endif
468 
469 #if !defined(WTF_USE_ALTERNATE_JSIMMEDIATE) && PLATFORM(X86_64) && PLATFORM(MAC)
470 #define WTF_USE_ALTERNATE_JSIMMEDIATE 1
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 */
533