Prefix remaining OS defines with FML_ namespace (flutter/engine#31172)

This commit is contained in:
Brandon DeRosier 2022-01-31 14:31:44 -08:00 committed by GitHub
parent aa080e821d
commit 925224a9ee
26 changed files with 73 additions and 73 deletions

View File

@ -122,7 +122,7 @@ TEST(FrameTimingsRecorderTest, RecordRasterTimesWithCache) {
}
// Windows and Fuchsia don't allow testing with killed by signal.
#if !defined(OS_FUCHSIA) && !defined(OS_WIN) && \
#if !defined(OS_FUCHSIA) && !defined(FML_OS_WIN) && \
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
TEST(FrameTimingsRecorderTest, ThrowWhenRecordBuildBeforeVsync) {

View File

@ -11,7 +11,7 @@
#include <csignal>
#include <sstream>
#if OS_WIN
#if FML_OS_WIN
#include <crtdbg.h>
#include <debugapi.h>
#endif
@ -132,7 +132,7 @@ static void ToggleSignalHandlers(bool set) {
}
void InstallCrashHandler() {
#if OS_WIN
#if FML_OS_WIN
if (!IsDebuggerPresent()) {
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);

View File

@ -4,8 +4,8 @@
// This file adds defines about the platform we're currently building on.
// Operating System:
// OS_WIN / FML_OS_MACOSX / FML_OS_LINUX / FML_OS_POSIX (MACOSX or LINUX) /
// FML_OS_NACL (NACL_SFI or NACL_NONSFI) / FML_OS_NACL_SFI /
// FML_OS_WIN / FML_OS_MACOSX / FML_OS_LINUX / FML_OS_POSIX (MACOSX or LINUX)
// / FML_OS_NACL (NACL_SFI or NACL_NONSFI) / FML_OS_NACL_SFI /
// FML_OS_NACL_NONSFI
// Compiler:
// COMPILER_MSVC / COMPILER_GCC
@ -27,7 +27,7 @@
#include <TargetConditionals.h>
#define FML_OS_MACOSX 1
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#define OS_IOS 1
#define FML_OS_IOS 1
#endif // defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#elif defined(__linux__)
#define FML_OS_LINUX 1
@ -38,7 +38,7 @@
#define LIBC_GLIBC 1
#endif
#elif defined(_WIN32)
#define OS_WIN 1
#define FML_OS_WIN 1
#elif defined(__FreeBSD__)
#define FML_OS_FREEBSD 1
#elif defined(__OpenBSD__)
@ -51,10 +51,10 @@
#error Please add support for your platform in flutter/fml/build_config.h
#endif
// For access to standard BSD features, use OS_BSD instead of a
// For access to standard BSD features, use FML_OS_BSD instead of a
// more specific macro.
#if defined(FML_OS_FREEBSD) || defined(FML_OS_OPENBSD)
#define OS_BSD 1
#define FML_OS_BSD 1
#endif
// For access to standard POSIXish features, use FML_OS_POSIX instead of a

View File

@ -9,7 +9,7 @@
#include "flutter/fml/build_config.h"
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
// Windows has no concept of EINTR.
#define FML_HANDLE_EINTR(x) (x)
@ -38,6 +38,6 @@
eintr_wrapper_result; \
})
#endif // defined(OS_WIN)
#endif // defined(FML_OS_WIN)
#endif // FLUTTER_FML_EINTR_WRAPPER_H_

View File

@ -228,7 +228,7 @@ TEST(FileTest, CanStopVisitEarly) {
ASSERT_TRUE(fml::UnlinkDirectory(dir.fd(), "a"));
}
#if OS_WIN
#if FML_OS_WIN
#define AtomicWriteTest DISABLED_AtomicWriteTest
#else
#define AtomicWriteTest AtomicWriteTest

View File

@ -11,7 +11,7 @@
#if defined(FML_OS_ANDROID)
#include <android/log.h>
#elif defined(OS_IOS)
#elif defined(FML_OS_IOS)
#include <syslog.h>
#elif defined(OS_FUCHSIA)
#include <lib/syslog/global.h>
@ -94,7 +94,7 @@ LogMessage::~LogMessage() {
break;
}
__android_log_write(priority, "flutter", stream_.str().c_str());
#elif defined(OS_IOS)
#elif defined(FML_OS_IOS)
syslog(LOG_ALERT, "%s", stream_.str().c_str());
#elif defined(OS_FUCHSIA)
fx_log_severity_t fx_severity;

View File

@ -82,7 +82,7 @@ class FileMapping final : public Mapping {
uint8_t* mapping_ = nullptr;
uint8_t* mutable_mapping_ = nullptr;
#if OS_WIN
#if FML_OS_WIN
fml::UniqueFD mapping_handle_;
#endif

View File

@ -12,7 +12,7 @@
#include "flutter/fml/logging.h"
#include "flutter/fml/macros.h"
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
#include <windows.h>
#else
#include <pthread.h>
@ -30,7 +30,7 @@ namespace fml {
// there's a small space cost to having even an empty class. )
class ThreadChecker final {
public:
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
ThreadChecker() : self_(GetCurrentThreadId()) {}
~ThreadChecker() {}

View File

@ -21,7 +21,7 @@
#include "flutter/fml/platform/fuchsia/message_loop_fuchsia.h"
#elif FML_OS_LINUX
#include "flutter/fml/platform/linux/message_loop_linux.h"
#elif OS_WIN
#elif FML_OS_WIN
#include "flutter/fml/platform/win/message_loop_win.h"
#endif
@ -36,7 +36,7 @@ fml::RefPtr<MessageLoopImpl> MessageLoopImpl::Create() {
return fml::MakeRefCounted<MessageLoopFuchsia>();
#elif FML_OS_LINUX
return fml::MakeRefCounted<MessageLoopLinux>();
#elif OS_WIN
#elif FML_OS_WIN
return fml::MakeRefCounted<MessageLoopWin>();
#else
return nullptr;

View File

@ -18,7 +18,7 @@
#include "gtest/gtest.h"
#define TIMESENSITIVE(x) TimeSensitiveTest_##x
#if OS_WIN
#if FML_OS_WIN
#define PLATFORM_SPECIFIC_CAPTURE(...) [ __VA_ARGS__, count ]
#else
#define PLATFORM_SPECIFIC_CAPTURE(...) [__VA_ARGS__]

View File

@ -12,20 +12,20 @@
#include "flutter/fml/memory/ref_counted.h"
#include "flutter/fml/memory/ref_ptr.h"
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
#include <windows.h>
#endif // defined(OS_WIN)
#endif // defined(FML_OS_WIN)
namespace fml {
class NativeLibrary : public fml::RefCountedThreadSafe<NativeLibrary> {
public:
#if OS_WIN
#if FML_OS_WIN
using Handle = HMODULE;
using SymbolHandle = FARPROC;
#else // OS_WIN
#else // FML_OS_WIN
using Handle = void*;
using SymbolHandle = void*;
#endif // OS_WIN
#endif // FML_OS_WIN
static fml::RefPtr<NativeLibrary> Create(const char* path);

View File

@ -19,11 +19,11 @@ std::string JoinPaths(std::initializer_list<std::string> components) {
i++;
stream << component;
if (i != size) {
#if OS_WIN
#if FML_OS_WIN
stream << "\\";
#else // OS_WIN
#else // FML_OS_WIN
stream << "/";
#endif // OS_WIN
#endif // FML_OS_WIN
}
}
return stream.str();

View File

@ -59,7 +59,7 @@ class PlatformSemaphore {
} // namespace fml
#elif OS_WIN
#elif FML_OS_WIN
#include <windows.h>
namespace fml {

View File

@ -13,7 +13,7 @@
#include "flutter/fml/message_loop.h"
#include "flutter/fml/synchronization/waitable_event.h"
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
#include <windows.h>
#elif defined(OS_FUCHSIA)
#include <lib/zx/thread.h>
@ -55,7 +55,7 @@ void Thread::Join() {
thread_->join();
}
#if defined(OS_WIN)
#if defined(FML_OS_WIN)
// The information on how to set the thread name comes from
// a MSDN article: http://msdn2.microsoft.com/en-us/library/xcb2z8hs.aspx
const DWORD kVCThreadNameException = 0x406D1388;
@ -75,7 +75,7 @@ void Thread::SetCurrentThreadName(const std::string& name) {
pthread_setname_np(name.c_str());
#elif defined(FML_OS_LINUX) || defined(FML_OS_ANDROID)
pthread_setname_np(pthread_self(), name.c_str());
#elif defined(OS_WIN)
#elif defined(FML_OS_WIN)
THREADNAME_INFO info;
info.dwType = 0x1000;
info.szName = name.c_str();

View File

@ -9,7 +9,7 @@
namespace fml {
namespace internal {
#if OS_WIN
#if FML_OS_WIN
namespace os_win {
@ -22,7 +22,7 @@ void UniqueFDTraits::Free_Handle(HANDLE fd) {
} // namespace os_win
#else // OS_WIN
#else // FML_OS_WIN
namespace os_unix {
@ -36,7 +36,7 @@ void UniqueDirTraits::Free(DIR* dir) {
} // namespace os_unix
#endif // OS_WIN
#endif // FML_OS_WIN
} // namespace internal
} // namespace fml

View File

@ -8,20 +8,20 @@
#include "flutter/fml/build_config.h"
#include "flutter/fml/unique_object.h"
#if OS_WIN
#if FML_OS_WIN
#include <windows.h>
#include <map>
#include <mutex>
#include <optional>
#else // OS_WIN
#else // FML_OS_WIN
#include <dirent.h>
#include <unistd.h>
#endif // OS_WIN
#endif // FML_OS_WIN
namespace fml {
namespace internal {
#if OS_WIN
#if FML_OS_WIN
namespace os_win {
@ -69,7 +69,7 @@ struct UniqueFDTraits {
} // namespace os_win
#else // OS_WIN
#else // FML_OS_WIN
namespace os_unix {
@ -87,20 +87,20 @@ struct UniqueDirTraits {
} // namespace os_unix
#endif // OS_WIN
#endif // FML_OS_WIN
} // namespace internal
#if OS_WIN
#if FML_OS_WIN
using UniqueFD = UniqueObject<HANDLE, internal::os_win::UniqueFDTraits>;
#else // OS_WIN
#else // FML_OS_WIN
using UniqueFD = UniqueObject<int, internal::os_unix::UniqueFDTraits>;
using UniqueDir = UniqueObject<DIR*, internal::os_unix::UniqueDirTraits>;
#endif // OS_WIN
#endif // FML_OS_WIN
} // namespace fml

View File

@ -10,7 +10,7 @@
#include "third_party/skia/src/codec/SkCodecImageGenerator.h"
#ifdef FML_OS_MACOSX
#include "third_party/skia/include/ports/SkImageGeneratorCG.h"
#elif OS_WIN
#elif FML_OS_WIN
#include "third_party/skia/include/ports/SkImageGeneratorWIC.h"
#endif
@ -32,7 +32,7 @@ ImageGeneratorRegistry::ImageGeneratorRegistry() : weak_factory_(this) {
std::move(generator));
},
0);
#elif OS_WIN
#elif FML_OS_WIN
AddFactory(
[](sk_sp<SkData> buffer) {
auto generator = SkImageGeneratorWIC::MakeFromEncodedWIC(buffer);

View File

@ -13,7 +13,7 @@
#if defined(FML_OS_ANDROID)
#include <android/log.h>
#elif defined(OS_IOS)
#elif defined(FML_OS_IOS)
extern "C" {
// Cannot import the syslog.h header directly because of macro collision.
extern void syslog(int, const char*, ...);
@ -219,7 +219,7 @@ void UIDartState::LogMessage(const std::string& tag,
#if defined(FML_OS_ANDROID)
__android_log_print(ANDROID_LOG_INFO, tag.c_str(), "%.*s",
(int)message.size(), message.c_str());
#elif defined(OS_IOS)
#elif defined(FML_OS_IOS)
std::stringstream stream;
if (tag.size() > 0) {
stream << tag << ": ";

View File

@ -25,7 +25,7 @@ const char* DartSnapshot::kIsolateInstructionsSymbol =
// data through symbols that are statically linked into the executable.
// On other platforms this data is obtained by a dynamic symbol lookup.
#define DART_SNAPSHOT_STATIC_LINK \
((OS_WIN || FML_OS_ANDROID) && FLUTTER_JIT_RUNTIME)
((FML_OS_WIN || FML_OS_ANDROID) && FLUTTER_JIT_RUNTIME)
#if !DART_SNAPSHOT_STATIC_LINK

View File

@ -221,7 +221,7 @@ static std::vector<const char*> ProfilingFlags(bool enable_profiling) {
// This instructs the profiler to walk C++ frames, and to include
// them in the profile.
"--profile-vm",
#if OS_IOS && FML_ARCH_CPU_ARM_FAMILY && FML_ARCH_CPU_ARMEL
#if FML_OS_IOS && FML_ARCH_CPU_ARM_FAMILY && FML_ARCH_CPU_ARMEL
// Set the profiler interrupt period to 500Hz instead of the
// default 1000Hz on 32-bit iOS devices to reduce average and worst
// case frame build times.
@ -232,7 +232,7 @@ static std::vector<const char*> ProfilingFlags(bool enable_profiling) {
"--profile_period=2000",
#else
"--profile_period=1000",
#endif // OS_IOS && FML_ARCH_CPU_ARM_FAMILY && FML_ARCH_CPU_ARMEL
#endif // FML_OS_IOS && FML_ARCH_CPU_ARM_FAMILY && FML_ARCH_CPU_ARMEL
};
} else {
return {"--no-profiler"};
@ -341,7 +341,7 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
#endif // !OS_FUCHSIA
#if (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
#if !OS_IOS && !FML_OS_MACOSX
#if !FML_OS_IOS && !FML_OS_MACOSX
// Debug mode uses the JIT, disable code page write protection to avoid
// memory page protection changes before and after every compilation.
PushBackAll(&args, kDartWriteProtectCodeArgs,
@ -361,7 +361,7 @@ DartVM::DartVM(std::shared_ptr<const DartVMData> vm_data,
PushBackAll(&args, kDartDisableIntegerDivisionArgs,
fml::size(kDartDisableIntegerDivisionArgs));
#endif // TARGET_CPU_ARM
#endif // !OS_IOS && !FML_OS_MACOSX
#endif // !FML_OS_IOS && !FML_OS_MACOSX
#endif // (FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
if (enable_asserts) {

View File

@ -33,7 +33,7 @@
// Being extra careful and adding additional landmines that will prevent
// compilation of this TU in an incorrect runtime mode.
static_assert(OS_IOS, "This translation unit is iOS specific.");
static_assert(FML_OS_IOS, "This translation unit is iOS specific.");
static_assert(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG,
"This translation unit must only be compiled in the debug "
"runtime mode as it "

View File

@ -10,8 +10,8 @@
namespace flutter {
#define TRACING_CHECKS_NECESSARY \
OS_IOS && !TARGET_OS_SIMULATOR && \
#define TRACING_CHECKS_NECESSARY \
FML_OS_IOS && !TARGET_OS_SIMULATOR && \
(FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG)
enum class TracingResult {

View File

@ -20,11 +20,11 @@
#include "third_party/dart/runtime/include/dart_native_api.h"
#if !defined(FLUTTER_NO_EXPORT)
#if OS_WIN
#if FML_OS_WIN
#define FLUTTER_EXPORT __declspec(dllexport)
#else // OS_WIN
#else // FML_OS_WIN
#define FLUTTER_EXPORT __attribute__((visibility("default")))
#endif // OS_WIN
#endif // FML_OS_WIN
#endif // !FLUTTER_NO_EXPORT
extern "C" {
@ -95,7 +95,7 @@ static FlutterEngineResult LogEmbedderError(FlutterEngineResult code,
const char* function,
const char* file,
int line) {
#if OS_WIN
#if FML_OS_WIN
constexpr char kSeparator = '\\';
#else
constexpr char kSeparator = '/';
@ -183,18 +183,18 @@ static bool IsRendererValid(const FlutterRendererConfig* config) {
return false;
}
#if FML_OS_LINUX || OS_WIN
#if FML_OS_LINUX || FML_OS_WIN
static void* DefaultGLProcResolver(const char* name) {
static fml::RefPtr<fml::NativeLibrary> proc_library =
#if FML_OS_LINUX
fml::NativeLibrary::CreateForCurrentProcess();
#elif OS_WIN // FML_OS_LINUX
#elif FML_OS_WIN // FML_OS_LINUX
fml::NativeLibrary::Create("opengl32.dll");
#endif // OS_WIN
#endif // FML_OS_WIN
return static_cast<void*>(
const_cast<uint8_t*>(proc_library->ResolveSymbol(name)));
}
#endif // FML_OS_LINUX || OS_WIN
#endif // FML_OS_LINUX || FML_OS_WIN
static flutter::Shell::CreateCallback<flutter::PlatformView>
InferOpenGLPlatformViewCreationCallback(
@ -284,7 +284,7 @@ InferOpenGLPlatformViewCreationCallback(
return ptr(user_data, gl_proc_name);
};
} else {
#if FML_OS_LINUX || OS_WIN
#if FML_OS_LINUX || FML_OS_WIN
gl_proc_resolver = DefaultGLProcResolver;
#endif
}

View File

@ -15,9 +15,9 @@
#include <unistd.h>
#endif // FML_OS_MACOSX
#if OS_WIN
#if FML_OS_WIN
#include <windows.h>
#endif // OS_WIN
#endif // FML_OS_WIN
namespace flutter {
namespace testing {
@ -54,7 +54,7 @@ DebuggerStatus GetDebuggerStatus() {
return ((info.kp_proc.p_flag & P_TRACED) != 0) ? DebuggerStatus::kAttached
: DebuggerStatus::kDontKnow;
#elif OS_WIN
#elif FML_OS_WIN
return ::IsDebuggerPresent() ? DebuggerStatus::kAttached
: DebuggerStatus::kDontKnow;

View File

@ -13,9 +13,9 @@
#include "flutter/testing/test_timeout_listener.h"
#include "gtest/gtest.h"
#ifdef OS_IOS
#ifdef FML_OS_IOS
#include <asl.h>
#endif // OS_IOS
#endif // FML_OS_IOS
std::optional<fml::TimeDelta> GetTestTimeoutFromArgs(int argc, char** argv) {
const auto command_line = fml::CommandLineFromArgcArgv(argc, argv);
@ -37,12 +37,12 @@ std::optional<fml::TimeDelta> GetTestTimeoutFromArgs(int argc, char** argv) {
int main(int argc, char** argv) {
fml::InstallCrashHandler();
#ifdef OS_IOS
#ifdef FML_OS_IOS
asl_log_descriptor(NULL, NULL, ASL_LEVEL_NOTICE, STDOUT_FILENO,
ASL_LOG_DESCRIPTOR_WRITE);
asl_log_descriptor(NULL, NULL, ASL_LEVEL_ERR, STDERR_FILENO,
ASL_LOG_DESCRIPTOR_WRITE);
#endif // OS_IOS
#endif // FML_OS_IOS
::testing::InitGoogleTest(&argc, argv);

View File

@ -8,7 +8,7 @@
#ifdef FML_OS_MACOSX
#define VULKAN_SO_PATH "libvk_swiftshader.dylib"
#elif OS_WIN
#elif FML_OS_WIN
#define VULKAN_SO_PATH "vk_swiftshader.dll"
#else
#define VULKAN_SO_PATH "libvk_swiftshader.so"