summaryrefslogtreecommitdiff
path: root/mark.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-12-07 11:32:30 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-12-07 11:32:30 +0300
commit4338bb085a471f3cf7fbe53c564082a200d3aa3c (patch)
tree772394300904834e23b96a5632cfcc71eada2dbf /mark.c
parent2550e0778d60b8b4f595dacd0b2b4dc6f3ea9fa1 (diff)
downloadbdwgc-4338bb085a471f3cf7fbe53c564082a200d3aa3c.tar.gz
Fix '~' operator application to unsigned values shorter than word
Without the fix, unsigned result of "~" operator is zero-extended to a wide type (word) thus the result has leading zeros (which is not expected to be). * dyn_load.c [HAVE_DL_ITERATE_PHDR] (GC_register_dynlib_callback): Cast (sizeof(word)-1) to word before "~" operation. * mark.c (GC_mark_from): Likewise. * mark_rts.c (GC_add_roots_inner, GC_exclude_static_roots): Likewise. * mark_rts.c [!MSWIN32 && !MSWINCE && !CYGWIN32] (GC_remove_roots_inner): Likewise. * os_dep.c [SVR4 || AUX || DGUX || LINUX && SPARC] (GC_SysVGetDataStart): Likewise. * os_dep.c [!MSWIN32 && DATASTART_USES_BSDGETDATASTART] (GC_FreeBSDGetDataStart): Likewise. * dyn_load.c [(MSWIN32 || MSWINCE || CYGWIN32) && !GC_WIN32_THREADS] (GC_cond_add_roots): Cast (dwAllocationGranularity-1) to word before "~" operation. * include/private/gc_priv.h (HBLKPTR): Cast (HBLKSIZE-1) to word before "~" operation. * os_dep.c [USE_WINALLOC || CYGWIN32] (GC_win32_get_mem): Likewise. * mark.c (GC_mark_from): Change type of new_size local variable from int to word. * os_dep.c [OPENBSD] (GC_find_limit_openbsd, GC_skip_hole_openbsd): Change type of pgsz local variable from size_t to word (to avoid implicit unsigned value extension after "~" operation). * os_dep.c [PROC_VDB] (GC_read_dirty): Cast (sizeof(long)-1) to word before "~" operation.
Diffstat (limited to 'mark.c')
-rw-r--r--mark.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mark.c b/mark.c
index 0e8991c8..8b776f57 100644
--- a/mark.c
+++ b/mark.c
@@ -660,7 +660,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
# define SHARE_BYTES 2048
if (descr > SHARE_BYTES && GC_parallel
&& (word)mark_stack_top < (word)(mark_stack_limit - 1)) {
- int new_size = (descr/2) & ~(sizeof(word)-1);
+ word new_size = (descr/2) & ~(word)(sizeof(word)-1);
+
mark_stack_top -> mse_start = current_p;
mark_stack_top -> mse_descr.w = new_size + sizeof(word);
/* makes sure we handle */