Skip to content

Commit

Permalink
add missing #include, suppress dumb warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ericniebler committed Dec 24, 2023
1 parent 3f8e5a6 commit b349f53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
11 changes: 10 additions & 1 deletion include/stdexec/__detail/__config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@
#define STDEXEC_PRAGMA_POP() _Pragma("diagnostic pop")
#define STDEXEC_PRAGMA_IGNORE_EDG(...) _Pragma(STDEXEC_STRINGIZE(diag_suppress __VA_ARGS__))
#elif STDEXEC_CLANG() || STDEXEC_GCC()
#define STDEXEC_PRAGMA_PUSH() _Pragma("GCC diagnostic push")
#define STDEXEC_PRAGMA_PUSH() \
_Pragma("GCC diagnostic push") STDEXEC_PRAGMA_IGNORE_GNU("-Wpragmas") STDEXEC_PRAGMA_IGNORE_GNU( \
"-Wunknown-pragmas") STDEXEC_PRAGMA_IGNORE_GNU("-Wunknown-warning-option") \
STDEXEC_PRAGMA_IGNORE_GNU("-Wunknown-attributes") STDEXEC_PRAGMA_IGNORE_GNU("-Wattributes")
#define STDEXEC_PRAGMA_POP() _Pragma("GCC diagnostic pop")
#define STDEXEC_PRAGMA_IGNORE_GNU(...) \
_Pragma(STDEXEC_STRINGIZE(GCC diagnostic ignored __VA_ARGS__))
Expand Down Expand Up @@ -295,6 +298,12 @@
#define STDEXEC_TERMINATE() std::terminate()
#endif

#if STDEXEC_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
#define STDEXEC_TSAN(...) STDEXEC_HEAD_OR_TAIL(1, __VA_ARGS__)
#else
#define STDEXEC_TSAN(...) STDEXEC_HEAD_OR_NULL(0, __VA_ARGS__)
#endif

// Before clang-16, clang did not like libstdc++'s ranges implementation
#if __has_include(<ranges>) && \
(defined(__cpp_lib_ranges) && __cpp_lib_ranges >= 201911L) && \
Expand Down
14 changes: 8 additions & 6 deletions include/stdexec/__detail/__intrusive_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include <memory>
#include <new>

#if STDEXEC_TSAN()
#include <sanitizer/tsan_interface.h>
#endif

namespace stdexec {
namespace __ptr {
template <class _Ty>
Expand Down Expand Up @@ -66,21 +70,19 @@ namespace stdexec {
__refcount_.fetch_add(1, std::memory_order_relaxed);
}

STDEXEC_PRAGMA_PUSH()
STDEXEC_PRAGMA_IGNORE_GNU("-Wtsan")
STDEXEC_PRAGMA_PUSH()
STDEXEC_PRAGMA_IGNORE_GNU("-Wtsan")

void __dec_ref_() noexcept {
if (1u == __refcount_.fetch_sub(1, std::memory_order_release)) {
std::atomic_thread_fence(std::memory_order_acquire);
#if STDEXEC_HAS_FEATURE(thread_sanitizer) || defined(__SANITIZE_THREAD__)
// TSan does not support std::atomic_thread_fence, so we
// need to use the TSan-specific __tsan_acquire instead:
__tsan_acquire(&__refcount_);
#endif
STDEXEC_TSAN(__tsan_acquire(&__refcount_));
delete this;
}
}
STDEXEC_PRAGMA_POP()
STDEXEC_PRAGMA_POP()
};

template <class _Ty>
Expand Down

0 comments on commit b349f53

Please sign in to comment.