Skip to content

Commit

Permalink
map: Integrate color into lowest bit of parent pointer
Browse files Browse the repository at this point in the history
For the implementation of a red-black tree, we can combine the parent
pointer and color as what Linux kernel does -- inject the color info
in the lowest bit of the parent pointer, resulting in better locaity.
  • Loading branch information
jserv committed Aug 22, 2022
1 parent 8116a20 commit 7fb4ff7
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 101 deletions.
9 changes: 9 additions & 0 deletions common.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
#define unlikely(x) x
#endif

/* Alignment macro */
#if defined(__GNUC__) || defined(__clang__)
#define __ALIGNED(x) __attribute__((aligned(x)))
#elif defined(_MSC_VER)
#define __ALIGNED(x) __declspec(align(x))
#else /* unspported compilers */
#define __ALIGNED(x)
#endif

/* Pattern Matching for C macros.
* https://github.com/pfultz2/Cloak/wiki/C-Preprocessor-tricks,-tips,-and-idioms
*/
Expand Down

0 comments on commit 7fb4ff7

Please sign in to comment.