aboutsummaryrefslogtreecommitdiffstats
path: root/vespamalloc
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-11-16 07:42:34 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-11-16 07:42:34 +0000
commit0c35723cac50489a60098578e18ed0a6cef21d85 (patch)
tree3ea43f9f9a646332670b9ba7bbf59b19fbb7e9b4 /vespamalloc
parent3382dafd239b298012b06ae28dcdb520d2a64fe8 (diff)
Use std::atomics for all, but x86_64.
Diffstat (limited to 'vespamalloc')
-rw-r--r--vespamalloc/src/vespamalloc/malloc/allocchunk.h16
1 files changed, 10 insertions, 6 deletions
diff --git a/vespamalloc/src/vespamalloc/malloc/allocchunk.h b/vespamalloc/src/vespamalloc/malloc/allocchunk.h
index efacb0a2085..7df8e12b470 100644
--- a/vespamalloc/src/vespamalloc/malloc/allocchunk.h
+++ b/vespamalloc/src/vespamalloc/malloc/allocchunk.h
@@ -16,9 +16,9 @@ namespace vespamalloc {
* but requires the double-word compare-and-swap instruction.
* Very early Amd K7/8 CPUs are lacking this and will fail (Illegal Instruction).
**/
-struct TaggedPtr {
- TaggedPtr() noexcept : _ptr(nullptr), _tag(0) { }
- TaggedPtr(void *h, size_t t) noexcept : _ptr(h), _tag(t) {}
+struct TaggedPtrT {
+ TaggedPtrT() noexcept : _ptr(nullptr), _tag(0) { }
+ TaggedPtrT(void *h, size_t t) noexcept : _ptr(h), _tag(t) {}
void *_ptr;
size_t _tag;
@@ -61,16 +61,20 @@ struct AtomicTaggedPtr {
void *_ptr;
size_t _tag;
} __attribute__ ((aligned (16)));
+
+using TaggedPtr = AtomicTaggedPtr;
+
#else
- using AtomicTaggedPtr = TaggedPtr;
+ using TaggedPtr = TaggedPtrT;
+ using AtomicTaggedPtr = std::atomic<TaggedPtr>;
#endif
class AFListBase
{
public:
- using HeadPtr = std::conditional<std::atomic<TaggedPtr>::is_always_lock_free, TaggedPtr, AtomicTaggedPtr>::type;
- using AtomicHeadPtr = std::conditional<std::atomic<TaggedPtr>::is_always_lock_free, std::atomic<TaggedPtr>, AtomicTaggedPtr>::type;
+ using HeadPtr = TaggedPtr;
+ using AtomicHeadPtr = std::atomic<TaggedPtr>;
AFListBase() : _next(nullptr) { }
void setNext(AFListBase * csl) { _next = csl; }