1 #ifndef JEMALLOC_INTERNAL_PAGES_TYPES_H 2 #define JEMALLOC_INTERNAL_PAGES_TYPES_H 3 4 /* Page size. LG_PAGE is determined by the configure script. */ 5 #ifdef PAGE_MASK 6 # undef PAGE_MASK 7 #endif 8 #define PAGE ((size_t)(1U << LG_PAGE)) 9 #define PAGE_MASK ((size_t)(PAGE - 1)) 10 /* Return the page base address for the page containing address a. */ 11 #define PAGE_ADDR2BASE(a) \ 12 ((void *)((uintptr_t)(a) & ~PAGE_MASK)) 13 /* Return the smallest pagesize multiple that is >= s. */ 14 #define PAGE_CEILING(s) \ 15 (((s) + PAGE_MASK) & ~PAGE_MASK) 16 17 /* Huge page size. LG_HUGEPAGE is determined by the configure script. */ 18 #define HUGEPAGE ((size_t)(1U << LG_HUGEPAGE)) 19 #define HUGEPAGE_MASK ((size_t)(HUGEPAGE - 1)) 20 /* Return the huge page base address for the huge page containing address a. */ 21 #define HUGEPAGE_ADDR2BASE(a) \ 22 ((void *)((uintptr_t)(a) & ~HUGEPAGE_MASK)) 23 /* Return the smallest pagesize multiple that is >= s. */ 24 #define HUGEPAGE_CEILING(s) \ 25 (((s) + HUGEPAGE_MASK) & ~HUGEPAGE_MASK) 26 27 /* PAGES_CAN_PURGE_LAZY is defined if lazy purging is supported. */ 28 #if defined(_WIN32) || defined(JEMALLOC_PURGE_MADVISE_FREE) 29 # define PAGES_CAN_PURGE_LAZY 30 #endif 31 /* 32 * PAGES_CAN_PURGE_FORCED is defined if forced purging is supported. 33 * 34 * The only supported way to hard-purge on Windows is to decommit and then 35 * re-commit, but doing so is racy, and if re-commit fails it's a pain to 36 * propagate the "poisoned" memory state. Since we typically decommit as the 37 * next step after purging on Windows anyway, there's no point in adding such 38 * complexity. 39 */ 40 #if !defined(_WIN32) && defined(JEMALLOC_PURGE_MADVISE_DONTNEED) 41 # define PAGES_CAN_PURGE_FORCED 42 #endif 43 44 #endif /* JEMALLOC_INTERNAL_PAGES_TYPES_H */ 45