From 1cb8033b10290d5dba7b458ddf93b89d8fb70643 Mon Sep 17 00:00:00 2001 From: Jelle Foks Date: Wed, 10 Jan 2024 10:37:36 -0800 Subject: [PATCH] Strip absl not compatible with Starboard. --- third_party/abseil-cpp/absl/base/BUILD.gn | 2 + .../absl/base/internal/spinlock_starboard.inc | 46 +++++++++++++++++++ .../absl/base/internal/spinlock_wait.cc | 2 +- .../abseil-cpp/absl/synchronization/BUILD.gn | 2 + 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 third_party/abseil-cpp/absl/base/internal/spinlock_starboard.inc diff --git a/third_party/abseil-cpp/absl/base/BUILD.gn b/third_party/abseil-cpp/absl/base/BUILD.gn index 3f525ac92e2e..e95dc8f207f4 100644 --- a/third_party/abseil-cpp/absl/base/BUILD.gn +++ b/third_party/abseil-cpp/absl/base/BUILD.gn @@ -46,6 +46,7 @@ absl_source_set("spinlock_wait") { "internal/spinlock_akaros.inc", "internal/spinlock_linux.inc", "internal/spinlock_posix.inc", + "internal/spinlock_starboard.inc", "internal/spinlock_wait.cc", "internal/spinlock_win32.inc", ] @@ -54,6 +55,7 @@ absl_source_set("spinlock_wait") { ":base_internal", ":core_headers", ":errno_saver", + "//starboard:starboard_headers_only", ] visibility = [ "//third_party/abseil-cpp/absl/base:*" ] } diff --git a/third_party/abseil-cpp/absl/base/internal/spinlock_starboard.inc b/third_party/abseil-cpp/absl/base/internal/spinlock_starboard.inc new file mode 100644 index 000000000000..d39a33f82a88 --- /dev/null +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_starboard.inc @@ -0,0 +1,46 @@ +// Copyright 2017 The Abseil Authors. +// +// 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 +// +// https://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. +// +// This file is a Posix-specific part of spinlock_wait.cc + +#if defined(STARBOARD) +#include "starboard/thread.h" + +#include +#include + +#include "absl/base/internal/errno_saver.h" +#include "absl/base/internal/scheduling_mode.h" +#include "absl/base/port.h" + +extern "C" { + +ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)( + std::atomic* /* lock_word */, uint32_t /* value */, int loop, + absl::base_internal::SchedulingMode /* mode */) { + absl::base_internal::ErrnoSaver errno_saver; + if (loop == 0) { + } else if (loop == 1) { + SbThreadYield(); + } else { + SbThreadSleep(loop); + } +} + +ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)( + std::atomic* /* lock_word */, bool /* all */) {} + +} // extern "C" + +#endif 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 0d990bdf8e96..edbd90eab431 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc @@ -22,7 +22,7 @@ #include "absl/base/internal/spinlock_wait.h" #if defined(STARBOARD) -#include "absl/base/internal/spinlock_posix.inc" +#include "absl/base/internal/spinlock_starboard.inc" #elif defined(_WIN32) #include "absl/base/internal/spinlock_win32.inc" #elif defined(__linux__) diff --git a/third_party/abseil-cpp/absl/synchronization/BUILD.gn b/third_party/abseil-cpp/absl/synchronization/BUILD.gn index 7e45ee211d9d..0e690d3ee78b 100644 --- a/third_party/abseil-cpp/absl/synchronization/BUILD.gn +++ b/third_party/abseil-cpp/absl/synchronization/BUILD.gn @@ -42,6 +42,7 @@ absl_test("kernel_timeout_internal_test") { } absl_source_set("synchronization") { + if (!use_cobalt_customizations) { sources = [ "barrier.cc", "blocking_counter.cc", @@ -87,6 +88,7 @@ absl_source_set("synchronization") { "//third_party/abseil-cpp/absl/debugging:symbolize", "//third_party/abseil-cpp/absl/time", ] + } } absl_test("waiter_test") {