update libcxx and libcxxabi to llvm 18.1.6

Contains fixes for OpenBSD
This commit is contained in:
Andrew Kelley 2024-05-20 06:19:58 -07:00
parent 9f4f43cf7f
commit 50a1419457
3 changed files with 32 additions and 4 deletions

View file

@ -25,16 +25,28 @@
# if !defined(SYS_futex) && defined(SYS_futex_time64) # if !defined(SYS_futex) && defined(SYS_futex_time64)
# define SYS_futex SYS_futex_time64 # define SYS_futex SYS_futex_time64
# endif # endif
# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
# include <sys/types.h> # include <sys/types.h>
# include <sys/umtx.h> # include <sys/umtx.h>
# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
#elif defined(__OpenBSD__)
# include <sys/futex.h>
// OpenBSD has no indirect syscalls
# define _LIBCPP_FUTEX(...) futex(__VA_ARGS__)
#else // <- Add other operating systems here #else // <- Add other operating systems here
// Baseline needs no new headers // Baseline needs no new headers
# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
#endif #endif
_LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_BEGIN_NAMESPACE_STD
@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
static void static void
__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) { __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
static constexpr timespec __timeout = {2, 0}; static constexpr timespec __timeout = {2, 0};
syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0); _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
} }
static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0); _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
} }
#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK) #elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)

View file

@ -31,7 +31,9 @@
# include <sys/time.h> // for gettimeofday and timeval # include <sys/time.h> // for gettimeofday and timeval
#endif #endif
#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0) // OpenBSD does not have a fully conformant suite of POSIX timers, but
// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
# define _LIBCPP_HAS_CLOCK_GETTIME # define _LIBCPP_HAS_CLOCK_GETTIME
#endif #endif

View file

@ -47,6 +47,9 @@
#include "__cxxabi_config.h" #include "__cxxabi_config.h"
#include "include/atomic_support.h" // from libc++ #include "include/atomic_support.h" // from libc++
#if defined(__has_include) #if defined(__has_include)
# if __has_include(<sys/futex.h>)
# include <sys/futex.h>
# endif
# if __has_include(<sys/syscall.h>) # if __has_include(<sys/syscall.h>)
# include <sys/syscall.h> # include <sys/syscall.h>
# endif # endif
@ -411,7 +414,18 @@ private:
// Futex Implementation // Futex Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#if defined(SYS_futex) #if defined(__OpenBSD__)
void PlatformFutexWait(int* addr, int expect) {
constexpr int WAIT = 0;
futex(reinterpret_cast<volatile uint32_t*>(addr), WAIT, expect, NULL, NULL);
__tsan_acquire(addr);
}
void PlatformFutexWake(int* addr) {
constexpr int WAKE = 1;
__tsan_release(addr);
futex(reinterpret_cast<volatile uint32_t*>(addr), WAKE, INT_MAX, NULL, NULL);
}
#elif defined(SYS_futex)
void PlatformFutexWait(int* addr, int expect) { void PlatformFutexWait(int* addr, int expect) {
constexpr int WAIT = 0; constexpr int WAIT = 0;
syscall(SYS_futex, addr, WAIT, expect, 0); syscall(SYS_futex, addr, WAIT, expect, 0);