From 3f40684f9f13c5d96cded0c60ab55b0bdb28dd25 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 20 Dec 2024 07:09:47 +0300 Subject: [PATCH] Fix `operand of size_t where capability is required` gcc error on CHERI (fix of commit 9db225895) Issue #627 (bdwgc). * os_dep.c [MPROTECT_VDB && GC_ASSERTIONS] (IS_PAGE_ALIGNED): Do not define. * os_dep.c [MPROTECT_VDB] (GC_protect_heap): Expand `IS_PAGE_ALIGNED(start)`; replace `IS_PAGE_ALIGNED(len)` to `(len&(GC_page_size-1))==0`. --- os_dep.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/os_dep.c b/os_dep.c index 24af7934e..a40c821ae 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3633,10 +3633,6 @@ GC_dirty_init(void) } # endif /* !DARWIN */ -# ifdef GC_ASSERTIONS -# define IS_PAGE_ALIGNED(p) ((ADDR(p) & (GC_page_size - 1)) == 0) -# endif - STATIC void GC_protect_heap(void) { @@ -3650,8 +3646,8 @@ GC_protect_heap(void) struct hblk *current_start; /* start of block to be protected */ ptr_t limit; - GC_ASSERT(IS_PAGE_ALIGNED(start)); - GC_ASSERT(IS_PAGE_ALIGNED(len)); + GC_ASSERT((ADDR(start) & (GC_page_size - 1)) == 0); + GC_ASSERT((len & (GC_page_size - 1)) == 0); # ifndef DONT_PROTECT_PTRFREE /* We avoid protecting pointer-free objects unless the page */ /* size differs from HBLKSIZE. */