1/*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2013 Apple Inc. All rights reserved.
3 * Copyright (C) 2007-2009 Torch Mobile, Inc.
4 * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
5 * Copyright (C) 2018 The Qt Company Ltd.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef WTF_Platform_h
30#define WTF_Platform_h
31
32#if defined(__cplusplus)
33#include <private/qv4global_p.h>
34#endif
35
36/* Include compiler specific macros */
37#include <wtf/Compiler.h>
38
39/* ==== PLATFORM handles OS, operating environment, graphics API, and
40 CPU. This macro will be phased out in favor of platform adaptation
41 macros, policy decision macros, and top-level port definitions. ==== */
42#define PLATFORM(WTF_FEATURE) WTF_PLATFORM_##WTF_FEATURE
43
44
45/* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
46
47/* CPU() - the target CPU architecture */
48#define CPU(WTF_FEATURE) WTF_CPU_##WTF_FEATURE
49/* HAVE() - specific system features (headers, functions or similar) that are present or not */
50#define HAVE(WTF_FEATURE) HAVE_##WTF_FEATURE
51/* OS() - underlying operating system; only to be used for mandated low-level services like
52 virtual memory, not to choose a GUI toolkit */
53#define OS(WTF_FEATURE) WTF_OS_##WTF_FEATURE
54
55
56/* ==== Policy decision macros: these define policy choices for a particular port. ==== */
57
58/* USE() - use a particular third-party library or optional OS service */
59#define USE(WTF_FEATURE) WTF_USE_##WTF_FEATURE
60/* ENABLE() - turn on a specific feature of WebKit */
61#define ENABLE(WTF_FEATURE) ENABLE_##WTF_FEATURE
62
63
64/* ==== CPU() - the target CPU architecture ==== */
65
66/* This also defines CPU(BIG_ENDIAN) or CPU(MIDDLE_ENDIAN) or neither, as appropriate. */
67
68/* CPU(ALPHA) - DEC Alpha */
69#if defined(__alpha__)
70#define WTF_CPU_ALPHA 1
71#endif
72
73/* CPU(IA64) - Itanium / IA-64 */
74#if defined(__ia64__)
75#define WTF_CPU_IA64 1
76/* 32-bit mode on Itanium */
77#if !defined(__LP64__)
78#define WTF_CPU_IA64_32 1
79#endif
80#endif
81
82/* CPU(MIPS) - MIPS 32-bit */
83/* Note: Only O32 ABI is tested, so we enable it for O32 ABI for now. */
84#if (defined(mips) || defined(__mips__) || defined(MIPS) || defined(_MIPS_)) \
85 && defined(_ABIO32)
86#define WTF_CPU_MIPS 1
87#if defined(__MIPSEB__)
88#define WTF_CPU_BIG_ENDIAN 1
89#endif
90#define WTF_MIPS_PIC (defined __PIC__)
91#define WTF_MIPS_ARCH __mips
92#define WTF_MIPS_ISA(v) (defined WTF_MIPS_ARCH && WTF_MIPS_ARCH == v)
93#define WTF_MIPS_ISA_AT_LEAST(v) (defined WTF_MIPS_ARCH && WTF_MIPS_ARCH >= v)
94#define WTF_MIPS_ARCH_REV __mips_isa_rev
95#define WTF_MIPS_ISA_REV(v) (defined WTF_MIPS_ARCH_REV && WTF_MIPS_ARCH_REV == v)
96#define WTF_MIPS_DOUBLE_FLOAT (defined __mips_hard_float && !defined __mips_single_float)
97#define WTF_MIPS_FP64 (defined __mips_fpr && __mips_fpr == 64)
98/* MIPS requires allocators to use aligned memory */
99#define WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
100#endif /* MIPS */
101
102/* CPU(PPC) - PowerPC 32-bit */
103#if defined(__ppc__) \
104 || defined(__PPC__) \
105 || defined(__powerpc__) \
106 || defined(__powerpc) \
107 || defined(__POWERPC__) \
108 || defined(_M_PPC) \
109 || defined(__PPC)
110#define WTF_CPU_PPC 1
111#define WTF_CPU_BIG_ENDIAN 1
112#endif
113
114/* CPU(PPC64) - PowerPC 64-bit */
115#if defined(__ppc64__) \
116 || defined(__PPC64__)
117#define WTF_CPU_PPC64 1
118#define WTF_CPU_BIG_ENDIAN 1
119#endif
120
121/* CPU(SH4) - SuperH SH-4 */
122#if defined(__SH4__)
123#define WTF_CPU_SH4 1
124#endif
125
126/* CPU(SPARC32) - SPARC 32-bit */
127#if defined(__sparc) && !defined(__arch64__) || defined(__sparcv8)
128#define WTF_CPU_SPARC32 1
129#define WTF_CPU_BIG_ENDIAN 1
130#endif
131
132/* CPU(SPARC64) - SPARC 64-bit */
133#if defined(__sparc__) && defined(__arch64__) || defined (__sparcv9)
134#define WTF_CPU_SPARC64 1
135#define WTF_CPU_BIG_ENDIAN 1
136#endif
137
138/* CPU(SPARC) - any SPARC, true for CPU(SPARC32) and CPU(SPARC64) */
139#if CPU(SPARC32) || CPU(SPARC64)
140#define WTF_CPU_SPARC 1
141#endif
142
143/* CPU(S390X) - S390 64-bit */
144#if defined(__s390x__)
145#define WTF_CPU_S390X 1
146#define WTF_CPU_BIG_ENDIAN 1
147#endif
148
149/* CPU(S390) - S390 32-bit */
150#if defined(__s390__)
151#define WTF_CPU_S390 1
152#define WTF_CPU_BIG_ENDIAN 1
153#endif
154
155/* CPU(X86) - i386 / x86 32-bit */
156#if defined(__i386__) \
157 || defined(i386) \
158 || defined(_M_IX86) \
159 || defined(_X86_) \
160 || defined(__THW_INTEL)
161#define WTF_CPU_X86 1
162#endif
163
164/* CPU(X86_64) - AMD64 / Intel64 / x86_64 64-bit */
165#if defined(__x86_64__) \
166 || defined(_M_X64)
167#define WTF_CPU_X86_64 1
168#endif
169
170/* CPU(ARM64) - Apple */
171#if (defined(__arm64__) && defined(__APPLE__)) || defined(__aarch64__)
172#define WTF_CPU_ARM64 1
173#endif
174
175/* CPU(ARM64) - INTEGRITY */
176#if (defined(__ARM64__))
177#define WTF_CPU_ARM64 1
178#endif
179
180/* CPU(ARM) - ARM, any version*/
181#define WTF_ARM_ARCH_AT_LEAST(N) (CPU(ARM) && WTF_ARM_ARCH_VERSION >= N)
182
183#if defined(arm) \
184 || defined(__arm__) \
185 || defined(ARM) \
186 || defined(_ARM_)
187#define WTF_CPU_ARM 1
188
189#if defined(__ARM_PCS_VFP)
190#define WTF_CPU_ARM_HARDFP 1
191#endif
192
193#if defined(__ARMEB__) || (COMPILER(RVCT) && defined(__BIG_ENDIAN))
194#define WTF_CPU_BIG_ENDIAN 1
195
196#elif !defined(__ARM_EABI__) \
197 && !defined(__EABI__) \
198 && !defined(__VFP_FP__) \
199 && !defined(_WIN32_WCE)
200#define WTF_CPU_MIDDLE_ENDIAN 1
201
202#endif
203
204/* Set WTF_ARM_ARCH_VERSION */
205#if defined(__ARM_ARCH_4__) \
206 || defined(__ARM_ARCH_4T__) \
207 || defined(__MARM_ARMV4__)
208#define WTF_ARM_ARCH_VERSION 4
209
210#elif defined(__ARM_ARCH_5__) \
211 || defined(__ARM_ARCH_5T__) \
212 || defined(__MARM_ARMV5__)
213#define WTF_ARM_ARCH_VERSION 5
214
215#elif defined(__ARM_ARCH_5E__) \
216 || defined(__ARM_ARCH_5TE__) \
217 || defined(__ARM_ARCH_5TEJ__)
218#define WTF_ARM_ARCH_VERSION 5
219/*ARMv5TE requires allocators to use aligned memory*/
220#define WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
221
222#elif defined(__ARM_ARCH_6__) \
223 || defined(__ARM_ARCH_6J__) \
224 || defined(__ARM_ARCH_6K__) \
225 || defined(__ARM_ARCH_6Z__) \
226 || defined(__ARM_ARCH_6ZK__) \
227 || defined(__ARM_ARCH_6KZ__) \
228 || defined(__ARM_ARCH_6T2__) \
229 || defined(__ARMV6__)
230#define WTF_ARM_ARCH_VERSION 6
231
232#elif defined(__ARM_ARCH_7A__) \
233 || defined(__ARM_ARCH_7R__) \
234 || defined(__ARM_ARCH_7S__) \
235 || defined(__CORE_CORTEXA__) // GHS-specific
236#define WTF_ARM_ARCH_VERSION 7
237
238/* MSVC sets _M_ARM */
239#elif defined(_M_ARM)
240#define WTF_ARM_ARCH_VERSION _M_ARM
241
242/* RVCT sets _TARGET_ARCH_ARM */
243#elif defined(__TARGET_ARCH_ARM)
244#define WTF_ARM_ARCH_VERSION __TARGET_ARCH_ARM
245
246#if defined(__TARGET_ARCH_5E) \
247 || defined(__TARGET_ARCH_5TE) \
248 || defined(__TARGET_ARCH_5TEJ)
249/*ARMv5TE requires allocators to use aligned memory*/
250#define WTF_USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
251#endif
252
253#else
254#define WTF_ARM_ARCH_VERSION 0
255
256#endif
257
258/* Set WTF_THUMB_ARCH_VERSION */
259#if defined(__ARM_ARCH_4T__)
260#define WTF_THUMB_ARCH_VERSION 1
261
262#elif defined(__ARM_ARCH_5T__) \
263 || defined(__ARM_ARCH_5TE__) \
264 || defined(__ARM_ARCH_5TEJ__)
265#define WTF_THUMB_ARCH_VERSION 2
266
267#elif defined(__ARM_ARCH_6J__) \
268 || defined(__ARM_ARCH_6K__) \
269 || defined(__ARM_ARCH_6Z__) \
270 || defined(__ARM_ARCH_6ZK__) \
271 || defined(__ARM_ARCH_6M__)
272#define WTF_THUMB_ARCH_VERSION 3
273
274#elif defined(__ARM_ARCH_6T2__) \
275 || defined(__ARM_ARCH_7__) \
276 || defined(__ARM_ARCH_7A__) \
277 || defined(__ARM_ARCH_7M__) \
278 || defined(__ARM_ARCH_7R__) \
279 || defined(__ARM_ARCH_7S__) \
280 || defined(__CORE_CORTEXA__) // GHS-specific
281#define WTF_THUMB_ARCH_VERSION 4
282
283/* RVCT sets __TARGET_ARCH_THUMB */
284#elif defined(__TARGET_ARCH_THUMB)
285#define WTF_THUMB_ARCH_VERSION __TARGET_ARCH_THUMB
286
287#else
288#define WTF_THUMB_ARCH_VERSION 0
289#endif
290
291
292/* CPU(ARMV5_OR_LOWER) - ARM instruction set v5 or earlier */
293/* On ARMv5 and below the natural alignment is required.
294 And there are some other differences for v5 or earlier. */
295#if !defined(ARMV5_OR_LOWER) && !WTF_ARM_ARCH_AT_LEAST(6)
296#define WTF_CPU_ARMV5_OR_LOWER 1
297#endif
298
299
300/* CPU(ARM_TRADITIONAL) - Thumb2 is not available, only traditional ARM (v4 or greater) */
301/* CPU(ARM_THUMB2) - Thumb2 instruction set is available */
302/* Only one of these will be defined. */
303#if !defined(WTF_CPU_ARM_TRADITIONAL) && !defined(WTF_CPU_ARM_THUMB2)
304# if defined(thumb2) || defined(__thumb2__) \
305 || ((defined(__thumb) || defined(__thumb__)) && WTF_THUMB_ARCH_VERSION == 4) \
306 || (defined(__ARM_ARCH_ISA_THUMB) && __ARM_ARCH_ISA_THUMB == 2)
307# define WTF_CPU_ARM_TRADITIONAL 0
308# define WTF_CPU_ARM_THUMB2 1
309# elif WTF_ARM_ARCH_AT_LEAST(4)
310# define WTF_CPU_ARM_TRADITIONAL 1
311# define WTF_CPU_ARM_THUMB2 0
312# else
313# error "Not supported ARM architecture"
314# endif
315#elif CPU(ARM_TRADITIONAL) && CPU(ARM_THUMB2) /* Sanity Check */
316# error "Cannot use both of WTF_CPU_ARM_TRADITIONAL and WTF_CPU_ARM_THUMB2 platforms"
317#endif /* !defined(WTF_CPU_ARM_TRADITIONAL) && !defined(WTF_CPU_ARM_THUMB2) */
318
319#if defined(__ARM_NEON__) && !defined(WTF_CPU_ARM_NEON)
320#define WTF_CPU_ARM_NEON 1
321#endif
322
323#if CPU(ARM_NEON) && (!COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 7, 0))
324// All NEON intrinsics usage can be disabled by this macro.
325#define HAVE_ARM_NEON_INTRINSICS 1
326#endif
327
328#if (defined(__VFP_FP__) && !defined(__SOFTFP__))
329#define WTF_CPU_ARM_VFP 1
330#endif
331
332#if defined(__ARM_ARCH_7S__)
333#define WTF_CPU_APPLE_ARMV7S 1
334#endif
335
336#endif /* ARM */
337
338#if CPU(ARM) || CPU(MIPS) || CPU(SH4) || CPU(SPARC)
339#define WTF_CPU_NEEDS_ALIGNED_ACCESS 1
340#endif
341
342/* ==== OS() - underlying operating system; only to be used for mandated low-level services like
343 virtual memory, not to choose a GUI toolkit ==== */
344
345/* OS(AIX) - AIX */
346#ifdef _AIX
347#define WTF_OS_AIX 1
348#endif
349
350/* OS(DARWIN) - Any Darwin-based OS, including Mac OS X and iPhone OS */
351#ifdef __APPLE__
352#define WTF_OS_DARWIN 1
353
354#include <Availability.h>
355#include <AvailabilityMacros.h>
356#include <TargetConditionals.h>
357#endif
358
359/* OS(IOS) - iOS */
360/* OS(MAC_OS_X) - Mac OS X (not including iOS) */
361#if OS(DARWIN) && ((defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) \
362 || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) \
363 || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR))
364#define WTF_OS_IOS 1
365#elif OS(DARWIN) && ((defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) \
366 || (defined(TARGET_OS_APPLETV) && TARGET_OS_APPLETV) \
367 || (defined(TARGET_APPLETV_SIMULATOR) && TARGET_APPLETV_SIMULATOR))
368#define WTF_OS_IOS 1
369#define WTF_OS_TVOS 1
370#elif OS(DARWIN) && defined(TARGET_OS_MAC) && TARGET_OS_MAC
371#define WTF_OS_MAC_OS_X 1
372
373/* FIXME: These can be removed after sufficient time has passed since the removal of BUILDING_ON / TARGETING macros. */
374
375#define ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MIN_REQUIRED 0 / 0
376#define ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MAX_ALLOWED 0 / 0
377
378#define BUILDING_ON_LEOPARD ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MIN_REQUIRED
379#define BUILDING_ON_SNOW_LEOPARD ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MIN_REQUIRED
380#define BUILDING_ON_LION ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MIN_REQUIRED
381
382#define TARGETING_LEOPARD ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MAX_ALLOWED
383#define TARGETING_SNOW_LEOPARD ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MAX_ALLOWED
384#define TARGETING_LION ERROR_PLEASE_COMPARE_WITH_MAC_OS_X_VERSION_MAX_ALLOWED
385#endif
386
387/* OS(FREEBSD) - FreeBSD */
388#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
389#define WTF_OS_FREEBSD 1
390#endif
391
392/* OS(HURD) - GNU/Hurd */
393#ifdef __GNU__
394#define WTF_OS_HURD 1
395#endif
396
397/* OS(INTEGRITY) - INTEGRITY */
398#ifdef __INTEGRITY
399#define WTF_OS_INTEGRITY 1
400#endif
401
402/* OS(LINUX) - Linux */
403#ifdef __linux__
404#define WTF_OS_LINUX 1
405#endif
406
407/* OS(NETBSD) - NetBSD */
408#if defined(__NetBSD__)
409#define WTF_OS_NETBSD 1
410#endif
411
412/* OS(OPENBSD) - OpenBSD */
413#ifdef __OpenBSD__
414#define WTF_OS_OPENBSD 1
415#endif
416
417/* OS(QNX) - QNX */
418#if defined(__QNXNTO__)
419#define WTF_OS_QNX 1
420#endif
421
422/* OS(SOLARIS) - Solaris */
423#if defined(sun) || defined(__sun)
424#define WTF_OS_SOLARIS 1
425#endif
426
427/* OS(WINCE) - Windows CE; note that for this platform OS(WINDOWS) is also defined */
428#if defined(_WIN32_WCE)
429#define WTF_OS_WINCE 1
430#endif
431
432/* OS(WINCE) - Windows Runtime; note that for this platform OS(WINDOWS) is also defined */
433#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY==WINAPI_FAMILY_APP || WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP)
434#define WTF_OS_WINRT 1
435#endif
436
437/* OS(WINDOWS) - Any version of Windows */
438#if defined(WIN32) || defined(_WIN32)
439#define WTF_OS_WINDOWS 1
440#endif
441
442#ifdef __rtems__
443#define WTF_OS_RTEMS 1
444#endif
445
446#define WTF_OS_WIN ERROR "USE WINDOWS WITH OS NOT WIN"
447#define WTF_OS_MAC ERROR "USE MAC_OS_X WITH OS NOT MAC"
448
449/* OS(UNIX) - Any Unix-like system */
450#if OS(AIX) \
451 || OS(DARWIN) \
452 || OS(FREEBSD) \
453 || OS(HURD) \
454 || OS(INTEGRITY) \
455 || OS(LINUX) \
456 || OS(NETBSD) \
457 || OS(OPENBSD) \
458 || OS(QNX) \
459 || OS(RTEMS) \
460 || OS(SOLARIS) \
461 || defined(unix) \
462 || defined(__unix) \
463 || defined(__unix__)
464#define WTF_OS_UNIX 1
465#endif
466
467/* Operating environments */
468
469/* FIXME: these are all mixes of OS, operating environment and policy choices. */
470/* PLATFORM(QT) */
471/* PLATFORM(WX) */
472/* PLATFORM(EFL) */
473/* PLATFORM(GTK) */
474/* PLATFORM(BLACKBERRY) */
475/* PLATFORM(MAC) */
476/* PLATFORM(WIN) */
477#if defined(BUILDING_QT__)
478#define WTF_PLATFORM_QT 1
479#elif defined(BUILDING_WX__)
480#define WTF_PLATFORM_WX 1
481#elif defined(BUILDING_EFL__)
482#define WTF_PLATFORM_EFL 1
483#elif defined(BUILDING_GTK__)
484#define WTF_PLATFORM_GTK 1
485#elif defined(BUILDING_BLACKBERRY__)
486#define WTF_PLATFORM_BLACKBERRY 1
487#elif OS(DARWIN)
488#define WTF_PLATFORM_MAC 1
489#elif OS(WINDOWS)
490#define WTF_PLATFORM_WIN 1
491#else
492
493/* PLATFORM(IOS) */
494/* FIXME: this is sometimes used as an OS switch and sometimes for higher-level things */
495#if (defined(TARGET_OS_EMBEDDED) && TARGET_OS_EMBEDDED) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
496#define WTF_PLATFORM_IOS 1
497#endif
498
499/* PLATFORM(IOS_SIMULATOR) */
500#if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR
501#define WTF_PLATFORM_IOS 1
502#define WTF_PLATFORM_IOS_SIMULATOR 1
503#endif
504#endif
505
506/* Graphics engines */
507
508/* USE(CG) and PLATFORM(CI) */
509#if PLATFORM(MAC) || PLATFORM(IOS)
510#define WTF_USE_CG 1
511#endif
512#if PLATFORM(MAC) || PLATFORM(IOS) || (PLATFORM(WIN) && USE(CG))
513#define WTF_USE_CA 1
514#endif
515
516#if PLATFORM(BLACKBERRY)
517#define WTF_USE_SKIA 1
518#define WTF_USE_LOW_QUALITY_IMAGE_INTERPOLATION 1
519#define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_DITHERING 1
520#define WTF_USE_LOW_QUALITY_IMAGE_NO_JPEG_FANCY_UPSAMPLING 1
521#endif
522
523#if PLATFORM(GTK)
524#define WTF_USE_CAIRO 1
525#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
526#endif
527
528/* On Windows, use QueryPerformanceCounter by default */
529#if OS(WINDOWS)
530#define WTF_USE_QUERY_PERFORMANCE_COUNTER 1
531#endif
532
533#if OS(WINCE)
534#define NOSHLWAPI /* shlwapi.h not available on WinCe */
535
536/* MSDN documentation says these functions are provided with uspce.lib. But we cannot find this file. */
537#define __usp10__ /* disable "usp10.h" */
538
539#define _INC_ASSERT /* disable "assert.h" */
540#define assert(x)
541
542#endif /* OS(WINCE) */
543
544#if OS(WINCE) && !PLATFORM(QT)
545#define WTF_USE_WCHAR_UNICODE 1
546#elif PLATFORM(GTK)
547/* The GTK+ Unicode backend is configurable */
548#else
549#define WTF_USE_ICU_UNICODE 1
550#endif
551
552#if PLATFORM(MAC) && !PLATFORM(IOS)
553#if CPU(X86_64)
554#define WTF_USE_PLUGIN_HOST_PROCESS 1
555#endif
556#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
557#define WTF_USE_SCROLLBAR_PAINTER 1
558#define HAVE_XPC 1
559#endif
560#define WTF_USE_CF 1
561#define HAVE_READLINE 1
562#define HAVE_RUNLOOP_TIMER 1
563#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
564#define HAVE_LAYER_HOSTING_IN_WINDOW_SERVER 1
565#endif
566#define WTF_USE_APPKIT 1
567#define WTF_USE_SECURITY_FRAMEWORK 1
568#endif /* PLATFORM(MAC) && !PLATFORM(IOS) */
569
570#if PLATFORM(IOS)
571#define DONT_FINALIZE_ON_MAIN_THREAD 1
572#endif
573
574#if PLATFORM(QT) && OS(DARWIN)
575#define WTF_USE_CF 1
576#endif
577
578#if OS(DARWIN) && !PLATFORM(GTK) && !PLATFORM(QT)
579#define ENABLE_PURGEABLE_MEMORY 1
580#endif
581
582#if PLATFORM(IOS)
583#define HAVE_READLINE 1
584#define WTF_USE_APPKIT 0
585#define WTF_USE_CF 1
586#define WTF_USE_CFNETWORK 1
587#define WTF_USE_NETWORK_CFDATA_ARRAY_CALLBACK 1
588#define WTF_USE_SECURITY_FRAMEWORK 0
589#define WTF_USE_WEB_THREAD 1
590#endif /* PLATFORM(IOS) */
591
592#if PLATFORM(WIN) && !OS(WINCE)
593#define WTF_USE_CF 1
594#endif
595
596#if PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)
597#define WTF_USE_CFNETWORK 1
598#endif
599
600#if USE(CFNETWORK) || PLATFORM(MAC) || PLATFORM(IOS)
601#define WTF_USE_CFURLCACHE 1
602#endif
603
604#if PLATFORM(WX)
605#if !CPU(PPC)
606#if !defined(ENABLE_ASSEMBLER)
607#define ENABLE_ASSEMBLER 1
608#endif
609#define ENABLE_JIT 1
610#endif
611#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
612#define ENABLE_LLINT 0
613#if OS(DARWIN)
614#define WTF_USE_CF 1
615#endif
616#endif
617
618#if !defined(HAVE_ACCESSIBILITY)
619#if PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(EFL)
620#define HAVE_ACCESSIBILITY 1
621#endif
622#endif /* !defined(HAVE_ACCESSIBILITY) */
623
624#if OS(UNIX)
625#define HAVE_ERRNO_H 1
626#if !OS(INTEGRITY)
627#define HAVE_MMAP 1
628#endif
629#define HAVE_SIGNAL_H 1
630#define HAVE_STRINGS_H 1
631#define HAVE_SYS_PARAM_H 1
632#define HAVE_SYS_TIME_H 1
633#define WTF_USE_OS_RANDOMNESS 1
634#define WTF_USE_PTHREADS 1
635#endif /* OS(UNIX) */
636
637#if OS(UNIX) && !OS(QNX)
638#define HAVE_LANGINFO_H 1
639#endif
640
641#if (OS(FREEBSD) || OS(OPENBSD)) && !defined(__GLIBC__)
642#define HAVE_PTHREAD_NP_H 1
643#endif
644
645#if !defined(HAVE_VASPRINTF)
646#if !COMPILER(MSVC) && !COMPILER(RVCT) && !COMPILER(MINGW) && !(COMPILER(GCC) && OS(QNX))
647#define HAVE_VASPRINTF 1
648#endif
649#endif
650
651#if !defined(HAVE_STRNSTR)
652#if OS(DARWIN) || (OS(FREEBSD) && !defined(__GLIBC__))
653#define HAVE_STRNSTR 1
654#endif
655#endif
656
657#if !OS(WINDOWS) && !OS(SOLARIS)
658#define HAVE_TM_GMTOFF 1
659#define HAVE_TM_ZONE 1
660#define HAVE_TIMEGM 1
661#endif
662
663#if OS(DARWIN)
664
665#define HAVE_DISPATCH_H 1
666#define HAVE_MADV_FREE 1
667#define HAVE_MADV_FREE_REUSE 1
668#define HAVE_MERGESORT 1
669#define HAVE_PTHREAD_SETNAME_NP 1
670#define HAVE_SYS_TIMEB_H 1
671#define WTF_USE_ACCELERATE 1
672
673#if !PLATFORM(IOS)
674#define HAVE_HOSTED_CORE_ANIMATION 1
675#endif /* !PLATFORM(IOS) */
676
677#endif /* OS(DARWIN) */
678
679#if OS(WINDOWS) && !OS(WINCE)
680#define HAVE_SYS_TIMEB_H 1
681#define HAVE_ALIGNED_MALLOC 1
682#define HAVE_ISDEBUGGERPRESENT 1
683#endif
684
685#if OS(WINDOWS)
686#define HAVE_VIRTUALALLOC 1
687#define WTF_USE_OS_RANDOMNESS 1
688#endif
689
690#if OS(QNX)
691#define HAVE_MADV_FREE_REUSE 1
692#define HAVE_MADV_FREE 1
693#endif
694
695/* ENABLE macro defaults */
696
697/* FIXME: move out all ENABLE() defines from here to FeatureDefines.h */
698
699/* Include feature macros */
700#include <wtf/FeatureDefines.h>
701
702#if PLATFORM(QT)
703/* We must not customize the global operator new and delete for the Qt port. */
704#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
705#if !OS(UNIX)
706#define USE_SYSTEM_MALLOC 1
707#endif
708#endif
709
710#if PLATFORM(EFL)
711#define ENABLE_GLOBAL_FASTMALLOC_NEW 0
712#endif
713
714#if !defined(ENABLE_GLOBAL_FASTMALLOC_NEW)
715#define ENABLE_GLOBAL_FASTMALLOC_NEW 1
716#endif
717
718#define ENABLE_DEBUG_WITH_BREAKPOINT 0
719#define ENABLE_SAMPLING_COUNTERS 0
720#define ENABLE_SAMPLING_FLAGS 0
721#define ENABLE_SAMPLING_REGIONS 0
722#define ENABLE_OPCODE_SAMPLING 0
723#define ENABLE_CODEBLOCK_SAMPLING 0
724#if ENABLE(CODEBLOCK_SAMPLING) && !ENABLE(OPCODE_SAMPLING)
725#error "CODEBLOCK_SAMPLING requires OPCODE_SAMPLING"
726#endif
727#if ENABLE(OPCODE_SAMPLING) || ENABLE(SAMPLING_FLAGS) || ENABLE(SAMPLING_REGIONS)
728#define ENABLE_SAMPLING_THREAD 1
729#endif
730
731#if !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32_64)
732#if (CPU(X86_64) && (OS(UNIX) || OS(WINDOWS))) \
733 || (CPU(IA64) && !CPU(IA64_32)) \
734 || CPU(ALPHA) \
735 || CPU(ARM64) \
736 || CPU(SPARC64) \
737 || CPU(S390X) \
738 || CPU(PPC64)
739#define WTF_USE_JSVALUE64 1
740#else
741#define WTF_USE_JSVALUE32_64 1
742#endif
743#endif /* !defined(WTF_USE_JSVALUE64) && !defined(WTF_USE_JSVALUE32_64) */
744
745/* Disable the JIT on versions of GCC prior to 4.1 */
746#if !defined(ENABLE_JIT) && COMPILER(GCC) && !GCC_VERSION_AT_LEAST(4, 1, 0)
747#define ENABLE_JIT 0
748#endif
749
750/* The JIT is enabled by default on all x86, x86-64, ARM & MIPS platforms. */
751#if !defined(ENABLE_JIT) \
752 && (CPU(X86) || CPU(X86_64) || CPU(ARM) || CPU(MIPS) || CPU(ARM64)) \
753 && (OS(DARWIN) || !COMPILER(GCC) || GCC_VERSION_AT_LEAST(4, 1, 0)) \
754 && !OS(WINCE) \
755 && !(OS(QNX) && !PLATFORM(QT)) /* We use JIT in QNX Qt */
756#define ENABLE_JIT 1
757#endif
758
759/* If possible, try to enable a disassembler. This is optional. We proceed in two
760 steps: first we try to find some disassembler that we can use, and then we
761 decide if the high-level disassembler API can be enabled. */
762#if !defined(WTF_USE_UDIS86) && ENABLE(JIT) && (PLATFORM(MAC) || (PLATFORM(QT) && OS(LINUX))) \
763 && (CPU(X86) || CPU(X86_64))
764#define WTF_USE_UDIS86 1
765#endif
766
767#if !defined(ENABLE_DISASSEMBLER) && (USE(UDIS86) || USE(ARMV7_DISASSEMBLER) || USE(ARM64_DISASSEMBLER) || USE(MIPS32_DISASSEMBLER))
768#define ENABLE_DISASSEMBLER 1
769#endif
770
771/* On the GTK+ port we take an extra precaution for LLINT support:
772 * We disable it on x86 builds if the build target doesn't support SSE2
773 * instructions (LLINT requires SSE2 on this platform). */
774#if !defined(ENABLE_LLINT) && PLATFORM(GTK) && CPU(X86) && COMPILER(GCC) \
775 && !defined(__SSE2__)
776#define ENABLE_LLINT 0
777#endif
778
779/* On some of the platforms where we have a JIT, we want to also have the
780 low-level interpreter. */
781#if !defined(ENABLE_LLINT) \
782 && ENABLE(JIT) \
783 && (OS(DARWIN) || OS(LINUX)) \
784 && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(GTK) || PLATFORM(QT)) \
785 && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2) || CPU(ARM_TRADITIONAL) || CPU(MIPS))
786#define ENABLE_LLINT 1
787#endif
788
789#if !defined(ENABLE_DFG_JIT) && ENABLE(JIT) && !COMPILER(MSVC)
790/* Enable the DFG JIT on X86 and X86_64. Only tested on Mac and GNU/Linux. */
791#if (CPU(X86) || CPU(X86_64)) && (OS(DARWIN) || OS(LINUX))
792#define ENABLE_DFG_JIT 1
793#endif
794/* Enable the DFG JIT on ARMv7. Only tested on iOS and Qt Linux. */
795#if CPU(ARM_THUMB2) && (PLATFORM(IOS) || PLATFORM(BLACKBERRY) || PLATFORM(QT))
796#define ENABLE_DFG_JIT 1
797#endif
798/* Enable the DFG JIT on ARM. */
799#if CPU(ARM_TRADITIONAL)
800#define ENABLE_DFG_JIT 1
801#endif
802/* Enable the DFG JIT on MIPS. */
803#if CPU(MIPS)
804#define ENABLE_DFG_JIT 1
805#endif
806#endif
807
808/* If the jit is not available, enable the LLInt C Loop: */
809/* Not for Qml. We have our own interpreter. */
810#if 0 /* !ENABLE(JIT) */
811#undef ENABLE_LLINT /* Undef so that we can redefine it. */
812#undef ENABLE_LLINT_C_LOOP /* Undef so that we can redefine it. */
813#undef ENABLE_DFG_JIT /* Undef so that we can redefine it. */
814#define ENABLE_LLINT 1
815#define ENABLE_LLINT_C_LOOP 1
816#define ENABLE_DFG_JIT 0
817#endif
818
819/* Do a sanity check to make sure that we at least have one execution engine in
820 use: */
821#if 0 /* !(ENABLE(JIT) || ENABLE(LLINT)) */
822#error You have to have at least one execution model enabled to build JSC
823#endif
824
825/* Profiling of types and values used by JIT code. DFG_JIT depends on it, but you
826 can enable it manually with DFG turned off if you want to use it as a standalone
827 profiler. In that case, you probably want to also enable VERBOSE_VALUE_PROFILE
828 below. */
829#if !defined(ENABLE_VALUE_PROFILER) && ENABLE(DFG_JIT)
830#define ENABLE_VALUE_PROFILER 1
831#endif
832
833#if !defined(ENABLE_VERBOSE_VALUE_PROFILE) && ENABLE(VALUE_PROFILER)
834#define ENABLE_VERBOSE_VALUE_PROFILE 0
835#endif
836
837#if !defined(ENABLE_SIMPLE_HEAP_PROFILING)
838#define ENABLE_SIMPLE_HEAP_PROFILING 0
839#endif
840
841/* Counts uses of write barriers using sampling counters. Be sure to also
842 set ENABLE_SAMPLING_COUNTERS to 1. */
843#if !defined(ENABLE_WRITE_BARRIER_PROFILING)
844#define ENABLE_WRITE_BARRIER_PROFILING 0
845#endif
846
847/* Enable verification that that register allocations are not made within generated control flow.
848 Turned on for debug builds. */
849#if !defined(ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION) && ENABLE(DFG_JIT)
850#if !defined(NDEBUG)
851#define ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION 1
852#else
853#define ENABLE_DFG_REGISTER_ALLOCATION_VALIDATION 0
854#endif
855#endif
856
857/* Configure the JIT */
858#if CPU(X86) && COMPILER(MSVC)
859#define JSC_HOST_CALL __fastcall
860#elif CPU(X86) && COMPILER(GCC)
861#define JSC_HOST_CALL __attribute__ ((fastcall))
862#else
863#define JSC_HOST_CALL
864#endif
865
866/* Configure the interpreter */
867#if COMPILER(GCC) || (COMPILER(RVCT) && defined(__GNUC__))
868#define HAVE_COMPUTED_GOTO 1
869#endif
870
871/* Determine if we need to enable Computed Goto Opcodes or not: */
872#if HAVE(COMPUTED_GOTO) && ENABLE(LLINT)
873#define ENABLE_COMPUTED_GOTO_OPCODES 1
874#endif
875
876/* Regular Expression Tracing - Set to 1 to trace RegExp's in jsc. Results dumped at exit */
877#define ENABLE_REGEXP_TRACING 0
878
879/* Yet Another Regex Runtime - turned on by default for JIT enabled ports. */
880#if !defined(ENABLE_YARR_JIT) && (ENABLE(JIT) || ENABLE(LLINT_C_LOOP)) && !(OS(QNX) && PLATFORM(QT))
881#define ENABLE_YARR_JIT 1
882
883/* Setting this flag compares JIT results with interpreter results. */
884#define ENABLE_YARR_JIT_DEBUG 0
885#endif
886
887/* If either the JIT or the RegExp JIT is enabled, then the Assembler must be
888 enabled as well: */
889#if ENABLE(JIT) || ENABLE(YARR_JIT)
890#if defined(ENABLE_ASSEMBLER) && !ENABLE_ASSEMBLER
891#error "Cannot enable the JIT or RegExp JIT without enabling the Assembler"
892#else
893#undef ENABLE_ASSEMBLER
894#define ENABLE_ASSEMBLER 1
895#endif
896#endif
897
898/* Pick which allocator to use; we only need an executable allocator if the assembler is compiled in.
899 On x86-64 we use a single fixed mmap, on other platforms we mmap on demand. */
900#if ENABLE(ASSEMBLER)
901#if CPU(X86_64) && !OS(WINDOWS) || PLATFORM(IOS) || CPU(ARM64)
902#define ENABLE_EXECUTABLE_ALLOCATOR_FIXED 1
903#else
904#define ENABLE_EXECUTABLE_ALLOCATOR_DEMAND 1
905#endif
906#endif
907
908/* Use the QXmlStreamReader implementation for XMLDocumentParser */
909/* Use the QXmlQuery implementation for XSLTProcessor */
910#if PLATFORM(QT)
911#if !USE(LIBXML2)
912#define WTF_USE_QXMLSTREAM 1
913#define WTF_USE_QXMLQUERY 1
914#endif
915#endif
916
917/* Accelerated compositing */
918#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(QT) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO))
919#define WTF_USE_ACCELERATED_COMPOSITING 1
920#endif
921
922#if ENABLE(WEBGL) && !defined(WTF_USE_3D_GRAPHICS)
923#define WTF_USE_3D_GRAPHICS 1
924#endif
925
926/* Qt always uses Texture Mapper */
927#if PLATFORM(QT)
928#define WTF_USE_TEXTURE_MAPPER 1
929#endif
930
931#if USE(TEXTURE_MAPPER) && USE(3D_GRAPHICS) && !defined(WTF_USE_TEXTURE_MAPPER_GL)
932#define WTF_USE_TEXTURE_MAPPER_GL 1
933#endif
934
935/* Compositing on the UI-process in WebKit2 */
936#if USE(3D_GRAPHICS) && PLATFORM(QT)
937#define WTF_USE_COORDINATED_GRAPHICS 1
938#endif
939
940#if PLATFORM(MAC) || PLATFORM(IOS)
941#define WTF_USE_PROTECTION_SPACE_AUTH_CALLBACK 1
942#endif
943
944/* Set up a define for a common error that is intended to cause a build error -- thus the space after Error. */
945#define WTF_PLATFORM_CFNETWORK Error USE_macro_should_be_used_with_CFNETWORK
946
947/* FIXME: Eventually we should enable this for all platforms and get rid of the define. */
948#if PLATFORM(IOS) || PLATFORM(MAC) || PLATFORM(WIN) || PLATFORM(QT) || PLATFORM(GTK) || PLATFORM(EFL)
949#define WTF_USE_PLATFORM_STRATEGIES 1
950#endif
951
952#if PLATFORM(WIN)
953#define WTF_USE_CROSS_PLATFORM_CONTEXT_MENUS 1
954#endif
955
956#if PLATFORM(MAC) && HAVE(ACCESSIBILITY)
957#define WTF_USE_ACCESSIBILITY_CONTEXT_MENUS 1
958#endif
959
960#if !defined(ENABLE_THREADING_LIBDISPATCH) && HAVE(DISPATCH_H)
961#define ENABLE_THREADING_LIBDISPATCH 1
962#elif !defined(ENABLE_THREADING_OPENMP) && defined(_OPENMP)
963#define ENABLE_THREADING_OPENMP 1
964#elif !defined(THREADING_GENERIC)
965#define ENABLE_THREADING_GENERIC 1
966#endif
967
968#if USE(GLIB)
969#include <wtf/gobject/GTypedefs.h>
970#endif
971
972/* FIXME: This define won't be needed once #27551 is fully landed. However,
973 since most ports try to support sub-project independence, adding new headers
974 to WTF causes many ports to break, and so this way we can address the build
975 breakages one port at a time. */
976#if !defined(WTF_USE_EXPORT_MACROS) && (PLATFORM(MAC) || PLATFORM(QT) || PLATFORM(WX))
977#define WTF_USE_EXPORT_MACROS 1
978#endif
979
980#if !defined(WTF_USE_EXPORT_MACROS_FOR_TESTING) && (PLATFORM(GTK) || PLATFORM(WIN))
981#define WTF_USE_EXPORT_MACROS_FOR_TESTING 1
982#endif
983
984#if (PLATFORM(QT) && !OS(DARWIN) && !OS(WINDOWS)) || PLATFORM(GTK) || PLATFORM(EFL)
985#define WTF_USE_UNIX_DOMAIN_SOCKETS 1
986#endif
987
988#if !defined(ENABLE_COMPARE_AND_SWAP) && (OS(WINDOWS) || (COMPILER(GCC) && (CPU(X86) || CPU(X86_64) || CPU(ARM_THUMB2))))
989#define ENABLE_COMPARE_AND_SWAP 1
990#endif
991
992#define ENABLE_OBJECT_MARK_LOGGING 0
993
994#if !defined(ENABLE_PARALLEL_GC) && !ENABLE(OBJECT_MARK_LOGGING) && (PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(BLACKBERRY) || PLATFORM(GTK)) && ENABLE(COMPARE_AND_SWAP)
995#define ENABLE_PARALLEL_GC 1
996#elif PLATFORM(QT)
997// Parallel GC is temporarily disabled on Qt because of regular crashes, see https://bugs.webkit.org/show_bug.cgi?id=90957 for details
998#define ENABLE_PARALLEL_GC 0
999#endif
1000
1001#if !defined(ENABLE_GC_VALIDATION) && !defined(NDEBUG)
1002#define ENABLE_GC_VALIDATION 1
1003#endif
1004
1005#if !defined(ENABLE_BINDING_INTEGRITY)
1006#define ENABLE_BINDING_INTEGRITY 1
1007#endif
1008
1009#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
1010#define WTF_USE_AVFOUNDATION 1
1011#endif
1012
1013#if (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080)
1014#define WTF_USE_COREMEDIA 1
1015#endif
1016
1017#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
1018#define HAVE_AVFOUNDATION_TEXT_TRACK_SUPPORT 1
1019#endif
1020
1021#if PLATFORM(MAC) && !PLATFORM(IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
1022#define HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK 1
1023#endif
1024
1025#if PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(WIN) && !OS(WINCE) && !PLATFORM(WIN_CAIRO)) || PLATFORM(BLACKBERRY)
1026#define WTF_USE_REQUEST_ANIMATION_FRAME_TIMER 1
1027#endif
1028
1029#if PLATFORM(MAC) || PLATFORM(BLACKBERRY)
1030#define WTF_USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR 1
1031#endif
1032
1033#if PLATFORM(MAC) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070)
1034#define HAVE_INVERTED_WHEEL_EVENTS 1
1035#endif
1036
1037#if PLATFORM(MAC)
1038#define WTF_USE_COREAUDIO 1
1039#endif
1040
1041#if !defined(WTF_USE_ZLIB) && !PLATFORM(QT)
1042#define WTF_USE_ZLIB 1
1043#endif
1044
1045#if PLATFORM(QT)
1046#include <qglobal.h>
1047#endif
1048
1049#if !PLATFORM(IOS) && PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
1050#define WTF_USE_CONTENT_FILTERING 1
1051#endif
1052
1053#if ENABLE(YARR_JIT)
1054#if CPU(ARM64) || (CPU(X86_64) && !OS(WINDOWS))
1055/* Enable JIT'ing Regular Expressions that have nested parenthesis. */
1056#define ENABLE_YARR_JIT_ALL_PARENS_EXPRESSIONS 1
1057#define ENABLE_YARR_JIT_BACKREFERENCES 1
1058#endif
1059#endif
1060
1061#endif /* WTF_Platform_h */
1062

source code of qtdeclarative/src/3rdparty/masm/wtf/Platform.h