From 8c9999a941dfc9bf863aebbe8f11e0734ba0f313 Mon Sep 17 00:00:00 2001 From: Niranjan Yardi Date: Tue, 14 Jan 2025 18:21:31 -0800 Subject: [PATCH] Fix base_unittests --- .../partition_allocator/partition_alloc_config.h | 4 ++-- .../allocator/partition_allocator/shim/allocator_shim.cc | 2 +- .../partition_allocator/shim/allocator_shim_internals.h | 2 +- .../shim/allocator_shim_override_libc_symbols.h | 9 --------- base/debug/stack_trace.cc | 2 +- base/debug/stack_trace_posix.cc | 4 ++-- base/system/sys_info_posix.cc | 6 +++--- third_party/abseil-cpp/absl/base/internal/direct_mmap.h | 2 +- third_party/abseil-cpp/absl/base/internal/raw_logging.cc | 4 ++-- .../abseil-cpp/absl/base/internal/spinlock_wait.cc | 2 +- .../absl/debugging/internal/address_is_readable.cc | 2 +- .../abseil-cpp/absl/synchronization/internal/futex.h | 4 ++-- third_party/musl/include/pthread.h | 9 +++++---- 13 files changed, 22 insertions(+), 30 deletions(-) diff --git a/base/allocator/partition_allocator/partition_alloc_config.h b/base/allocator/partition_allocator/partition_alloc_config.h index c09df1f09e2c..ac00261d7808 100644 --- a/base/allocator/partition_allocator/partition_alloc_config.h +++ b/base/allocator/partition_allocator/partition_alloc_config.h @@ -65,7 +65,7 @@ static_assert(sizeof(void*) != 8, ""); #endif #if BUILDFLAG(HAS_64_BIT_POINTERS) && \ - (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID)) && !BUILDFLAG(IS_STARBOARD) + (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_ANDROID)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include // TODO(bikineev): Enable for ChromeOS. #define PA_CONFIG_STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED() \ @@ -104,7 +104,7 @@ static_assert(sizeof(void*) != 8, ""); // POSIX is not only UNIX, e.g. macOS and other OSes. We do use Linux-specific // features such as futex(2). #define PA_CONFIG_HAS_LINUX_KERNEL() \ - (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)) && !BUILDFLAG(IS_STARBOARD) + (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) // On some platforms, we implement locking by spinning in userspace, then going // into the kernel only if there is contention. This requires platform support, diff --git a/base/allocator/partition_allocator/shim/allocator_shim.cc b/base/allocator/partition_allocator/shim/allocator_shim.cc index bb4ccc2d5616..6f6a21929e16 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim.cc +++ b/base/allocator/partition_allocator/shim/allocator_shim.cc @@ -405,7 +405,7 @@ ALWAYS_INLINE void ShimAlignedFree(void* address, void* context) { #else // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) #include "base/allocator/partition_allocator/shim/allocator_shim_override_mac_symbols.h" #endif // BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC) -#elif BUILDFLAG(IS_STARBOARD) +#elif (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) // // In file included from ../../base/allocator/partition_allocator/shim/allocator_shim.cc:409: // ../../base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h:40:26: error: exception specification in declaration does not match previous declaration // Don't include anything, all includes are already set up in MUSL libc diff --git a/base/allocator/partition_allocator/shim/allocator_shim_internals.h b/base/allocator/partition_allocator/shim/allocator_shim_internals.h index 893e245e5d4e..1a020322769e 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_internals.h +++ b/base/allocator/partition_allocator/shim/allocator_shim_internals.h @@ -9,7 +9,7 @@ #if defined(__GNUC__) -#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_STARBOARD) +#if BUILDFLAG(IS_POSIX) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include // for __THROW #endif diff --git a/base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h b/base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h index ff2ac20b18fb..c9b2a751b9eb 100644 --- a/base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h +++ b/base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h @@ -12,13 +12,6 @@ #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ -#include "build/build_config.h" - -// TODO: b/384652502 - Cobalt: Add source files after fixing compiler errors. -// /arch/generic --sysroot=../../build/linux/debian_bullseye_amd64-sysroot -fvisibility-inlines-hidden -c ../../base/allocator/partition_allocator/shim/allocator_shim.cc -o obj/base/base/allocator_shim.o -// In file included from ../../base/allocator/partition_allocator/shim/allocator_shim.cc:409: -// ../../base/allocator/partition_allocator/shim/allocator_shim_override_libc_symbols.h:36:26: error: exception specification in declaration does not match previous declaration -#if BUILDFLAG(IS_STARBOARD) #if BUILDFLAG(IS_APPLE) #include #else @@ -94,7 +87,5 @@ SHIM_ALWAYS_EXPORT size_t malloc_usable_size(void* address) __THROW { } // extern "C" -#endif // IS_STARBOARD - #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_SHIM_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ diff --git a/base/debug/stack_trace.cc b/base/debug/stack_trace.cc index b58cddc3f673..56043156dd9f 100644 --- a/base/debug/stack_trace.cc +++ b/base/debug/stack_trace.cc @@ -281,7 +281,7 @@ std::string StackTrace::ToString() const { } std::string StackTrace::ToStringWithPrefix(const char* prefix_string) const { std::stringstream stream; -#if !defined(__UCLIBC__) && !defined(_AIX) && !BUILDFLAG(IS_STARBOARD) +#if (!defined(__UCLIBC__) && !defined(_AIX)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) OutputToStreamWithPrefix(&stream, prefix_string); #endif return stream.str(); diff --git a/base/debug/stack_trace_posix.cc b/base/debug/stack_trace_posix.cc index f9045067fd99..52274e3f338f 100644 --- a/base/debug/stack_trace_posix.cc +++ b/base/debug/stack_trace_posix.cc @@ -318,12 +318,12 @@ void AlarmSignalHandler(int signal, siginfo_t* info, void* void_context) { "Warning: Default signal handler failed to terminate process.\n"); PrintToStderr("Calling exit_group() directly to prevent timeout.\n"); -#if !BUILDFLAG(IS_STARBOARD) +#if !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) // See: https://man7.org/linux/man-pages/man2/exit_group.2.html syscall(SYS_exit_group, EXIT_FAILURE); #else // No clue how to substitue , ask yavor -#endif // IS_STARBOARD +#endif // (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) } #endif // BUILDFLAG(IS_LINUX) diff --git a/base/system/sys_info_posix.cc b/base/system/sys_info_posix.cc index 332b1ee5772d..cd12921259c9 100644 --- a/base/system/sys_info_posix.cc +++ b/base/system/sys_info_posix.cc @@ -35,7 +35,7 @@ #include #endif -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_STARBOARD) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include #include #endif @@ -60,7 +60,7 @@ base::LazyInstance< base::internal::LazySysInfoValue>::Leaky g_lazy_virtual_memory = LAZY_INSTANCE_INITIALIZER; -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_STARBOARD) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) bool IsStatsZeroIfUnlimited(const base::FilePath& path) { struct statfs stats; @@ -90,7 +90,7 @@ bool GetDiskSpaceInfo(const base::FilePath& path, if (HANDLE_EINTR(statvfs(path.value().c_str(), &stats)) != 0) return false; -#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_STARBOARD) +#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) const bool zero_size_means_unlimited = stats.f_blocks == 0 && IsStatsZeroIfUnlimited(path); #else diff --git a/third_party/abseil-cpp/absl/base/internal/direct_mmap.h b/third_party/abseil-cpp/absl/base/internal/direct_mmap.h index 530e0348b405..17f5a4174361 100644 --- a/third_party/abseil-cpp/absl/base/internal/direct_mmap.h +++ b/third_party/abseil-cpp/absl/base/internal/direct_mmap.h @@ -25,7 +25,7 @@ #include #include "build/build_config.h" -#if defined(__linux__) && !BUILDFLAG(IS_STARBOARD) +#if defined(__linux__) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include #ifdef __BIONIC__ #include diff --git a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc index 3dc0c89dabd4..1a5e10380d22 100644 --- a/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +++ b/third_party/abseil-cpp/absl/base/internal/raw_logging.cc @@ -59,7 +59,7 @@ // syscall(SYS_write, /*int*/ fd, /*char* */ buf, /*size_t*/ len); // for low level operations that want to avoid libc. #if (defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)) && \ - !defined(__ANDROID__) && !BUILDFLAG(IS_STARBOARD) + !defined(__ANDROID__) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include #define ABSL_HAVE_SYSCALL_WRITE 1 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1 @@ -217,7 +217,7 @@ void AsyncSignalSafeWriteToStderr(const char* s, size_t len) { write(STDERR_FILENO, s, len); #elif defined(ABSL_HAVE_RAW_IO) _write(/* stderr */ 2, s, static_cast(len)); -#elif BUILDFLAG(IS_STARBOARD) +#elif (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) SbLog(kSbLogPriorityError, s); #else // stderr logging unsupported on this platform diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc index 5a13ddbd2f07..51923e6d3e0d 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc @@ -24,7 +24,7 @@ #if defined(_WIN32) #include "absl/base/internal/spinlock_win32.inc" -#elif defined(__linux__) && !BUILDFLAG(IS_STARBOARD) +#elif defined(__linux__) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include "absl/base/internal/spinlock_linux.inc" #elif defined(__akaros__) #include "absl/base/internal/spinlock_akaros.inc" diff --git a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc index 28eb039041e9..c43513e3ec49 100644 --- a/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc +++ b/third_party/abseil-cpp/absl/debugging/internal/address_is_readable.cc @@ -18,7 +18,7 @@ #include "absl/debugging/internal/address_is_readable.h" #include "build/build_config.h" -#if !defined(__linux__) || defined(__ANDROID__) || BUILDFLAG(IS_STARBOARD) +#if !defined(__linux__) || defined(__ANDROID__) || (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) namespace absl { ABSL_NAMESPACE_BEGIN diff --git a/third_party/abseil-cpp/absl/synchronization/internal/futex.h b/third_party/abseil-cpp/absl/synchronization/internal/futex.h index daedd4e1ecb1..f008658dc220 100644 --- a/third_party/abseil-cpp/absl/synchronization/internal/futex.h +++ b/third_party/abseil-cpp/absl/synchronization/internal/futex.h @@ -22,12 +22,12 @@ #include #endif -#if !BUILDFLAG(IS_STARBOARD) +#if !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #ifdef __linux__ #include #include #endif -#endif // !BUILDFLAG(IS_STARBOARD) +#endif // !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #include #include diff --git a/third_party/musl/include/pthread.h b/third_party/musl/include/pthread.h index a821a424b9c8..60ebb70e838e 100644 --- a/third_party/musl/include/pthread.h +++ b/third_party/musl/include/pthread.h @@ -1,11 +1,12 @@ #ifndef _PTHREAD_H #define _PTHREAD_H -// #if defined(STARBOARD) +#include "build/build_config.h" -// #include "pthread_starboard.h" +#if (BUILDFLAG(IS_STARBOARD) && !defined(_LIBCPP_HAS_MUSL_LIBC)) +#include "pthread_starboard.h" -// #else +#elif (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC)) #ifdef __cplusplus extern "C" { @@ -249,5 +250,5 @@ __REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64); } #endif -// #endif // defined(STARBOARD) +#endif // defined(STARBOARD) #endif