Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Unity-Technologies/bdwgc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
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 /dyn_load.c
parent2550e0778d60b8b4f595dacd0b2b4dc6f3ea9fa1 (diff)
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 'dyn_load.c')
-rw-r--r--dyn_load.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/dyn_load.c b/dyn_load.c
index 42534c1e..d6616a52 100644
--- a/dyn_load.c
+++ b/dyn_load.c
@@ -485,8 +485,8 @@ STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info,
/* rounding to the next multiple of ALIGNMENT, so, most */
/* probably, we should remove the corresponding assertion */
/* check in GC_add_roots_inner along with this code line. */
- /* start pointer value may require aligning */
- start = (ptr_t)((word)start & ~(sizeof(word) - 1));
+ /* start pointer value may require aligning. */
+ start = (ptr_t)((word)start & ~(word)(sizeof(word) - 1));
# endif
if (n_load_segs >= MAX_LOAD_SEGS) {
if (!load_segs_overflow) {
@@ -926,7 +926,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
# else
char * stack_top
= (char *)((word)GC_approx_sp() &
- ~(GC_sysinfo.dwAllocationGranularity - 1));
+ ~(word)(GC_sysinfo.dwAllocationGranularity - 1));
if (base == limit) return;
if ((word)limit > (word)stack_top