#include /* **** For a system where a pointer is an unsigned long long: */ typedef unsigned long long uintptr_t; #define UINTPTR_CONST(p) ((uintptr_t)p##ULL) #define UINTPTRXf "llX" /* **** For a system where a pointer is an unsigned long: typedef unsigned long uintptr_t; #define UINTPTR_CONST(p) ((uintptr_t)p##UL) #define UINTPTRXf "lX" */ #define NOP_BITS 2 #define BIT_BITS 3 #define BYTE_BITS 14 #define NOP_MASK UINTPTR_CONST(0x00000003) #define BIT_MASK UINTPTR_CONST(0x00000007) #define BYTE_MASK UINTPTR_CONST(0x00003FFF) #define NOP_OFFSET 0 #define BIT_OFFSET (sizeof(void*) >> 1) #define BYTE_OFFSET (BIT_OFFSET + BIT_BITS) #define SLOT_OFFSET (BYTE_OFFSET + BYTE_BITS) void check_new(void* p) { register uintptr_t i = (uintptr_t)p; uintptr_t slot = ( i >> SLOT_OFFSET ); uintptr_t byte = ( i >> BYTE_OFFSET ) & BYTE_MASK; uintptr_t bit = ( i >> BIT_OFFSET ) & BIT_MASK; uintptr_t nop = ( i >> NOP_OFFSET ) & NOP_MASK; printf("address: %012p " "slot: %012p " "byte: %4"UINTPTRXf" " "bit: %4"UINTPTRXf" " "nop: %"UINTPTRXf"\n", p, (void*)slot, byte, bit, nop ); } int main(int argc, char *argv[]) { void* p; for ( p = (void*)UINTPTR_CONST(123456); p < (void*)(UINTPTR_CONST(1) << 34); p += (UINTPTR_CONST(1) << 29) ) check_new(p); return 0; }