I wrote a little blog post on storing data in pointers - initially motivated by documenting the impact of >48-bit virtual addresses on such tricks and the various available hardware pointer masking schemes https://muxup.com/2023q4/storing-data-in-pointers Any corrections or additional notes, do let me know!
@asb I have found that these sort of tricks are usually avoidable. However, these tricks can be kind of necessary when working with lock-free algorithms. You need bit hacking to fit in ABA tags as many architecture just don't offer wide enough atomic operations.
You can also use indexes/side tables but it gets messy.
struct node {
_Atomic uint8_t next;
};
struct info;
struct info infos[];
struct info {
uint64_t aba;
struct node *node;
};
Then preallocate the nodes at startup.