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