From cc28f284349a547e607dad68f97a67a504ed993f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 9 Jan 2025 08:42:20 -0800 Subject: [PATCH] Drop dependency on native/fb (#48568) Summary: We only need this dependency for internal builds, as we only rely on fbjni, which is its own open-source project. This code was forked for open-source and not synced in anyway, which is a potential liability. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D67796633 --- .../ReactAndroid/src/main/jni/CMakeLists.txt | 1 - .../main/jni/first-party/fb/CMakeLists.txt | 31 -- .../src/main/jni/first-party/fb/assert.cpp | 39 -- .../main/jni/first-party/fb/include/fb/ALog.h | 82 ---- .../jni/first-party/fb/include/fb/Build.h | 31 -- .../jni/first-party/fb/include/fb/Countable.h | 45 --- .../jni/first-party/fb/include/fb/Doxyfile | 18 - .../first-party/fb/include/fb/Environment.h | 93 ----- .../fb/include/fb/ProgramLocation.h | 58 --- .../jni/first-party/fb/include/fb/RefPtr.h | 266 ------------- .../fb/include/fb/StaticInitialized.h | 37 -- .../first-party/fb/include/fb/ThreadLocal.h | 112 ------ .../jni/first-party/fb/include/fb/assert.h | 43 --- .../main/jni/first-party/fb/include/fb/log.h | 350 ------------------ .../first-party/fb/include/fb/noncopyable.h | 20 - .../first-party/fb/include/fb/nonmovable.h | 20 - .../first-party/fb/include/fb/visibility.h | 10 - .../src/main/jni/first-party/fb/log.cpp | 102 ----- .../jni/react/jni/CatalystInstanceImpl.cpp | 1 - .../jni/react/jni/JniJSModulesUnbundle.cpp | 7 +- .../src/main/jni/react/jni/ProxyExecutor.cpp | 1 - 21 files changed, 3 insertions(+), 1364 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/assert.cpp delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ALog.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Build.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Countable.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Doxyfile delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Environment.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ProgramLocation.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/RefPtr.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/StaticInitialized.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ThreadLocal.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/assert.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/log.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/noncopyable.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/nonmovable.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/visibility.h delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/first-party/fb/log.cpp diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 12f2ff9c038271..e308584f0d1b89 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -122,7 +122,6 @@ add_react_common_subdir(react/timing) # ReactAndroid JNI targets add_react_build_subdir(generated/source/codegen/jni) -add_react_android_subdir(src/main/jni/first-party/fb) add_react_android_subdir(src/main/jni/first-party/fbgloginit) add_react_android_subdir(src/main/jni/first-party/yogajni) add_react_android_subdir(src/main/jni/first-party/jni-lib-merge) diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt deleted file mode 100644 index 572123bb390acf..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright (c) Meta Platforms, Inc. and affiliates. -# -# This source code is licensed under the MIT license found in the -# LICENSE file in the root directory of this source tree. - -cmake_minimum_required(VERSION 3.13) -set(CMAKE_VERBOSE_MAKEFILE on) - -add_library(fb - STATIC - assert.cpp - log.cpp) - -add_compile_options( - -DLOG_TAG=\"libfb\" - -DDISABLE_CPUCAP - -DDISABLE_XPLAT - -fexceptions - -frtti - -Wno-unused-parameter - -Wno-error=unused-but-set-variable - -DHAVE_POSIX_CLOCKS -) -if(NOT ${CMAKE_BUILD_TYPE} MATCHES Debug) - add_compile_options(-DNDEBUG) -endif() - -# Yogacore needs to link towards android and log from the NDK libs -target_link_libraries(fb dl android log) - -target_include_directories(fb PUBLIC include) diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/assert.cpp b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/assert.cpp deleted file mode 100644 index 3ffd43a19fb38c..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/assert.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include - -#include -#include - -namespace facebook { - -#define ASSERT_BUF_SIZE 4096 -static char sAssertBuf[ASSERT_BUF_SIZE]; -static AssertHandler gAssertHandler; - -void assertInternal(const char* formatstr...) { - va_list va_args; - va_start(va_args, formatstr); - vsnprintf(sAssertBuf, sizeof(sAssertBuf), formatstr, va_args); - va_end(va_args); - if (gAssertHandler != NULL) { - gAssertHandler(sAssertBuf); - } - FBLOG(LOG_FATAL, "fbassert", "%s", sAssertBuf); - // crash at this specific address so that we can find our crashes easier - *(int*)0xdeadb00c = 0; - // let the compiler know we won't reach the end of the function - __builtin_unreachable(); -} - -void setAssertHandler(AssertHandler assertHandler) { - gAssertHandler = assertHandler; -} - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ALog.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ALog.h deleted file mode 100644 index 8d87f05327e9c1..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ALog.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/** @file ALog.h - * - * Very simple android only logging. Define LOG_TAG to enable the macros. - */ - -#pragma once - -#ifdef __ANDROID__ - -#include - -namespace facebook { -namespace alog { - -template -inline void -log(int level, const char* tag, const char* msg, ARGS... args) noexcept { - __android_log_print(level, tag, msg, args...); -} - -template -inline void log(int level, const char* tag, const char* msg) noexcept { - __android_log_write(level, tag, msg); -} - -template -inline void logv(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_VERBOSE, tag, msg, args...); -} - -template -inline void logd(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_DEBUG, tag, msg, args...); -} - -template -inline void logi(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_INFO, tag, msg, args...); -} - -template -inline void logw(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_WARN, tag, msg, args...); -} - -template -inline void loge(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_ERROR, tag, msg, args...); -} - -template -inline void logf(const char* tag, const char* msg, ARGS... args) noexcept { - log(ANDROID_LOG_FATAL, tag, msg, args...); -} - -#ifdef LOG_TAG -#define ALOGV(...) ::facebook::alog::logv(LOG_TAG, __VA_ARGS__) -#define ALOGD(...) ::facebook::alog::logd(LOG_TAG, __VA_ARGS__) -#define ALOGI(...) ::facebook::alog::logi(LOG_TAG, __VA_ARGS__) -#define ALOGW(...) ::facebook::alog::logw(LOG_TAG, __VA_ARGS__) -#define ALOGE(...) ::facebook::alog::loge(LOG_TAG, __VA_ARGS__) -#define ALOGF(...) ::facebook::alog::logf(LOG_TAG, __VA_ARGS__) -#endif - -} // namespace alog -} // namespace facebook - -#else -#define ALOGV(...) ((void)0) -#define ALOGD(...) ((void)0) -#define ALOGI(...) ((void)0) -#define ALOGW(...) ((void)0) -#define ALOGE(...) ((void)0) -#define ALOGF(...) ((void)0) -#endif diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Build.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Build.h deleted file mode 100644 index 94916b1670d320..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Build.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#if defined(__ANDROID__) -#include -#endif - -namespace facebook { -namespace build { - -struct Build { - static int getAndroidSdk() { - static auto android_sdk = ([] { - char sdk_version_str[PROP_VALUE_MAX]; - __system_property_get("ro.build.version.sdk", sdk_version_str); - return atoi(sdk_version_str); - })(); - return android_sdk; - } -}; - -} // namespace build -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Countable.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Countable.h deleted file mode 100644 index 6ba2439b9b916d..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Countable.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once -#include -#include -#include -#include -#include - -namespace facebook { - -class Countable : public noncopyable, public nonmovable { - public: - // RefPtr expects refcount to start at 0 - Countable() : m_refcount(0) {} - virtual ~Countable() { - FBASSERT(m_refcount == 0); - } - - private: - void ref() { - ++m_refcount; - } - - void unref() { - if (0 == --m_refcount) { - delete this; - } - } - - bool hasOnlyOneRef() const { - return m_refcount == 1; - } - - template - friend class RefPtr; - std::atomic m_refcount; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Doxyfile b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Doxyfile deleted file mode 100644 index 8b4df6a7c986ee..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Doxyfile +++ /dev/null @@ -1,18 +0,0 @@ -PROJECT_NAME = "Facebook JNI" -PROJECT_BRIEF = "Helper library to provide safe and convenient access to JNI with very low overhead" -JAVADOC_AUTOBRIEF = YES -EXTRACT_ALL = YES -RECURSIVE = YES -EXCLUDE = tests Asserts.h Countable.h GlobalReference.h LocalReference.h LocalString.h Registration.h WeakReference.h jni_helpers.h Environment.h -EXCLUDE_PATTERNS = *-inl.h *.cpp -GENERATE_HTML = YES -GENERATE_LATEX = NO -ENABLE_PREPROCESSING = YES -HIDE_UNDOC_MEMBERS = YES -HIDE_SCOPE_NAMES = YES -HIDE_FRIEND_COMPOUNDS = YES -HIDE_UNDOC_CLASSES = YES -SHOW_INCLUDE_FILES = NO -PREDEFINED = LOG_TAG=fbjni -EXAMPLE_PATH = samples -#ENABLED_SECTIONS = INTERNAL diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Environment.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Environment.h deleted file mode 100644 index f6f53181b11b79..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/Environment.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once -#include -#include -#include - -#include - -namespace facebook { -namespace jni { - -namespace internal { -struct CacheEnvTag {}; -} // namespace internal - -// Keeps a thread-local reference to the current thread's JNIEnv. -struct Environment { - // May be null if this thread isn't attached to the JVM - FBEXPORT static JNIEnv* current(); - static void initialize(JavaVM* vm); - - // There are subtle issues with calling the next functions directly. It is - // much better to always use a ThreadScope to manage attaching/detaching for - // you. - FBEXPORT static JNIEnv* ensureCurrentThreadIsAttached(); - FBEXPORT static void detachCurrentThread(); -}; - -/** - * RAII Object that attaches a thread to the JVM. Failing to detach from a - * thread before it exits will cause a crash, as will calling Detach an extra - * time, and this guard class helps keep that straight. In addition, it - * remembers whether it performed the attach or not, so it is safe to nest it - * with itself or with non-fbjni code that manages the attachment correctly. - * - * Potential concerns: - * - Attaching to the JVM is fast (~100us on MotoG), but ideally you would - * attach while the app is not busy. - * - Having a thread detach at arbitrary points is not safe in Dalvik; you need - * to be sure that there is no Java code on the current stack or you run the - * risk of a crash like: ERROR: detaching thread with interp frames (count=18) - * (More detail at - * https://groups.google.com/forum/#!topic/android-ndk/2H8z5grNqjo) ThreadScope - * won't do a detach if the thread was already attached before the guard is - * instantiated, but there's probably some usage that could trip this up. - * - Newly attached C++ threads only get the bootstrap class loader -- i.e. - * java language classes, not any of our application's classes. This will be - * different behavior than threads that were initiated on the Java side. A - * workaround is to pass a global reference for a class or instance to the new - * thread; this bypasses the need for the class loader. (See - * http://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/invocation.html#attach_current_thread) - * If you need access to the application's classes, you can use - * ThreadScope::WithClassLoader. - */ -class FBEXPORT ThreadScope { - public: - ThreadScope(); - ThreadScope(ThreadScope&) = delete; - ThreadScope(ThreadScope&&) = default; - ThreadScope& operator=(ThreadScope&) = delete; - ThreadScope& operator=(ThreadScope&&) = delete; - ~ThreadScope(); - - /** - * This runs the closure in a scope with fbjni's classloader. This should be - * the same classloader as the rest of the application and thus anything - * running in the closure will have access to the same classes as in a normal - * java-create thread. - */ - static void WithClassLoader(std::function&& runnable); - - static void OnLoad(); - - // This constructor is only used internally by fbjni. - ThreadScope(JNIEnv*, internal::CacheEnvTag); - - private: - friend struct Environment; - ThreadScope* previous_; - // If the JNIEnv* is set, it is guaranteed to be valid at least through the - // lifetime of this ThreadScope. The only case where that guarantee can be - // made is when there is a java frame in the stack below this. - JNIEnv* env_; - bool attachedWithThisScope_; -}; -} // namespace jni -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ProgramLocation.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ProgramLocation.h deleted file mode 100644 index 45c4ca59950624..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ProgramLocation.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once -#include -#include -#include - -namespace facebook { - -#define FROM_HERE facebook::ProgramLocation(__FUNCTION__, __FILE__, __LINE__) - -class ProgramLocation { - public: - ProgramLocation() - : m_functionName("Unspecified"), - m_fileName("Unspecified"), - m_lineNumber(0) {} - - ProgramLocation(const char* functionName, const char* fileName, int line) - : m_functionName(functionName), - m_fileName(fileName), - m_lineNumber(line) {} - - const char* functionName() const { - return m_functionName; - } - const char* fileName() const { - return m_fileName; - } - int lineNumber() const { - return m_lineNumber; - } - - std::string asFormattedString() const { - std::stringstream str; - str << "Function " << m_functionName << " in file " << m_fileName << ":" - << m_lineNumber; - return str.str(); - } - - bool operator==(const ProgramLocation& other) const { - // Assumes that the strings are static - return (m_functionName == other.m_functionName) && - (m_fileName == other.m_fileName) && m_lineNumber == other.m_lineNumber; - } - - private: - const char* m_functionName; - const char* m_fileName; - int m_lineNumber; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/RefPtr.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/RefPtr.h deleted file mode 100644 index c7acd785f52475..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/RefPtr.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once -#include -#include - -namespace facebook { - -// Reference counting smart pointer. This is designed to work with the -// Countable class or other implementations in the future. It is designed in a -// way to be both efficient and difficult to misuse. Typical usage is very -// simple once you learn the patterns (and the compiler will help!): -// -// By default, the internal pointer is null. -// RefPtr ref; -// -// Object creation requires explicit construction: -// RefPtr ref = createNew(...); -// -// Or if the constructor is not public: -// RefPtr ref = adoptRef(new Foo(...)); -// -// But you can implicitly create from nullptr: -// RefPtr maybeRef = cond ? ref : nullptr; -// -// Move/Copy Construction/Assignment are straightforward: -// RefPtr ref2 = ref; -// ref = std::move(ref2); -// -// Destruction automatically drops the RefPtr's reference as expected. -// -// Upcasting is implicit but downcasting requires an explicit cast: -// struct Bar : public Foo {}; -// RefPtr barRef = static_cast>(ref); -// ref = barRef; -// -template -class RefPtr { - public: - constexpr RefPtr() : m_ptr(nullptr) {} - - // Allow implicit construction from a pointer only from nullptr - constexpr RefPtr(std::nullptr_t ptr) : m_ptr(nullptr) {} - - RefPtr(const RefPtr& ref) : m_ptr(ref.m_ptr) { - refIfNecessary(m_ptr); - } - - // Only allow implicit upcasts. A downcast will result in a compile error - // unless you use static_cast (which will end up invoking the explicit - // operator below). - template - RefPtr( - const RefPtr& ref, - typename std::enable_if::value, U>::type* = nullptr) - : m_ptr(ref.get()) { - refIfNecessary(m_ptr); - } - - RefPtr(RefPtr&& ref) : m_ptr(nullptr) { - *this = std::move(ref); - } - - // Only allow implicit upcasts. A downcast will result in a compile error - // unless you use static_cast (which will end up invoking the explicit - // operator below). - template - RefPtr( - RefPtr&& ref, - typename std::enable_if::value, U>::type* = nullptr) - : m_ptr(nullptr) { - *this = std::move(ref); - } - - ~RefPtr() { - unrefIfNecessary(m_ptr); - m_ptr = nullptr; - } - - RefPtr& operator=(const RefPtr& ref) { - if (m_ptr != ref.m_ptr) { - unrefIfNecessary(m_ptr); - m_ptr = ref.m_ptr; - refIfNecessary(m_ptr); - } - return *this; - } - - // The STL assumes rvalue references are unique and for simplicity's sake, we - // make the same assumption here, that &ref != this. - RefPtr& operator=(RefPtr&& ref) { - unrefIfNecessary(m_ptr); - m_ptr = ref.m_ptr; - ref.m_ptr = nullptr; - return *this; - } - - template - RefPtr& operator=(RefPtr&& ref) { - unrefIfNecessary(m_ptr); - m_ptr = ref.m_ptr; - ref.m_ptr = nullptr; - return *this; - } - - void reset() { - unrefIfNecessary(m_ptr); - m_ptr = nullptr; - } - - T* get() const { - return m_ptr; - } - - T* operator->() const { - return m_ptr; - } - - T& operator*() const { - return *m_ptr; - } - - template - explicit operator RefPtr() const; - - explicit operator bool() const { - return m_ptr ? true : false; - } - - bool isTheLastRef() const { - FBASSERT(m_ptr); - return m_ptr->hasOnlyOneRef(); - } - - // Creates a strong reference from a raw pointer, assuming that is already - // referenced from some other RefPtr. This should be used sparingly. - static inline RefPtr assumeAlreadyReffed(T* ptr) { - return RefPtr(ptr, ConstructionMode::External); - } - - // Creates a strong reference from a raw pointer, assuming that it points to a - // freshly-created object. See the documentation for RefPtr for usage. - static inline RefPtr adoptRef(T* ptr) { - return RefPtr(ptr, ConstructionMode::Adopted); - } - - private: - enum class ConstructionMode { Adopted, External }; - - RefPtr(T* ptr, ConstructionMode mode) : m_ptr(ptr) { - FBASSERTMSGF( - ptr, - "Got null pointer in %s construction mode", - mode == ConstructionMode::Adopted ? "adopted" : "external"); - ptr->ref(); - if (mode == ConstructionMode::Adopted) { - FBASSERT(ptr->hasOnlyOneRef()); - } - } - - static inline void refIfNecessary(T* ptr) { - if (ptr) { - ptr->ref(); - } - } - static inline void unrefIfNecessary(T* ptr) { - if (ptr) { - ptr->unref(); - } - } - - template - friend class RefPtr; - - T* m_ptr; -}; - -// Creates a strong reference from a raw pointer, assuming that is already -// referenced from some other RefPtr and that it is non-null. This should be -// used sparingly. -template -static inline RefPtr assumeAlreadyReffed(T* ptr) { - return RefPtr::assumeAlreadyReffed(ptr); -} - -// As above, but tolerant of nullptr. -template -static inline RefPtr assumeAlreadyReffedOrNull(T* ptr) { - return ptr ? RefPtr::assumeAlreadyReffed(ptr) : nullptr; -} - -// Creates a strong reference from a raw pointer, assuming that it points to a -// freshly-created object. See the documentation for RefPtr for usage. -template -static inline RefPtr adoptRef(T* ptr) { - return RefPtr::adoptRef(ptr); -} - -template -static inline RefPtr createNew(Args&&... arguments) { - return RefPtr::adoptRef(new T(std::forward(arguments)...)); -} - -template -template -RefPtr::operator RefPtr() const { - static_assert(std::is_base_of::value, "Invalid static cast"); - return assumeAlreadyReffedOrNull(static_cast(m_ptr)); -} - -template -inline bool operator==(const RefPtr& a, const RefPtr& b) { - return a.get() == b.get(); -} - -template -inline bool operator!=(const RefPtr& a, const RefPtr& b) { - return a.get() != b.get(); -} - -template -inline bool operator==(const RefPtr& ref, U* ptr) { - return ref.get() == ptr; -} - -template -inline bool operator!=(const RefPtr& ref, U* ptr) { - return ref.get() != ptr; -} - -template -inline bool operator==(U* ptr, const RefPtr& ref) { - return ref.get() == ptr; -} - -template -inline bool operator!=(U* ptr, const RefPtr& ref) { - return ref.get() != ptr; -} - -template -inline bool operator==(const RefPtr& ref, std::nullptr_t ptr) { - return ref.get() == ptr; -} - -template -inline bool operator!=(const RefPtr& ref, std::nullptr_t ptr) { - return ref.get() != ptr; -} - -template -inline bool operator==(std::nullptr_t ptr, const RefPtr& ref) { - return ref.get() == ptr; -} - -template -inline bool operator!=(std::nullptr_t ptr, const RefPtr& ref) { - return ref.get() != ptr; -} - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/StaticInitialized.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/StaticInitialized.h deleted file mode 100644 index 4139b420f679e2..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/StaticInitialized.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once -#include -#include - -namespace facebook { - -// Class that lets you declare a global but does not add a static constructor -// to the binary. Eventually I'd like to have this auto-initialize in a -// multithreaded environment but for now it's easiest just to use manual -// initialization. -template -class StaticInitialized { - public: - constexpr StaticInitialized() : m_instance(nullptr) {} - - template - void initialize(Args&&... arguments) { - FBASSERT(!m_instance); - m_instance = new T(std::forward(arguments)...); - } - - T* operator->() const { - return m_instance; - } - - private: - T* m_instance; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ThreadLocal.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ThreadLocal.h deleted file mode 100644 index acd5d248c95e00..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/ThreadLocal.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include -#include - -#include - -namespace facebook { - -/////////////////////////////////////////////////////////////////////////////// - -/** - * A thread-local object is a "global" object within a thread. This is useful - * for writing apartment-threaded code, where nothing is actullay shared - * between different threads (hence no locking) but those variables are not - * on stack in local scope. To use it, just do something like this, - * - * ThreadLocal static_object; - * static_object->data_ = ...; - * static_object->doSomething(); - * - * ThreadLocal static_number; - * int value = *static_number; - * - * So, syntax-wise it's similar to pointers. T can be primitive types, and if - * it's a class, there has to be a default constructor. - */ -template -class ThreadLocal { - public: - /** - * Constructor that has to be called from a thread-neutral place. - */ - ThreadLocal() : m_key(0), m_cleanup(OnThreadExit) { - initialize(); - } - - /** - * As above but with a custom cleanup function - */ - typedef void (*CleanupFunction)(void* obj); - explicit ThreadLocal(CleanupFunction cleanup) : m_key(0), m_cleanup(cleanup) { - FBASSERT(cleanup); - initialize(); - } - - /** - * Access object's member or method through this operator overload. - */ - T* operator->() const { - return get(); - } - - T& operator*() const { - return *get(); - } - - T* get() const { - return (T*)pthread_getspecific(m_key); - } - - T* release() { - T* obj = get(); - pthread_setspecific(m_key, NULL); - return obj; - } - - void reset(T* other = NULL) { - T* old = (T*)pthread_getspecific(m_key); - if (old != other) { - FBASSERT(m_cleanup); - m_cleanup(old); - pthread_setspecific(m_key, other); - } - } - - private: - void initialize() { - int ret = pthread_key_create(&m_key, m_cleanup); - if (ret != 0) { - const char* msg = "(unknown error)"; - switch (ret) { - case EAGAIN: - msg = "PTHREAD_KEYS_MAX (1024) is exceeded"; - break; - case ENOMEM: - msg = "Out-of-memory"; - break; - } - (void)msg; - FBASSERTMSGF(0, "pthread_key_create failed: %d %s", ret, msg); - } - } - - static void OnThreadExit(void* obj) { - if (NULL != obj) { - delete (T*)obj; - } - } - - pthread_key_t m_key; - CleanupFunction m_cleanup; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/assert.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/assert.h deleted file mode 100644 index 25914cb18155cd..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/assert.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#ifndef FBASSERT_H -#define FBASSERT_H - -#include - -namespace facebook { -#define ENABLE_FBASSERT 1 - -#if ENABLE_FBASSERT -#define FBASSERTMSGF(expr, msg, ...) \ - !(expr) ? facebook::assertInternal( \ - "Assert (%s:%d): " msg, __FILE__, __LINE__, ##__VA_ARGS__) \ - : (void)0 -#else -#define FBASSERTMSGF(expr, msg, ...) -#endif // ENABLE_FBASSERT - -#define FBASSERT(expr) FBASSERTMSGF(expr, "%s", #expr) - -#define FBCRASH(msg, ...) \ - facebook::assertInternal( \ - "Fatal error (%s:%d): " msg, __FILE__, __LINE__, ##__VA_ARGS__) -#define FBUNREACHABLE() \ - facebook::assertInternal( \ - "This code should be unreachable (%s:%d)", __FILE__, __LINE__) - -FBEXPORT void assertInternal(const char* formatstr, ...) - __attribute__((noreturn)); - -// This allows storing the assert message before the current process terminates -// due to a crash -typedef void (*AssertHandler)(const char* message); -void setAssertHandler(AssertHandler assertHandler); - -} // namespace facebook -#endif // FBASSERT_H diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/log.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/log.h deleted file mode 100644 index 0185c7c21a8034..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/log.h +++ /dev/null @@ -1,350 +0,0 @@ -/* - * Copyright (C) 2005 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* - * FB Wrapper for logging functions. - * - * The android logging API uses the macro "LOG()" for its logic, which means - * that it conflicts with random other places that use LOG for their own - * purposes and doesn't work right half the places you include it - * - * FBLOG uses exactly the same semantics (FBLOGD for debug etc) but because of - * the FB prefix it's strictly better. FBLOGV also gets stripped out based on - * whether NDEBUG is set, but can be overridden by FBLOG_NDEBUG - * - * Most of the rest is a copy of with minor changes. - */ - -// -// C/C++ logging functions. See the logging documentation for API details. -// -// We'd like these to be available from C code (in case we import some from -// somewhere), so this has a C interface. -// -// The output will be correct when the log file is shared between multiple -// threads and/or multiple processes so long as the operating system -// supports O_APPEND. These calls have mutex-protected data structures -// and so are NOT reentrant. Do not use LOG in a signal handler. -// -#pragma once - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef ANDROID -#include -#else -// These declarations are needed for our internal use even on non-Android -// builds. -// (they are borrowed from ) - -/* - * Android log priority values, in ascending priority order. - */ -typedef enum android_LogPriority { - ANDROID_LOG_UNKNOWN = 0, - ANDROID_LOG_DEFAULT, /* only for SetMinPriority() */ - ANDROID_LOG_VERBOSE, - ANDROID_LOG_DEBUG, - ANDROID_LOG_INFO, - ANDROID_LOG_WARN, - ANDROID_LOG_ERROR, - ANDROID_LOG_FATAL, - ANDROID_LOG_SILENT, /* only for SetMinPriority(); must be last */ -} android_LogPriority; - -/* - * Send a simple string to the log. - */ -int __android_log_write(int prio, const char* tag, const char* text); - -/* - * Send a formatted string to the log, used like printf(fmt,...) - */ -int __android_log_print(int prio, const char* tag, const char* fmt, ...) -#if defined(__GNUC__) - __attribute__((format(printf, 3, 4))) -#endif - ; - -#endif - -// --------------------------------------------------------------------- - -/* - * Normally we strip FBLOGV (VERBOSE messages) from release builds. - * You can modify this (for example with "#define FBLOG_NDEBUG 0" - * at the top of your source file) to change that behavior. - */ -#ifndef FBLOG_NDEBUG -#ifdef NDEBUG -#define FBLOG_NDEBUG 1 -#else -#define FBLOG_NDEBUG 0 -#endif -#endif - -/* - * This is the local tag used for the following simplified - * logging macros. You can change this preprocessor definition - * before using the other macros to change the tag. - */ -#ifndef LOG_TAG -#define LOG_TAG NULL -#endif - -// --------------------------------------------------------------------- - -/* - * Simplified macro to send a verbose log message using the current LOG_TAG. - */ -#ifndef FBLOGV -#if FBLOG_NDEBUG -#define FBLOGV(...) ((void)0) -#else -#define FBLOGV(...) ((void)FBLOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) -#endif -#endif - -#define CONDITION(cond) (__builtin_expect((cond) != 0, 0)) - -#ifndef FBLOGV_IF -#if FBLOG_NDEBUG -#define FBLOGV_IF(cond, ...) ((void)0) -#else -#define FBLOGV_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)FBLOG(LOG_VERBOSE, LOG_TAG, __VA_ARGS__)) \ - : (void)0) -#endif -#endif - -/* - * Simplified macro to send a debug log message using the current LOG_TAG. - */ -#ifndef FBLOGD -#define FBLOGD(...) ((void)FBLOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef FBLOGD_IF -#define FBLOGD_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)FBLOG(LOG_DEBUG, LOG_TAG, __VA_ARGS__)) : (void)0) -#endif - -/* - * Simplified macro to send an info log message using the current LOG_TAG. - */ -#ifndef FBLOGI -#define FBLOGI(...) ((void)FBLOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef FBLOGI_IF -#define FBLOGI_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)FBLOG(LOG_INFO, LOG_TAG, __VA_ARGS__)) : (void)0) -#endif - -/* - * Simplified macro to send a warning log message using the current LOG_TAG. - */ -#ifndef FBLOGW -#define FBLOGW(...) ((void)FBLOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef FBLOGW_IF -#define FBLOGW_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)FBLOG(LOG_WARN, LOG_TAG, __VA_ARGS__)) : (void)0) -#endif - -/* - * Simplified macro to send an error log message using the current LOG_TAG. - */ -#ifndef FBLOGE -#define FBLOGE(...) ((void)FBLOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) -#endif - -#ifndef FBLOGE_IF -#define FBLOGE_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)FBLOG(LOG_ERROR, LOG_TAG, __VA_ARGS__)) : (void)0) -#endif - -// --------------------------------------------------------------------- - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * verbose priority. - */ -#ifndef IF_FBLOGV -#if FBLOG_NDEBUG -#define IF_FBLOGV() if (false) -#else -#define IF_FBLOGV() IF_FBLOG(LOG_VERBOSE, LOG_TAG) -#endif -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * debug priority. - */ -#ifndef IF_FBLOGD -#define IF_FBLOGD() IF_FBLOG(LOG_DEBUG, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * info priority. - */ -#ifndef IF_FBLOGI -#define IF_FBLOGI() IF_FBLOG(LOG_INFO, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * warn priority. - */ -#ifndef IF_FBLOGW -#define IF_FBLOGW() IF_FBLOG(LOG_WARN, LOG_TAG) -#endif - -/* - * Conditional based on whether the current LOG_TAG is enabled at - * error priority. - */ -#ifndef IF_FBLOGE -#define IF_FBLOGE() IF_FBLOG(LOG_ERROR, LOG_TAG) -#endif - -// --------------------------------------------------------------------- - -/* - * Log a fatal error. If the given condition fails, this stops program - * execution like a normal assertion, but also generating the given message. - * It is NOT stripped from release builds. Note that the condition test - * is -inverted- from the normal assert() semantics. - */ -#define FBLOG_ALWAYS_FATAL_IF(cond, ...) \ - ((CONDITION(cond)) ? ((void)fb_printAssert(#cond, LOG_TAG, __VA_ARGS__)) \ - : (void)0) - -#define FBLOG_ALWAYS_FATAL(...) \ - (((void)fb_printAssert(NULL, LOG_TAG, __VA_ARGS__))) - -/* - * Versions of LOG_ALWAYS_FATAL_IF and LOG_ALWAYS_FATAL that - * are stripped out of release builds. - */ -#if FBLOG_NDEBUG - -#define FBLOG_FATAL_IF(cond, ...) ((void)0) -#define FBLOG_FATAL(...) ((void)0) - -#else - -#define FBLOG_FATAL_IF(cond, ...) FBLOG_ALWAYS_FATAL_IF(cond, __VA_ARGS__) -#define FBLOG_FATAL(...) FBLOG_ALWAYS_FATAL(__VA_ARGS__) - -#endif - -/* - * Assertion that generates a log message when the assertion fails. - * Stripped out of release builds. Uses the current LOG_TAG. - */ -#define FBLOG_ASSERT(cond, ...) FBLOG_FATAL_IF(!(cond), __VA_ARGS__) -// #define LOG_ASSERT(cond) LOG_FATAL_IF(!(cond), "Assertion failed: " #cond) - -// --------------------------------------------------------------------- - -/* - * Basic log message macro. - * - * Example: - * FBLOG(LOG_WARN, NULL, "Failed with error %d", errno); - * - * The second argument may be NULL or "" to indicate the "global" tag. - */ -#ifndef FBLOG -#define FBLOG(priority, tag, ...) \ - FBLOG_PRI(ANDROID_##priority, tag, __VA_ARGS__) -#endif - -#ifndef FBLOG_BY_DELIMS -#define FBLOG_BY_DELIMS(priority, tag, delims, msg, ...) \ - logPrintByDelims(ANDROID_##priority, tag, delims, msg, ##__VA_ARGS__) -#endif - -/* - * Log macro that allows you to specify a number for the priority. - */ -#ifndef FBLOG_PRI -#define FBLOG_PRI(priority, tag, ...) fb_printLog(priority, tag, __VA_ARGS__) -#endif - -/* - * Log macro that allows you to pass in a varargs ("args" is a va_list). - */ -#ifndef FBLOG_PRI_VA -#define FBLOG_PRI_VA(priority, tag, fmt, args) \ - fb_vprintLog(priority, NULL, tag, fmt, args) -#endif - -/* - * Conditional given a desired logging priority and tag. - */ -#ifndef IF_FBLOG -#define IF_FBLOG(priority, tag) if (fb_testLog(ANDROID_##priority, tag)) -#endif - -typedef void (*LogHandler)(int priority, const char* tag, const char* message); -FBEXPORT void setLogHandler(LogHandler logHandler); - -/* - * =========================================================================== - * - * The stuff in the rest of this file should not be used directly. - */ -FBEXPORT int fb_printLog(int prio, const char* tag, const char* fmt, ...) -#if defined(__GNUC__) - __attribute__((format(printf, 3, 4))) -#endif - ; - -#define fb_vprintLog(prio, cond, tag, fmt...) \ - __android_log_vprint(prio, tag, fmt) - -#define fb_printAssert(cond, tag, fmt...) __android_log_assert(cond, tag, fmt) - -#define fb_writeLog(prio, tag, text) __android_log_write(prio, tag, text) - -#define fb_bWriteLog(tag, payload, len) __android_log_bwrite(tag, payload, len) -#define fb_btWriteLog(tag, type, payload, len) \ - __android_log_btwrite(tag, type, payload, len) - -#define fb_testLog(prio, tag) (1) - -/* - * FB extensions - */ -void logPrintByDelims( - int priority, - const char* tag, - const char* delims, - const char* msg, - ...); - -#ifdef __cplusplus -} -#endif diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/noncopyable.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/noncopyable.h deleted file mode 100644 index 329ff5d4b25669..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/noncopyable.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -namespace facebook { - -struct noncopyable { - noncopyable(const noncopyable&) = delete; - noncopyable& operator=(const noncopyable&) = delete; - - protected: - noncopyable() = default; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/nonmovable.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/nonmovable.h deleted file mode 100644 index 856b2f49f40d0a..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/nonmovable.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -namespace facebook { - -struct nonmovable { - nonmovable(nonmovable&&) = delete; - nonmovable& operator=(nonmovable&&) = delete; - - protected: - nonmovable() = default; -}; - -} // namespace facebook diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/visibility.h b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/visibility.h deleted file mode 100644 index f44ef6055260f7..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/include/fb/visibility.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#define FBEXPORT __attribute__((visibility("default"))) diff --git a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/log.cpp b/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/log.cpp deleted file mode 100644 index 8e9aa148ccdfbf..00000000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/first-party/fb/log.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#include -#include -#include -#include - -#define LOG_BUFFER_SIZE 4096 -static LogHandler gLogHandler; - -void setLogHandler(LogHandler logHandler) { - gLogHandler = logHandler; -} - -int fb_printLog(int prio, const char* tag, const char* fmt, ...) { - char logBuffer[LOG_BUFFER_SIZE]; - - va_list va_args; - va_start(va_args, fmt); - int result = vsnprintf(logBuffer, sizeof(logBuffer), fmt, va_args); - va_end(va_args); - if (gLogHandler != NULL) { - gLogHandler(prio, tag, logBuffer); - } - __android_log_write(prio, tag, logBuffer); - return result; -} - -void logPrintByDelims( - int priority, - const char* tag, - const char* delims, - const char* msg, - ...) { - va_list ap; - char buf[32768]; - char* context; - char* tok; - - va_start(ap, msg); - vsnprintf(buf, sizeof(buf), msg, ap); - va_end(ap); - - tok = strtok_r(buf, delims, &context); - - if (!tok) { - return; - } - - do { - __android_log_write(priority, tag, tok); - } while ((tok = strtok_r(NULL, delims, &context))); -} - -#ifndef ANDROID - -// Implementations of the basic android logging functions for non-android -// platforms. - -static char logTagChar(int prio) { - switch (prio) { - default: - case ANDROID_LOG_UNKNOWN: - case ANDROID_LOG_DEFAULT: - case ANDROID_LOG_SILENT: - return ' '; - case ANDROID_LOG_VERBOSE: - return 'V'; - case ANDROID_LOG_DEBUG: - return 'D'; - case ANDROID_LOG_INFO: - return 'I'; - case ANDROID_LOG_WARN: - return 'W'; - case ANDROID_LOG_ERROR: - return 'E'; - case ANDROID_LOG_FATAL: - return 'F'; - } -} - -int __android_log_write(int prio, const char* tag, const char* text) { - return fprintf(stderr, "[%c/%.16s] %s\n", logTagChar(prio), tag, text); -} - -int __android_log_print(int prio, const char* tag, const char* fmt, ...) { - va_list ap; - va_start(ap, fmt); - - int res = fprintf(stderr, "[%c/%.16s] ", logTagChar(prio), tag); - res += vfprintf(stderr, "%s\n", ap); - - va_end(ap); - return res; -} - -#endif diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp index 8dccfab349aa05..c664693edcb4e9 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CatalystInstanceImpl.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JniJSModulesUnbundle.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JniJSModulesUnbundle.cpp index f192010aa8ecdc..743ba5b3ab6128 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/JniJSModulesUnbundle.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/JniJSModulesUnbundle.cpp @@ -7,7 +7,8 @@ #include "JniJSModulesUnbundle.h" -#include +#include + #include #include #include @@ -72,9 +73,7 @@ bool JniJSModulesUnbundle::isUnbundle( JSModulesUnbundle::Module JniJSModulesUnbundle::getModule( uint32_t moduleId) const { // can be nullptr for default constructor. - FBASSERTMSGF( - m_assetManager != nullptr, - "Unbundle has not been initialized with an asset manager"); + react_native_assert(m_assetManager != nullptr); std::ostringstream sourceUrlBuilder; sourceUrlBuilder << moduleId << ".js"; diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp index c10bc2d72a8039..9855f903115c61 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include