First added in #153585 for Darwin only. All Linux AArch64 systems also
have Top Byte Ignore enabled in userspace so the test "just works"
there.
FreeBSD has very recently gained Top Byte Ignore support:
4c6c27d3fb
However it's so recent, I don't want to assume it'll be available on any
random FreeBSD system out there.
There isn't really a good place to put this test, so I put it in the top
level of API, next to the other non-address bit test that didn't have a
good home either.
14 lines
283 B
C
14 lines
283 B
C
#include <stdint.h>
|
|
|
|
uintptr_t get_high_bits(void *ptr) {
|
|
uintptr_t address_bits = 56;
|
|
uintptr_t mask = ~((1ULL << address_bits) - 1);
|
|
uintptr_t ptrtoint = (uintptr_t)ptr;
|
|
uintptr_t high_bits = ptrtoint & mask;
|
|
return high_bits;
|
|
}
|
|
|
|
int main() {
|
|
return 0; // break here
|
|
}
|