Commit 7f9a0ca7 authored by Matthias Vallentin's avatar Matthias Vallentin

Work around offsetof quirk on Clang/libc++/Linux

Resolves #519.
parent 9f3078e1
...@@ -45,12 +45,17 @@ public: ...@@ -45,12 +45,17 @@ public:
// 1) make sure control block fits into a single cache line // 1) make sure control block fits into a single cache line
static_assert(sizeof(actor_control_block) < CAF_CACHE_LINE_SIZE, static_assert(sizeof(actor_control_block) < CAF_CACHE_LINE_SIZE,
"actor_control_block exceeds a single cache line"); "actor_control_block exceeds a single cache line");
// Clang in combination with libc++ on Linux complains about offsetof:
// error: 'actor_storage' does not refer to a value
// Until we have found a reliable solution, we disable this safety check.
#if !(defined(CAF_CLANG) && defined(CAF_LINUX))
// 2) make sure reinterpret cast of the control block to the storage works // 2) make sure reinterpret cast of the control block to the storage works
static_assert(offsetof(actor_storage, ctrl) == 0, static_assert(offsetof(actor_storage, ctrl) == 0,
"control block is not at the start of the storage"); "control block is not at the start of the storage");
// 3) make sure we can obtain a data pointer by jumping one cache line // 3) make sure we can obtain a data pointer by jumping one cache line
static_assert(offsetof(actor_storage, data) == CAF_CACHE_LINE_SIZE, static_assert(offsetof(actor_storage, data) == CAF_CACHE_LINE_SIZE,
"data is not at cache line size boundary"); "data is not at cache line size boundary");
#endif
// 4) make sure static_cast and reinterpret_cast // 4) make sure static_cast and reinterpret_cast
// between T* and abstract_actor* are identical // between T* and abstract_actor* are identical
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment