| author | |
| committer | |
| log | 50a1419457bff596747ea7716e77140178c96389 |
| tree | 362c0ee8ce4148bbf892b1df8926859fe738e91a |
| parent | 9f4f43cf7fdd2b2a50e475a1e7d740c9bcc2227e |
Contains fixes for OpenBSD3 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_time64 | 26 | # define SYS_futex SYS_futex_time64 |
| 27 | # endif | 27 | # endif |
| 28 | # define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__) | ||
| 28 | 29 | ||
| 29 | #elif defined(__FreeBSD__) | 30 | #elif defined(__FreeBSD__) |
| 30 | 31 | ||
| 31 | # include <sys/types.h> | 32 | # include <sys/types.h> |
| 32 | # include <sys/umtx.h> | 33 | # include <sys/umtx.h> |
| 33 | 34 | ||
| 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 here | 44 | #else // <- Add other operating systems here |
| 35 | 45 | ||
| 36 | // Baseline needs no new headers | 46 | // Baseline needs no new headers |
| 37 | 47 | ||
| 48 | # define _LIBCPP_FUTEX(...) syscall(SYS_futex, __VA_ARGS__) | ||
| 49 | |||
| 38 | #endif | 50 | #endif |
| 39 | 51 | ||
| 40 | _LIBCPP_BEGIN_NAMESPACE_STD | 52 | _LIBCPP_BEGIN_NAMESPACE_STD |
| ... | @@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD | ... | @@ -44,11 +56,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD |
| 44 | static void | 56 | static 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 | } |
| 49 | 61 | ||
| 50 | static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) { | 62 | static 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 | } |
| 53 | 65 | ||
| 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 timeval | 31 | # include <sys/time.h> // for gettimeofday and timeval |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 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_GETTIME | 37 | # define _LIBCPP_HAS_CLOCK_GETTIME |
| 36 | #endif | 38 | #endif |
| 37 | 39 |
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 | # endif | 55 | # endif |
| ... | @@ -411,7 +414,18 @@ private: | ... | @@ -411,7 +414,18 @@ private: |
| 411 | // Futex Implementation | 414 | // Futex Implementation |
| 412 | //===----------------------------------------------------------------------===// | 415 | //===----------------------------------------------------------------------===// |
| 413 | 416 | ||
| 414 | #if defined(SYS_futex) | 417 | #if defined(__OpenBSD__) |
| 418 | void 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 | } | ||
| 423 | void 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) | ||
| 415 | void PlatformFutexWait(int* addr, int expect) { | 429 | void 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); |