From 93374170974aba0e9992c5acedb52d887f237a93 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Wed, 7 Nov 2018 23:34:04 +0300 Subject: Use GC_WORD_MAX macro across all C source files (code refactoring) * alloc.c (GC_collect_at_heapsize, GC_compute_heap_usage_percent, GC_add_to_heap, GC_expand_hp_inner): Use GC_WORD_MAX instead of (word)-1. * dyn_load.c [DATASTART_IS_FUNC] (GC_register_dynamic_libraries_dl_iterate_phdr): Likewise. * finalize.c [KEEP_BACK_PTRS] (GC_notify_or_invoke_finalizers): Likewise. * headers.c (GC_install_counts): Likewise. * include/private/thread_local_alloc.h [GC_GCJ_SUPPORT] (ERROR_FL): Likewise. * os_dep.c [NEED_FIND_LIMIT || USE_PROC_FOR_LIBRARIES] (GC_find_limit): Likewise. * os_dep.c [MPROTECT_VDB && DARWIN] (GC_mprotect_thread): Likewise. * pthread_support.c [PARALLEL_MARK] (GC_mark_thread): Likewise. * win32_threads.c (ADDR_LIMIT): Likewise. * win32_threads.c [PARALLEL_MARK] (GC_mark_thread): Likewise. * alloc.c (GC_least_plausible_heap_addr): Use GC_WORD_MAX instead of ONES macro. * include/private/gc_priv.h [STACK_GROWS_DOWN] (MAKE_COOLER): Likewise. * mark.c (GC_set_hdr_marks): Likewise. * alloc.c (GC_WORD_MAX): Remove definition (in this file). * headers.c (GC_install_counts): Reformat code. * include/private/gc_priv.h (ONES): Rename to GC_WORD_MAX. --- headers.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'headers.c') diff --git a/headers.c b/headers.c index 462da89f..1b3b3ebb 100644 --- a/headers.c +++ b/headers.c @@ -283,17 +283,19 @@ GC_INNER GC_bool GC_install_counts(struct hblk *h, size_t sz/* bytes */) struct hblk * hbp; for (hbp = h; (word)hbp < (word)h + sz; hbp += BOTTOM_SZ) { - if (!get_index((word) hbp)) return(FALSE); - if ((word)hbp > (~(word)0) - (word)BOTTOM_SZ * HBLKSIZE) + if (!get_index((word)hbp)) + return FALSE; + if ((word)hbp > GC_WORD_MAX - (word)BOTTOM_SZ * HBLKSIZE) break; /* overflow of hbp+=BOTTOM_SZ is expected */ } - if (!get_index((word)h + sz - 1)) return(FALSE); + if (!get_index((word)h + sz - 1)) + return FALSE; for (hbp = h + 1; (word)hbp < (word)h + sz; hbp += 1) { word i = HBLK_PTR_DIFF(hbp, h); SET_HDR(hbp, (hdr *)(i > MAX_JUMP? MAX_JUMP : i)); } - return(TRUE); + return TRUE; } /* Remove the header for block h */ -- cgit v1.2.1