diff --git a/third_party/abseil-cpp/absl/base/BUILD.gn b/third_party/abseil-cpp/absl/base/BUILD.gn index 3f525ac92e2e..74a518dac5c2 100644 --- a/third_party/abseil-cpp/absl/base/BUILD.gn +++ b/third_party/abseil-cpp/absl/base/BUILD.gn @@ -54,6 +54,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_posix.inc b/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc index 4f6f887d993c..91a8daf25d34 100644 --- a/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +++ b/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc @@ -14,7 +14,11 @@ // // This file is a Posix-specific part of spinlock_wait.cc +#if defined(STARBOARD) +#include "starboard/thread.h" +#else #include +#endif #include #include @@ -29,6 +33,14 @@ 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 defined(STARBOARD) + if (loop == 0) { + } else if (loop == 1) { + SbThreadYield(); + } else { + SbThreadSleep(loop); + } +#else if (loop == 0) { } else if (loop == 1) { sched_yield(); @@ -38,6 +50,7 @@ ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockDelay)( tm.tv_nsec = absl::base_internal::SpinLockSuggestedDelayNS(loop); nanosleep(&tm, nullptr); } +#endif } ABSL_ATTRIBUTE_WEAK void ABSL_INTERNAL_C_SYMBOL(AbslInternalSpinLockWake)(