RSSAmplifier

Blog

Ryan Chung

A blog exploring whatever intrigues me.

nekrozqliphort.github.ioRSS feed ↗5 posts

Latest posts

Learner's Notes: Linux membarrier() System Call - Details of Asymmetric Fences

Asymmetric Fences? While browsing through Folly’s synchronization primitives to study up on concurrency concepts, one familiar-looking name in the codebase caught my attention: Asymmetric Thread Fence. I already knew what std::atomic_thread_fence is meant to achieve, but what does this construct do? And what exactly is asymmetric about it? That question led me down an interesting rabbit hole: ...

Learner's Notes: Alignment and padding - What does [[no_unique_address]] do?

Problem Statement Let’s start with a small, innocent-looking example: struct Foo { long long foo_val; bool foo_val2; }; template <typename T> struct MaybeDeleted { T val; bool deleted; }; static_assert(sizeof(Foo) == 16); static_assert(alignof(Foo) == 8); static_assert(sizeof(MaybeDeleted<Foo>) == 24); At first glance, nothing here looks particularly suspi...

Learner's Notes: Memory Order Side Chapter - The Story Of Strongly Happens Before

Strongly Happens Before? It started innocently enough. I just wanted to brush up on C++ memory orderings. It’s been a while since I last stared into the abyss of std::atomic, so I figured, why not revisit some good ol’ std::memory_order mayhem? Then I saw it. Strongly happens before. Wait, what? When did we get a stronger version of happens before? Turns out, it has been there for quite some...

Learner's Notes: Exploring C++ Undefined Behavior (Part 3) – Best Practices for Low-Level Object Manipulation

Quick Note: If you’re into the nitty-gritty details, be sure to check out Part 1 and Part 2. But if you’re here for practical advice, welcome to Part 3! Best Practices As promised in the Part 2, here are the three key rules to keep in mind when dealing with low-level object manipulation: Always use arrays of std::byte or unsigned char as memory buffers instead of char. Always check whet...

Learner's Notes: Exploring C++ Undefined Behavior (Part 2) – Revisiting std::launder

Quick Note: If you haven’t read Part 1, why are you here? Turn back and read Part 1! Looking Back At Our Fix In our previous post, we came up with the following implementation: template<std::size_t N> struct MyAllocator { std::byte data[N]; void* p; std::size_t sz; MyAllocator() : p(data), sz(N) {} // Note: Only well-defined for implicit-lifetime types template&...