From 709f9f279b7fd011afd744b482a7f5404134fa92 Mon Sep 17 00:00:00 2001 From: Daniel Anderson Date: Wed, 1 Nov 2023 12:25:59 -0400 Subject: [PATCH 1/2] Portability fixes for Windows/Cygwin/MSYS --- include/parlay/internal/atomic_wait.h | 15 +++++++++------ include/parlay/portability.h | 4 +++- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/parlay/internal/atomic_wait.h b/include/parlay/internal/atomic_wait.h index 37d6390e..b08f71ab 100644 --- a/include/parlay/internal/atomic_wait.h +++ b/include/parlay/internal/atomic_wait.h @@ -91,7 +91,7 @@ The strategy is chosen this way, by platform: #define __ABI #endif -#if defined(__APPLE__) || defined(__linux__) +#if defined(__APPLE__) || defined(__linux__) || defined(__CYGWIN__) #include #include @@ -137,7 +137,7 @@ The strategy is chosen this way, by platform: #define __NO_CONDVAR #define __NO_TABLE - + #ifndef NOMINMAX #define PARLAY_DEFINED_NOMINMAX #define NOMINMAX @@ -146,11 +146,12 @@ The strategy is chosen this way, by platform: #ifdef PARLAY_DEFINED_NOMINMAX #undef NOMINMAX #endif - + #define __YIELD() Sleep(0) #define __SLEEP(x) Sleep(x) #define __YIELD_PROCESSOR() YieldProcessor() +#if !defined(__clang__) #include template auto __atomic_load_n(_Tp const* a, int) -> typename std::remove_reference::type { @@ -158,6 +159,8 @@ The strategy is chosen this way, by platform: _ReadWriteBarrier(); return t; } +#endif + #define __builtin_expect(e, v) (e) #if defined(_WIN32_WINNT) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8) && !defined(__NO_FUTEX) @@ -255,7 +258,7 @@ The strategy is chosen this way, by platform: #elif defined(__FUTEX) template ::type = 1> - void __cxx_atomic_notify_all(_Tp const* ptr) { + void __cxx_atomic_notify_all([[maybe_unused]] _Tp const* ptr) { #if defined(__TABLE) auto * const c = __contention(ptr); __atomic_fetch_add(&c->version, 1, __ATOMIC_RELAXED); @@ -326,9 +329,9 @@ The strategy is chosen this way, by platform: __cxx_atomic_try_wait_slow_fallback(ptr, val, order); } template - __ABI void __cxx_atomic_notify_one(_Tp const* ptr) { } + __ABI void __cxx_atomic_notify_one([[maybe_unused]] _Tp const* ptr) { } template - __ABI void __cxx_atomic_notify_all(_Tp const* ptr) { } + __ABI void __cxx_atomic_notify_all([[maybe_unused]] _Tp const* ptr) { } #endif // __FUTEX || __CONDVAR diff --git a/include/parlay/portability.h b/include/parlay/portability.h index 88a37188..b56414b4 100644 --- a/include/parlay/portability.h +++ b/include/parlay/portability.h @@ -76,13 +76,15 @@ namespace parlay { #endif -#if defined(__cplusplus) && __cplusplus >= 202002L +#if defined(__has_cpp_attribute) +#if __has_cpp_attribute(likely) && __has_cpp_attribute(unlikely) #define PARLAY_LIKELY [[likely]] #define PARLAY_UNLIKELY [[unlikely]] #else #define PARLAY_LIKELY #define PARLAY_UNLIKELY #endif +#endif // Check for exceptions. The standard suggests __cpp_exceptions. Clang/GCC defined __EXCEPTIONS. // MSVC disables them with _HAS_EXCEPTIONS=0. Might not cover obscure compilers/STLs. From 79229431f6c31f95d4cae9b452691871113b112f Mon Sep 17 00:00:00 2001 From: Daniel Anderson Date: Thu, 30 Nov 2023 17:47:32 -0500 Subject: [PATCH 2/2] Missing include --- CMakeLists.txt | 2 +- include/parlay/portability.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e58bd394..3b9a2cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # ------------------------------------------------------------------- cmake_minimum_required(VERSION 3.14) -project(PARLAY VERSION 2.2.3 +project(PARLAY VERSION 2.2.4 DESCRIPTION "A collection of parallel algorithms and other support for parallelism in C++" LANGUAGES CXX) diff --git a/include/parlay/portability.h b/include/parlay/portability.h index b56414b4..ecfbff87 100644 --- a/include/parlay/portability.h +++ b/include/parlay/portability.h @@ -16,6 +16,7 @@ #include #include +#include namespace parlay {