Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Fix barrier offsetof calc
Browse files Browse the repository at this point in the history
  • Loading branch information
wmaxey committed Aug 10, 2021
1 parent 4b82954 commit 32f88dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/cuda/std/barrier
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public:

_LIBCUDACXX_INLINE_VISIBILITY
barrier(std::ptrdiff_t __expected, std::__empty_completion __completion = std::__empty_completion()) {
static_assert(offsetof(barrier<thread_scope_block>, __barrier) == 0, "fatal error: bad barrier layout");
static_assert(_LIBCUDACXX_OFFSET_IS_ZERO(barrier<thread_scope_block>, __barrier), "fatal error: bad barrier layout");
init(this, __expected, __completion);
}

Expand Down
6 changes: 6 additions & 0 deletions libcxx/include/__config
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,12 @@ extern "C++" {

#define _LIBCUDACXX_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)

#if defined(_LIBCUDACXX_COMPILER_NVRTC)
#define _LIBCUDACXX_OFFSET_IS_ZERO(type, member) !(&(((type *)0)->member))
#else
#define _LIBCUDACXX_OFFSET_IS_ZERO(type, member) !offsetof(type, member)
#endif

#if defined(_LIBCUDACXX_COMPILER_CLANG)

// _LIBCUDACXX_ALTERNATE_STRING_LAYOUT is an old name for
Expand Down

0 comments on commit 32f88dd

Please sign in to comment.