From 7478c9959ae409f7b3d63146943575d6ee745352 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 13 Aug 2021 10:06:04 -0300 Subject: malloc: Add THP/madvise support for sbrk To increase effectiveness with Transparent Huge Page with madvise, the large page size is use instead page size for sbrk increment for the main arena. Checked on x86_64-linux-gnu. Reviewed-by: DJ Delorie --- include/libc-pointer-arith.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include/libc-pointer-arith.h') diff --git a/include/libc-pointer-arith.h b/include/libc-pointer-arith.h index 04ba537617..55dccc10ac 100644 --- a/include/libc-pointer-arith.h +++ b/include/libc-pointer-arith.h @@ -60,4 +60,12 @@ #define PTR_ALIGN_UP(base, size) \ ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size))) +/* Check if BASE is aligned on SIZE */ +#define PTR_IS_ALIGNED(base, size) \ + ((((uintptr_t) (base)) & (size - 1)) == 0) + +/* Returns the ptrdiff_t diference between P1 and P2. */ +#define PTR_DIFF(p1, p2) \ + ((ptrdiff_t)((uintptr_t)(p1) - (uintptr_t)(p2))) + #endif -- cgit v1.2.3-70-g09d2