authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-20 06:19:58-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-05-20 16:12:36-04:00
log50a1419457bff596747ea7716e77140178c96389
tree362c0ee8ce4148bbf892b1df8926859fe738e91a
parent9f4f43cf7fdd2b2a50e475a1e7d740c9bcc2227e

update libcxx and libcxxabi to llvm 18.1.6

Contains fixes for OpenBSD

3 files changed, 32 insertions(+), 4 deletions(-)

lib/libcxx/src/atomic.cpp+14-2
...@@ -25,16 +25,28 @@...@@ -25,16 +25,28 @@
25# if !defined(SYS_futex) && defined(SYS_futex_time64)25# if !defined(SYS_futex) && defined(SYS_futex_time64)
26# define SYS_futex SYS_futex_time6426# define SYS_futex SYS_futex_time64
27# endif27# endif
28# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
2829
29#elif defined(__FreeBSD__)30#elif defined(__FreeBSD__)
3031
31# include <sys/types.h>32# include <sys/types.h>
32# include <sys/umtx.h>33# include <sys/umtx.h>
3334
35# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
36
37#elif defined(__OpenBSD__)
38
39# include <sys/futex.h>
40
41// OpenBSD has no indirect syscalls
42# define _LIBCPP_FUTEX(...) futex(__VA_ARGS__)
43
34#else // <- Add other operating systems here44#else // <- Add other operating systems here
3545
36// Baseline needs no new headers46// Baseline needs no new headers
3747
48# define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__)
49
38#endif50#endif
3951
40_LIBCPP_BEGIN_NAMESPACE_STD52_LIBCPP_BEGIN_NAMESPACE_STD
...@@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD...@@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
44static void56static void
45__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {57__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
46 static constexpr timespec __timeout = {2, 0};58 static constexpr timespec __timeout = {2, 0};
47 syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);59 _LIBCPP_FUTEX(__ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
48}60}
4961
50static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {62static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
51 syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);63 _LIBCPP_FUTEX(__ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
52}64}
5365
54#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)66#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
lib/libcxx/src/chrono.cpp+3-1
...@@ -31,7 +31,9 @@...@@ -31,7 +31,9 @@
31# include <sys/time.h> // for gettimeofday and timeval31# include <sys/time.h> // for gettimeofday and timeval
32#endif32#endif
3333
34#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)34// OpenBSD does not have a fully conformant suite of POSIX timers, but
35// it does have clock_gettime and CLOCK_MONOTONIC which is all we need.
36#if defined(__APPLE__) || defined(__gnu_hurd__) || defined(__OpenBSD__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
35# define _LIBCPP_HAS_CLOCK_GETTIME37# define _LIBCPP_HAS_CLOCK_GETTIME
36#endif38#endif
3739
lib/libcxxabi/src/cxa_guard_impl.h+15-1
...@@ -47,6 +47,9 @@...@@ -47,6 +47,9 @@
47#include "__cxxabi_config.h"47#include "__cxxabi_config.h"
48#include "include/atomic_support.h" // from libc++48#include "include/atomic_support.h" // from libc++
49#if defined(__has_include)49#if defined(__has_include)
50# if __has_include(<sys/futex.h>)
51# include <sys/futex.h>
52# endif
50# if __has_include(<sys/syscall.h>)53# if __has_include(<sys/syscall.h>)
51# include <sys/syscall.h>54# include <sys/syscall.h>
52# endif55# endif
...@@ -411,7 +414,18 @@ private:...@@ -411,7 +414,18 @@ private:
411// Futex Implementation414// Futex Implementation
412//===----------------------------------------------------------------------===//415//===----------------------------------------------------------------------===//
413416
414#if defined(SYS_futex)417#if defined(__OpenBSD__)
418void PlatformFutexWait(int* addr, int expect) {
419 constexpr int WAIT = 0;
420 futex(reinterpret_cast<volatile uint32_t*>(addr), WAIT, expect, NULL, NULL);
421 __tsan_acquire(addr);
422}
423void PlatformFutexWake(int* addr) {
424 constexpr int WAKE = 1;
425 __tsan_release(addr);
426 futex(reinterpret_cast<volatile uint32_t*>(addr), WAKE, INT_MAX, NULL, NULL);
427}
428#elif defined(SYS_futex)
415void PlatformFutexWait(int* addr, int expect) {429void PlatformFutexWait(int* addr, int expect) {
416 constexpr int WAIT = 0;430 constexpr int WAIT = 0;
417 syscall(SYS_futex, addr, WAIT, expect, 0);431 syscall(SYS_futex, addr, WAIT, expect, 0);