Created
April 18, 2014 19:46
-
-
Save amckinley/11061307 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef unsigned __int128 TaggedPointer; | |
#define TP_GET_PTR(ptr) ((Node *)((ptr) >> 64)) | |
#define TP_GET_VERSION(ptr) ((uint64_t)(ptr)) | |
TaggedPointer pack_tagged_pointer(void *ptr, uint64_t version) { | |
printf("args of %p, %lu\n", ptr, version); | |
unsigned __int128 result = (intptr_t)ptr; | |
result = result << 64; | |
result |= version; | |
return result; | |
} | |
TaggedPointer tp = pack_tagged_pointer(&foo, 1); | |
printf("res = %d, version = %lu, ptr = %p\n", res, TP_GET_VERSION(tp), TP_GET_PTR(tp)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment