#ifndef BASE_MEMORY_H #define BASE_MEMORY_H //- asan // Marks memory region [addr, addr+size) as unaddressable. // This memory must be previously allocated by the user program. Accessing // addresses in this region from instrumented code is forbidden until // this region is unpoisoned. This function is not guaranteed to poison // the whole region - it may poison only subregion of [addr, addr+size) due // to ASan alignment restrictions. // Method is NOT thread-safe in the sense that no two threads can // (un)poison memory in the same memory region simultaneously. void __asan_poison_memory_region(void const volatile *addr, size_t size); // Marks memory region [addr, addr+size) as addressable. // This memory must be previously allocated by the user program. Accessing // addresses in this region is allowed until this region is poisoned again. // This function may unpoison a superregion of [addr, addr+size) due to // ASan alignment restrictions. // Method is NOT thread-safe in the sense that no two threads can // (un)poison memory in the same memory region simultaneously. void __asan_unpoison_memory_region(void const volatile *addr, size_t size); // User code should use macros instead of functions. #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__) #define ASAN_POISON_MEMORY_REGION(addr, size) __asan_poison_memory_region((addr), (size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) __asan_unpoison_memory_region((addr), (size)) #else #define ASAN_POISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size)) #define ASAN_UNPOISON_MEMORY_REGION(addr, size) ((void)(addr), (void)(size)) #endif //- helper functions #define KiB(n) (((u64)(n)) << 10) #define MiB(n) (((u64)(n)) << 20) #define GiB(n) (((u64)(n)) << 30) internal b32 is_pow(umm x); internal u64 align(u64 pointer, umm alignment); #endif // BASE_MEMORY_H