Skip to content

Commit

Permalink
Fix base_unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
niranjanyardi committed Jan 15, 2025
1 parent 3373730 commit 8c9999a
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions base/allocator/partition_allocator/partition_alloc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <linux/version.h>
// TODO(bikineev): Enable for ChromeOS.
#define PA_CONFIG_STARSCAN_UFFD_WRITE_PROTECTOR_SUPPORTED() \
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion base/allocator/partition_allocator/shim/allocator_shim.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/cdefs.h> // for __THROW
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <malloc/malloc.h>
#else
Expand Down Expand Up @@ -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_

2 changes: 1 addition & 1 deletion base/debug/stack_trace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions base/debug/stack_trace_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions base/system/sys_info_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <sys/statvfs.h>
#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 <linux/magic.h>
#include <sys/vfs.h>
#endif
Expand All @@ -60,7 +60,7 @@ base::LazyInstance<
base::internal::LazySysInfoValue<uint64_t, AmountOfVirtualMemory>>::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;

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion third_party/abseil-cpp/absl/base/internal/direct_mmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <sys/mman.h>

#include "build/build_config.h"
#if defined(__linux__) && !BUILDFLAG(IS_STARBOARD)
#if defined(__linux__) && !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC))
#include <sys/types.h>
#ifdef __BIONIC__
#include <sys/syscall.h>
Expand Down
4 changes: 2 additions & 2 deletions third_party/abseil-cpp/absl/base/internal/raw_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/syscall.h>
#define ABSL_HAVE_SYSCALL_WRITE 1
#define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
Expand Down Expand Up @@ -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<unsigned>(len));
#elif BUILDFLAG(IS_STARBOARD)
#elif (BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC))
SbLog(kSbLogPriorityError, s);
#else
// stderr logging unsupported on this platform
Expand Down
2 changes: 1 addition & 1 deletion third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions third_party/abseil-cpp/absl/synchronization/internal/futex.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
#include <unistd.h>
#endif

#if !BUILDFLAG(IS_STARBOARD)
#if !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC))
#ifdef __linux__
#include <linux/futex.h>
#include <sys/syscall.h>
#endif
#endif // !BUILDFLAG(IS_STARBOARD)
#endif // !(BUILDFLAG(IS_STARBOARD) && defined(_LIBCPP_HAS_MUSL_LIBC))

#include <errno.h>
#include <stdio.h>
Expand Down
9 changes: 5 additions & 4 deletions third_party/musl/include/pthread.h
Original file line number Diff line number Diff line change
@@ -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" {
Expand Down Expand Up @@ -249,5 +250,5 @@ __REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64);
}
#endif

// #endif // defined(STARBOARD)
#endif // defined(STARBOARD)
#endif

0 comments on commit 8c9999a

Please sign in to comment.