I need a way to mark the pointer as part of set x or part of set y (i.e. the tag has only 2 'states'), I want to be able to accept unagged = x and tagged = y.
I am currently looking for using bitwise xor for this:
ptr ^ magic = encoded_ptr
encoded_ptr ^ magic = ptr
but I don’t understand how to determine if the pointer is marked first. I use this to mark what happens to the pool nodes in a linked list, so that when they are overloaded, they can return to the correct words.
Update
Just to make it clear to all those people who offer to store the flag in additional data members, I am limited sizeof(void*), so I can not add new members, otherwise I would do it. Also, pools do not touch, they consist of many pages, tracking ranges will add too much overhead (after a quick and easy decision, so to speak).
source
share