Platform.h is out of control Part 6: Split USE_* macro definitions out of Platform.h and into a new PlatformUse.h
https://bugs.webkit.org/show_bug.cgi?id=206354
Reviewed by Dan Bernstein.
As a another step towards cleaning up Platform.h, split out all the legacy platform
macros into their own file.
* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
Add new file.
* wtf/Platform.h: In addition to removing all the USE_* macros, consolidate
all the sub-includes at the top.
* wtf/PlatformEnable.h: Moved ASSERT_ENABLED here from Platform.h,
as it makes more sense here. Eventually should be renamed ro ENABLE_ASSERT
for consistency.
* wtf/PlatformUse.h: Copied from Source/WTF/wtf/Platform.h.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@254701 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 73f49aa..f36d657 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,26 @@
+2020-01-16 Sam Weinig <weinig@apple.com>
+
+ Platform.h is out of control Part 6: Split USE_* macro definitions out of Platform.h and into a new PlatformUse.h
+ https://bugs.webkit.org/show_bug.cgi?id=206354
+
+ Reviewed by Dan Bernstein.
+
+ As a another step towards cleaning up Platform.h, split out all the legacy platform
+ macros into their own file.
+
+ * WTF.xcodeproj/project.pbxproj:
+ * wtf/CMakeLists.txt:
+ Add new file.
+
+ * wtf/Platform.h: In addition to removing all the USE_* macros, consolidate
+ all the sub-includes at the top.
+
+ * wtf/PlatformEnable.h: Moved ASSERT_ENABLED here from Platform.h,
+ as it makes more sense here. Eventually should be renamed ro ENABLE_ASSERT
+ for consistency.
+
+ * wtf/PlatformUse.h: Copied from Source/WTF/wtf/Platform.h.
+
2020-01-16 Per Arne Vollan <pvollan@apple.com>
[Win] Fix AppleWin build
diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj
index 8093136..f9ff508 100644
--- a/Source/WTF/WTF.xcodeproj/project.pbxproj
+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj
@@ -455,6 +455,7 @@
7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorAdaptors.h; sourceTree = "<group>"; };
7CDD7FF9186D2A54007433CD /* IteratorRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IteratorRange.h; sourceTree = "<group>"; };
7CEAE5AC1EA6E10F00DB6890 /* NotFound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NotFound.h; sourceTree = "<group>"; };
+ 7CFAF3C923D0AF1500D21BDD /* PlatformUse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformUse.h; sourceTree = "<group>"; };
7E29C33D15FFD79B00516D61 /* ObjCRuntimeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCRuntimeExtras.h; sourceTree = "<group>"; };
8134013615B092FD001FF0B8 /* Base64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Base64.cpp; sourceTree = "<group>"; };
8134013715B092FD001FF0B8 /* Base64.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Base64.h; sourceTree = "<group>"; };
@@ -1132,6 +1133,7 @@
7C42307323CE2D8B006E54D0 /* PlatformOS.h */,
FE1E2C41224187C600F6B729 /* PlatformRegisters.cpp */,
E3200AB41E9A536D003B59D2 /* PlatformRegisters.h */,
+ 7CFAF3C923D0AF1500D21BDD /* PlatformUse.h */,
0FF860941BCCBD740045127F /* PointerComparison.h */,
FEB6B035201BE0B600B958C1 /* PointerPreparations.h */,
0F9D335D165DBA73005AD387 /* PrintStream.cpp */,
diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt
index d1c5999..8c7b051 100644
--- a/Source/WTF/wtf/CMakeLists.txt
+++ b/Source/WTF/wtf/CMakeLists.txt
@@ -176,6 +176,7 @@
PlatformLegacy.h
PlatformOS.h
PlatformRegisters.h
+ PlatformUse.h
PointerComparison.h
PointerPreparations.h
PrintStream.h
diff --git a/Source/WTF/wtf/Platform.h b/Source/WTF/wtf/Platform.h
index e200d0b6..aa9f8ea 100644
--- a/Source/WTF/wtf/Platform.h
+++ b/Source/WTF/wtf/Platform.h
@@ -30,6 +30,9 @@
/* Include compiler specific macros */
#include <wtf/Compiler.h>
+/* __PLATFORM_INDIRECT__ ensures that users #include <wtf/Platform.h> rather than one of the helper files files directly. */
+#define __PLATFORM_INDIRECT__
+
/* ==== Platform adaptation macros: these describe properties of the target environment. ==== */
/* CPU() - the target CPU architecture */
@@ -50,35 +53,27 @@
/* ==== Policy decision macros: these define policy choices for a particular port. ==== */
/* USE() - use a particular third-party library or optional OS service */
-#define USE(WTF_FEATURE) (defined USE_##WTF_FEATURE && USE_##WTF_FEATURE)
+#include <wtf/PlatformUse.h>
+
/* ENABLE() - turn on a specific feature of WebKit */
-#define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE && ENABLE_##WTF_FEATURE)
+#include <wtf/PlatformEnable.h>
+#undef __PLATFORM_INDIRECT__
-
-#if PLATFORM(COCOA)
-#if defined __has_include && __has_include(<CoreFoundation/CFPriv.h>)
-#define USE_APPLE_INTERNAL_SDK 1
-#endif
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/AdditionalPlatform.h>)
+#include <WebKitAdditions/AdditionalPlatform.h>
#endif
-/* MIPS requires allocators to use aligned memory */
-#if CPU(MIPS) || CPU(MIPS64)
-#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
-#endif
-
-/*ARMv5TE requires allocators to use aligned memory*/
-#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
-#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
-#endif
-
-/*ARMv5TE requires allocators to use aligned memory*/
-#if defined(__TARGET_ARCH_5E) || defined(__TARGET_ARCH_5TE) || defined(__TARGET_ARCH_5TEJ)
-#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
+#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/AdditionalFeatureDefines.h>)
+#include <WebKitAdditions/AdditionalFeatureDefines.h>
#endif
-/* Operating environments */
+
+/* FIXME: The following are currenly positioned at the bottom of this file as they either
+ are currently dependent on macros they should not be and need to be refined or do not
+ belong as part of Platform.h at all. */
+
/* FIXME: Rename WTF_CPU_EFFECTIVE_ADDRESS_WIDTH to WTF_OS_EFFECTIVE_ADDRESS_WIDTH, as it is an OS feature, not a CPU feature. */
@@ -93,64 +88,6 @@
#define WTF_CPU_EFFECTIVE_ADDRESS_WIDTH 32
#endif
-/* Export macro support. Detects the attributes available for shared library symbol export
- decorations. */
-#if OS(WINDOWS) || (COMPILER_HAS_CLANG_DECLSPEC(dllimport) && COMPILER_HAS_CLANG_DECLSPEC(dllexport))
-#define USE_DECLSPEC_ATTRIBUTE 1
-#define USE_VISIBILITY_ATTRIBUTE 0
-#elif defined(__GNUC__)
-#define USE_DECLSPEC_ATTRIBUTE 0
-#define USE_VISIBILITY_ATTRIBUTE 1
-#else
-#define USE_DECLSPEC_ATTRIBUTE 0
-#define USE_VISIBILITY_ATTRIBUTE 0
-#endif
-
-/* Standard libraries */
-
-/* FIXME: ASSERT_ENABLED should defined in different, perhaps its own, file. */
-/* ASSERT_ENABLED should be true if we want the current compilation unit to
- do debug assertion checks unconditionally (e.g. treat a debug ASSERT
- like a RELEASE_ASSERT.
-*/
-#ifndef ASSERT_ENABLED
-#ifdef NDEBUG
-#define ASSERT_ENABLED 0
-#else
-#define ASSERT_ENABLED 1
-#endif
-#endif
-
-
-
-#if PLATFORM(COCOA)
-#define USE_CG 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_CA 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_GLIB 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_FREETYPE 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_HARFBUZZ 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_SOUP 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_WEBP 1
-#endif
-
#if PLATFORM(GTK)
#define GLIB_VERSION_MIN_REQUIRED GLIB_VERSION_2_36
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_6
@@ -164,28 +101,6 @@
#define SOUP_VERSION_MIN_REQUIRED SOUP_VERSION_2_42
#endif
-/* On Windows, use QueryPerformanceCounter by default */
-#if OS(WINDOWS)
-#define USE_QUERY_PERFORMANCE_COUNTER 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_CF 1
-#endif
-
-#if PLATFORM(COCOA) || (PLATFORM(GTK) || PLATFORM(WPE))
-#define USE_FILE_LOCK 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_FOUNDATION 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_NETWORK_CFDATA_ARRAY_CALLBACK 1
-#endif
-
-
#if PLATFORM(COCOA)
/* Cocoa defines a series of platform macros for debugging. */
/* Some of them are really annoying because they use common names (e.g. check()). */
@@ -194,144 +109,6 @@
#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
#endif
-#if PLATFORM(MAC)
-#define USE_APPKIT 1
-#endif
-
-#if PLATFORM(MAC)
-#define USE_PASSKIT 1
-#endif
-
-#if PLATFORM(MAC)
-#define USE_PLUGIN_HOST_PROCESS 1
-#endif
-
-#if PLATFORM(IOS_FAMILY)
-#define USE_UIKIT_EDITING 1
-#endif
-
-#if PLATFORM(IOS_FAMILY)
-#define USE_WEB_THREAD 1
-#endif
-
-#if !defined(USE_UIKIT_KEYBOARD_ADDITIONS) && (PLATFORM(IOS) || PLATFORM(MACCATALYST))
-#define USE_UIKIT_KEYBOARD_ADDITIONS 1
-#endif
-
-#if OS(UNIX)
-#define USE_PTHREADS 1
-#endif
-
-#if OS(DARWIN) && !PLATFORM(GTK)
-#define USE_ACCELERATE 1
-#endif
-
-#if OS(WINDOWS)
-#define USE_SYSTEM_MALLOC 1
-#endif
-
-#if !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64)
-#if CPU(ADDRESS64) || CPU(ARM64)
-#define USE_JSVALUE64 1
-#else
-#define USE_JSVALUE32_64 1
-#endif
-#endif /* !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64) */
-
-/* FIXME: This name should be more specific if it is only for use with CallFrame* */
-/* Use __builtin_frame_address(1) to get CallFrame* */
-#if COMPILER(GCC_COMPATIBLE) && (CPU(ARM64) || CPU(X86_64))
-#define USE_BUILTIN_FRAME_ADDRESS 1
-#endif
-
-#if PLATFORM(IOS)
-#define USE_PASSKIT 1
-#endif
-
-#if PLATFORM(IOS)
-#define USE_QUICK_LOOK 1
-#endif
-
-#if PLATFORM(IOS)
-#define USE_SYSTEM_PREVIEW 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_AVFOUNDATION 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_PROTECTION_SPACE_AUTH_CALLBACK 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_METAL 1
-#endif
-
-#if USE(GLIB)
-#include <wtf/glib/GTypedefs.h>
-#endif
-
-#if !defined(USE_EXPORT_MACROS) && (PLATFORM(COCOA) || OS(WINDOWS))
-#define USE_EXPORT_MACROS 1
-#endif
-
-#if PLATFORM(GTK) || PLATFORM(WPE)
-#define USE_UNIX_DOMAIN_SOCKETS 1
-#endif
-
-#if !defined(USE_IMLANG_FONT_LINK2)
-#define USE_IMLANG_FONT_LINK2 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_COREMEDIA 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_VIDEOTOOLBOX 1
-#endif
-
-#if !PLATFORM(WIN)
-#define USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR 1
-#endif
-
-#if PLATFORM(MAC)
-#define USE_COREAUDIO 1
-#endif
-
-#if !defined(USE_ZLIB)
-#define USE_ZLIB 1
-#endif
-
-#define USE_GRAMMAR_CHECKING 1
-
-#if PLATFORM(COCOA) || PLATFORM(GTK)
-#define USE_UNIFIED_TEXT_CHECKING 1
-#endif
-
-#if PLATFORM(MAC)
-#define USE_AUTOMATIC_TEXT_REPLACEMENT 1
-#endif
-
-#if PLATFORM(MAC)
-/* Some platforms provide UI for suggesting autocorrection. */
-#define USE_AUTOCORRECTION_PANEL 1
-#endif
-
-#if PLATFORM(COCOA)
-/* 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. */
-#define USE_MARKER_REMOVAL_UPON_EDITING 1
-#endif
-
-#if PLATFORM(MAC)
-#define USE_INSERTION_UNDO_GROUPING 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_AUDIO_SESSION 1
-#endif
-
#if COMPILER(MSVC)
#undef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS
@@ -339,119 +116,24 @@
#define __STDC_LIMIT_MACROS
#endif
+/* FIXME: Any remaining use of TARGET_OS_IPHONE should be removed outside of Apple only files and replaced with OS() checks. */
/* Set TARGET_OS_IPHONE to 0 by default to allow using it as a guard
* in cross-platform the same way as it is used in OS(DARWIN) code. */
#if !defined(TARGET_OS_IPHONE) && !OS(DARWIN)
#define TARGET_OS_IPHONE 0
#endif
-#if PLATFORM(COCOA)
-#define USE_MEDIATOOLBOX 1
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_OS_LOG 1
-#endif
-
-#if PLATFORM(COCOA) && USE(APPLE_INTERNAL_SDK)
-#define USE_OS_STATE 1
-#endif
-
-#if !defined(WTF_DEFAULT_EVENT_LOOP)
-#define WTF_DEFAULT_EVENT_LOOP 1
-#endif
-
-#if WTF_DEFAULT_EVENT_LOOP
-#if USE(GLIB)
-/* Use GLib's event loop abstraction. Primarily GTK port uses it. */
-#define USE_GLIB_EVENT_LOOP 1
-#elif OS(WINDOWS)
-/* Use Windows message pump abstraction.
- * Even if the port is AppleWin, we use the Windows message pump system for the event loop,
- * so that USE(WINDOWS_EVENT_LOOP) && USE(CF) can be true.
- * And PLATFORM(WIN) and PLATFORM(GTK) are exclusive. If the port is GTK,
- * PLATFORM(WIN) should be false. And in that case, GLib's event loop is used.
- */
-#define USE_WINDOWS_EVENT_LOOP 1
-#elif PLATFORM(COCOA)
-/* OS X and IOS. Use CoreFoundation & GCD abstraction. */
-#define USE_COCOA_EVENT_LOOP 1
-#else
-#define USE_GENERIC_EVENT_LOOP 1
-#endif
-#endif
-
-#if PLATFORM(COCOA)
-#define USE_MEDIAREMOTE 1
-#endif
-
+/* FIXME: This does not belong in Platform.h and should instead be included in another mechanism (compiler option, prefix header, config.h, etc) */
#if COMPILER(MSVC)
/* Enable strict runtime stack buffer checks. */
#pragma strict_gs_check(on)
#endif
-#if PLATFORM(MAC)
-#define USE_DICTATION_ALTERNATIVES 1
+/* FIXME: This does not belong in Platform.h and should instead be included in another mechanism (prefix header, config.h, etc) */
+#if USE(GLIB)
+#include <wtf/glib/GTypedefs.h>
#endif
-#if (PLATFORM(MAC) && USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || PLATFORM(IOS_FAMILY)
-#define USE_SOURCE_APPLICATION_AUDIT_DATA 1
-#endif
-
-#if PLATFORM(COCOA) && USE(CA)
-#define USE_IOSURFACE_CANVAS_BACKING_STORE 1
-#endif
-
-/* The override isn't needed on iOS family, as the default behavior is to not sniff. */
-/* FIXME: This should probably be enabled on 10.13.2 and newer, not just 10.14 and newer. */
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
-#define USE_CFNETWORK_CONTENT_ENCODING_SNIFFING_OVERRIDE 1
-#endif
-
-#if PLATFORM(MAC) || PLATFORM(WPE)
-/* FIXME: This really needs a descriptive name, this "new theme" was added in 2008. */
-#define USE_NEW_THEME 1
-#endif
-
-#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500
-#define USE_REALPATH_FOR_DLOPEN_PREFLIGHT 1
-#endif
-
-#if PLATFORM(IOS) || PLATFORM(MACCATALYST)
-#define USE_UICONTEXTMENU 1
-#endif
-
-#if PLATFORM(MAC) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || PLATFORM(WATCHOS) || PLATFORM(APPLETV)
-#define USE_PLATFORM_SYSTEM_FALLBACK_LIST 1
-#endif
-
-#if PLATFORM(IOS_FAMILY) || (!(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC) && (OS(LINUX) && (PLATFORM(GTK) || PLATFORM(WPE))))
-#define USE_BMALLOC_MEMORY_FOOTPRINT_API 1
-#endif
-
-
-
-
-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/AdditionalPlatform.h>)
-#include <WebKitAdditions/AdditionalPlatform.h>
-#endif
-
-#if USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/AdditionalFeatureDefines.h>)
-#include <WebKitAdditions/AdditionalFeatureDefines.h>
-#endif
-
-/* __PLATFORM_INDIRECT__ ensures that users #include <wtf/Platform.h> rather than wtf/FeatureDefines.h directly. */
-#define __PLATFORM_INDIRECT__
-
-/* Include feature macros */
-#include <wtf/PlatformEnable.h>
-
-#undef __PLATFORM_INDIRECT__
-
-
-
-/* FIXME: The following are currenly positioned at the bottom of this file as they are currently dependent on ENABLE or USE macros. */
-
/* FIXME: The availability of RSA_PSS should not depend on the policy decision to USE(GCRYPT). */
#if PLATFORM(MAC) || PLATFORM(IOS) || PLATFORM(MACCATALYST) || USE(GCRYPT)
#define HAVE_RSA_PSS 1
diff --git a/Source/WTF/wtf/PlatformEnable.h b/Source/WTF/wtf/PlatformEnable.h
index 5fffb85..b462b35 100644
--- a/Source/WTF/wtf/PlatformEnable.h
+++ b/Source/WTF/wtf/PlatformEnable.h
@@ -32,6 +32,8 @@
#error "Please #include <wtf/Platform.h> instead of this file directly."
#endif
+#define ENABLE(WTF_FEATURE) (defined ENABLE_##WTF_FEATURE && ENABLE_##WTF_FEATURE)
+
/* Use this file to list _all_ ENABLE() macros. Define the macros to be one of the following values:
* - "0" disables the feature by default. The feature can still be enabled for a specific port or environment.
* - "1" enables the feature by default. The feature can still be disabled for a specific port or environment.
@@ -52,6 +54,20 @@
* Get the list of features enabled by default for a PLATFORM(XXX): gcc -E -dM -I. -DWTF_PLATFORM_XXX "wtf/Platform.h" | grep "ENABLE_\w\+ 1" | cut -d' ' -f2 | sort
*/
+
+/* FIXME: This should be renamed to ENABLE_ASSERTS for consistency and so it can be used as ENABLE(ASSERTS). */
+/* ASSERT_ENABLED should be true if we want the current compilation unit to
+ do debug assertion checks unconditionally (e.g. treat a debug ASSERT
+ like a RELEASE_ASSERT.
+*/
+#ifndef ASSERT_ENABLED
+#ifdef NDEBUG
+#define ASSERT_ENABLED 0
+#else
+#define ASSERT_ENABLED 1
+#endif
+#endif
+
/* FIXME: Move out the PLATFORM specific rules into platform specific files. */
/* --------- Apple iOS (but not macOS) port --------- */
diff --git a/Source/WTF/wtf/PlatformUse.h b/Source/WTF/wtf/PlatformUse.h
new file mode 100644
index 0000000..53d39a2
--- /dev/null
+++ b/Source/WTF/wtf/PlatformUse.h
@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2006-2020 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2009 Torch Mobile, Inc.
+ * Copyright (C) 2010, 2011 Research In Motion Limited. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#ifndef __PLATFORM_INDIRECT__
+#error "Please #include <wtf/Platform.h> instead of this file directly."
+#endif
+
+
+/* USE() - use a particular third-party library or optional OS service */
+#define USE(WTF_FEATURE) (defined USE_##WTF_FEATURE && USE_##WTF_FEATURE)
+
+
+#if PLATFORM(COCOA)
+#if defined __has_include && __has_include(<CoreFoundation/CFPriv.h>)
+#define USE_APPLE_INTERNAL_SDK 1
+#endif
+#endif
+
+/* MIPS requires allocators to use aligned memory */
+#if CPU(MIPS) || CPU(MIPS64)
+#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
+#endif
+
+/*ARMv5TE requires allocators to use aligned memory*/
+#if defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__)
+#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
+#endif
+
+/*ARMv5TE requires allocators to use aligned memory*/
+#if defined(__TARGET_ARCH_5E) || defined(__TARGET_ARCH_5TE) || defined(__TARGET_ARCH_5TEJ)
+#define USE_ARENA_ALLOC_ALIGNMENT_INTEGER 1
+#endif
+
+/* Export macro support. Detects the attributes available for shared library symbol export
+ decorations. */
+#if OS(WINDOWS) || (COMPILER_HAS_CLANG_DECLSPEC(dllimport) && COMPILER_HAS_CLANG_DECLSPEC(dllexport))
+#define USE_DECLSPEC_ATTRIBUTE 1
+#elif defined(__GNUC__)
+#define USE_VISIBILITY_ATTRIBUTE 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_CG 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_CA 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_GLIB 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_FREETYPE 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_HARFBUZZ 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_SOUP 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_WEBP 1
+#endif
+
+/* On Windows, use QueryPerformanceCounter by default */
+#if OS(WINDOWS)
+#define USE_QUERY_PERFORMANCE_COUNTER 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_CF 1
+#endif
+
+#if PLATFORM(COCOA) || (PLATFORM(GTK) || PLATFORM(WPE))
+#define USE_FILE_LOCK 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_FOUNDATION 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_NETWORK_CFDATA_ARRAY_CALLBACK 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_APPKIT 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_PASSKIT 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_PLUGIN_HOST_PROCESS 1
+#endif
+
+#if PLATFORM(IOS_FAMILY)
+#define USE_UIKIT_EDITING 1
+#endif
+
+#if PLATFORM(IOS_FAMILY)
+#define USE_WEB_THREAD 1
+#endif
+
+#if !defined(USE_UIKIT_KEYBOARD_ADDITIONS) && (PLATFORM(IOS) || PLATFORM(MACCATALYST))
+#define USE_UIKIT_KEYBOARD_ADDITIONS 1
+#endif
+
+#if OS(UNIX)
+#define USE_PTHREADS 1
+#endif
+
+#if OS(DARWIN) && !PLATFORM(GTK)
+#define USE_ACCELERATE 1
+#endif
+
+#if OS(WINDOWS)
+#define USE_SYSTEM_MALLOC 1
+#endif
+
+#if !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64)
+#if CPU(ADDRESS64) || CPU(ARM64)
+#define USE_JSVALUE64 1
+#else
+#define USE_JSVALUE32_64 1
+#endif
+#endif /* !defined(USE_JSVALUE64) && !defined(USE_JSVALUE32_64) */
+
+/* FIXME: This name should be more specific if it is only for use with CallFrame* */
+/* Use __builtin_frame_address(1) to get CallFrame* */
+#if COMPILER(GCC_COMPATIBLE) && (CPU(ARM64) || CPU(X86_64))
+#define USE_BUILTIN_FRAME_ADDRESS 1
+#endif
+
+#if PLATFORM(IOS)
+#define USE_PASSKIT 1
+#endif
+
+#if PLATFORM(IOS)
+#define USE_QUICK_LOOK 1
+#endif
+
+#if PLATFORM(IOS)
+#define USE_SYSTEM_PREVIEW 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_AVFOUNDATION 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_PROTECTION_SPACE_AUTH_CALLBACK 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_METAL 1
+#endif
+
+#if !defined(USE_EXPORT_MACROS) && (PLATFORM(COCOA) || OS(WINDOWS))
+#define USE_EXPORT_MACROS 1
+#endif
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+#define USE_UNIX_DOMAIN_SOCKETS 1
+#endif
+
+#if !defined(USE_IMLANG_FONT_LINK2)
+#define USE_IMLANG_FONT_LINK2 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_COREMEDIA 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_VIDEOTOOLBOX 1
+#endif
+
+#if !PLATFORM(WIN)
+#define USE_REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_COREAUDIO 1
+#endif
+
+#if !defined(USE_ZLIB)
+#define USE_ZLIB 1
+#endif
+
+#define USE_GRAMMAR_CHECKING 1
+
+#if PLATFORM(COCOA) || PLATFORM(GTK)
+#define USE_UNIFIED_TEXT_CHECKING 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_AUTOMATIC_TEXT_REPLACEMENT 1
+#endif
+
+#if PLATFORM(MAC)
+/* Some platforms provide UI for suggesting autocorrection. */
+#define USE_AUTOCORRECTION_PANEL 1
+#endif
+
+#if PLATFORM(COCOA)
+/* 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. */
+#define USE_MARKER_REMOVAL_UPON_EDITING 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_INSERTION_UNDO_GROUPING 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_AUDIO_SESSION 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_MEDIATOOLBOX 1
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_OS_LOG 1
+#endif
+
+#if PLATFORM(COCOA) && USE(APPLE_INTERNAL_SDK)
+#define USE_OS_STATE 1
+#endif
+
+#if !defined(WTF_DEFAULT_EVENT_LOOP)
+#define WTF_DEFAULT_EVENT_LOOP 1
+#endif
+
+#if WTF_DEFAULT_EVENT_LOOP
+#if USE(GLIB)
+/* Use GLib's event loop abstraction. Primarily GTK port uses it. */
+#define USE_GLIB_EVENT_LOOP 1
+#elif OS(WINDOWS)
+/* Use Windows message pump abstraction.
+ * Even if the port is AppleWin, we use the Windows message pump system for the event loop,
+ * so that USE(WINDOWS_EVENT_LOOP) && USE(CF) can be true.
+ * And PLATFORM(WIN) and PLATFORM(GTK) are exclusive. If the port is GTK,
+ * PLATFORM(WIN) should be false. And in that case, GLib's event loop is used.
+ */
+#define USE_WINDOWS_EVENT_LOOP 1
+#elif PLATFORM(COCOA)
+/* OS X and IOS. Use CoreFoundation & GCD abstraction. */
+#define USE_COCOA_EVENT_LOOP 1
+#else
+#define USE_GENERIC_EVENT_LOOP 1
+#endif
+#endif
+
+#if PLATFORM(COCOA)
+#define USE_MEDIAREMOTE 1
+#endif
+
+#if PLATFORM(MAC)
+#define USE_DICTATION_ALTERNATIVES 1
+#endif
+
+#if (PLATFORM(MAC) && USE(APPLE_INTERNAL_SDK) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || PLATFORM(IOS_FAMILY)
+#define USE_SOURCE_APPLICATION_AUDIT_DATA 1
+#endif
+
+#if PLATFORM(COCOA) && USE(CA)
+#define USE_IOSURFACE_CANVAS_BACKING_STORE 1
+#endif
+
+/* The override isn't needed on iOS family, as the default behavior is to not sniff. */
+/* FIXME: This should probably be enabled on 10.13.2 and newer, not just 10.14 and newer. */
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
+#define USE_CFNETWORK_CONTENT_ENCODING_SNIFFING_OVERRIDE 1
+#endif
+
+#if PLATFORM(MAC) || PLATFORM(WPE)
+/* FIXME: This really needs a descriptive name, this "new theme" was added in 2008. */
+#define USE_NEW_THEME 1
+#endif
+
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500
+#define USE_REALPATH_FOR_DLOPEN_PREFLIGHT 1
+#endif
+
+#if PLATFORM(IOS) || PLATFORM(MACCATALYST)
+#define USE_UICONTEXTMENU 1
+#endif
+
+#if PLATFORM(MAC) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000) || PLATFORM(WATCHOS) || PLATFORM(APPLETV)
+#define USE_PLATFORM_SYSTEM_FALLBACK_LIST 1
+#endif
+
+#if PLATFORM(IOS_FAMILY) || (!(defined(USE_SYSTEM_MALLOC) && USE_SYSTEM_MALLOC) && (OS(LINUX) && (PLATFORM(GTK) || PLATFORM(WPE))))
+#define USE_BMALLOC_MEMORY_FOOTPRINT_API 1
+#endif