Replace pointer relational comparisons with non-pointer ones
authorIvan Maidanski <ivmai@mail.ru>
Mon, 5 Mar 2012 04:08:31 +0000 (08:08 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 5 Mar 2012 11:08:58 +0000 (15:08 +0400)
* allchblk.c (GC_dump_regions, GC_allochblk_nth): Cast pointers to
word type in relational (less-greater) comparisons.
* alloc.c (GC_add_to_heap, GC_print_heap_sects, GC_expand_hp_inner):
Likewise.
* backgraph.c (ensure_struct, add_back_edges): Likewise.
* blacklst.c (GC_number_stack_black_listed): Likewise.
* checksums.c (GC_checksum, GC_check_dirty): Likewise.
* darwin_stop_world.c (GC_push_all_stacks): Likewise.
* dbg_mlc.c (GC_get_back_ptr_info, GC_print_smashed_obj,
GC_check_heap_block): Likewise.
* dyn_load.c (sort_heap_sects, GC_register_map_entries,
GC_register_dynlib_callback,
GC_register_dynamic_libraries_dl_iterate_phdr,
GC_register_dynamic_libraries, GC_cond_add_roots): Likewise.
* finalize.c (GC_ignore_self_finalize_mark_proc): Likewise.
* headers.c (GC_scratch_alloc, GC_install_counts, GC_remove_counts):
Likewise.
* include/private/gc_pmark.h (PUSH_OBJ, PUsH_CONTENTS_HDR,
GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP, GC_mark_stack_empty): Likewise.
* include/private/gc_priv.h (MAKE_COOLER, COOLER_THAN): Likewise.
* mach_dep.c (GC_with_callee_saves_pushed): Likewise.
* malloc.c (calloc, free): Likewise.
* mark.c (GC_mark_some_inner, GC_mark_from, GC_steal_mark_stack,
GC_return_mark_stack, GC_do_local_mark, GC_mark_local, GC_push_all,
GC_push_selected, GC_push_all_eager, GC_push_marked1, GC_push_marked2,
GC_push_marked4, GC_push_marked, GC_push_unconditionally): Likewise.
* mark_rts.c (GC_is_static_root, GC_add_roots_inner,
GC_remove_roots_inner, GC_is_tmp_root, GC_exclude_static_roots_inner,
GC_push_conditional_with_exclusions, GC_push_all_register_sections,
GC_push_all_stack_sections, GC_push_all_stack_partially_eager,
GC_push_all_stack_part_eager_sections, GC_push_current_stack):
Likewise.
* misc.c (GC_clear_stack_inner, GC_clear_stack, GC_base,
GC_call_with_gc_active): Likewise.
* new_hblk.c (GC_build_fl_clear2, GC_build_fl_clear4,  GC_build_fl2,
GC_build_fl4, GC_build_fl): Likewise.
* os_dep.c (GC_enclosing_mapping, GC_text_mapping, tiny_sbrk,
GC_find_limit_openbsd, GC_skip_hole_openbsd, GC_find_limit_with_bound,
GC_get_main_stack_base, GC_get_stack_base, GC_least_described_address,
GC_register_root_section, GC_register_data_segments, GC_unmap_start,
GC_gww_read_dirty, GC_remove_protection, GC_protect_heap,
GC_unprotect_range, GC_read_dirty, GC_page_was_dirty,
GC_save_callers, GC_print_callers): Likewise.
* pcr_interface.c (GC_enumerate_block): Likewise.
* pthread_support.c (GC_is_thread_tsd_valid,
GC_segment_is_thread_stack, GC_greatest_stack_base_below,
GC_call_with_gc_active): Likewise.
* ptr_chck.c (GC_same_obj, GC_is_valid_displacement, GC_on_stack,
GC_is_visible): Likewise.
* reclaim.c (GC_reclaim_clear, GC_reclaim_uninit,
GC_disclaim_and_reclaim, GC_reclaim_check, GC_start_reclaim):
Likewise.
* tests/test.c (cons): Likewise.
* tools/setjmp_t.c (main): Likewise.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* win32_threads.c (GC_is_thread_tsd_valid, GC_call_with_gc_active,
GC_push_stack_for, GC_get_next_stack): Likewise.
* extra/msvc_dbg.c (GetDescriptionFromAddress,
GetDescriptionFromStack): Cast pointers to GC_ULONG_PTR in relational
comparisons.
* include/gc.h (GC_DATASTART, GC_DATAEND): Cast pointers to GC_word in
relational comparisons.
* misc.c (GC_init): Remove static assertion on ((ptr_t)-1 > 0) since
no longer required; add the comment.
* pcr_interface.c: Expand tabs to spaces.

29 files changed:
allchblk.c
alloc.c
backgraph.c
blacklst.c
checksums.c
darwin_stop_world.c
dbg_mlc.c
dyn_load.c
extra/msvc_dbg.c
finalize.c
headers.c
include/gc.h
include/private/gc_pmark.h
include/private/gc_priv.h
mach_dep.c
malloc.c
mark.c
mark_rts.c
misc.c
new_hblk.c
os_dep.c
pcr_interface.c
pthread_support.c
ptr_chck.c
reclaim.c
tests/test.c
tools/setjmp_t.c
typd_mlc.c
win32_threads.c

index b1c4212..bb08e79 100644 (file)
@@ -177,7 +177,7 @@ void GC_dump_regions(void)
             end = GC_heap_sects[i].hs_start + GC_heap_sects[i].hs_bytes;
           }
         GC_printf("***Section from %p to %p\n", start, end);
-        for (p = start; p < end;) {
+        for (p = start; (word)p < (word)end; ) {
             hhdr = HDR(p);
             if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
                 GC_printf("\t%p Missing header!!(%p)\n", p, (void *)hhdr);
@@ -676,7 +676,7 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, int may_split)
                                                 (signed_word)HBLKSIZE
                                                 : size_needed;
 
-              while ((ptr_t)lasthbp <= search_end
+              while ((word)lasthbp <= (word)search_end
                      && (thishbp = GC_is_black_listed(lasthbp,
                                             (word)eff_size_needed)) != 0) {
                 lasthbp = thishbp;
@@ -743,7 +743,7 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, int may_split)
                       GC_large_free_bytes -= total_size;
                       GC_bytes_dropped += total_size;
                       GC_remove_from_fl_at(hhdr, n);
-                      for (h = hbp; h < limit; h++) {
+                      for (h = hbp; (word)h < (word)limit; h++) {
                         if (h == hbp || 0 != (hhdr = GC_install_header(h))) {
                           (void) setup_header(
                                   hhdr, h,
diff --git a/alloc.c b/alloc.c
index 69c7f54..ac01907 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -1054,7 +1054,7 @@ GC_INNER void GC_add_to_heap(struct hblk *p, size_t bytes)
     phdr -> hb_flags = 0;
     GC_freehblk(p);
     GC_heapsize += bytes;
-    if ((ptr_t)p <= (ptr_t)GC_least_plausible_heap_addr
+    if ((word)p <= (word)GC_least_plausible_heap_addr
         || GC_least_plausible_heap_addr == 0) {
         GC_least_plausible_heap_addr = (void *)((ptr_t)p - sizeof(word));
                 /* Making it a little smaller than necessary prevents   */
@@ -1062,7 +1062,7 @@ GC_INNER void GC_add_to_heap(struct hblk *p, size_t bytes)
                 /* itself.  There's some unintentional reflection       */
                 /* here.                                                */
     }
-    if ((ptr_t)p + bytes >= (ptr_t)GC_greatest_plausible_heap_addr) {
+    if ((word)p + bytes >= (word)GC_greatest_plausible_heap_addr) {
         GC_greatest_plausible_heap_addr = (void *)endp;
     }
 }
@@ -1082,7 +1082,7 @@ GC_INNER void GC_add_to_heap(struct hblk *p, size_t bytes)
       struct hblk *h;
       unsigned nbl = 0;
 
-      for (h = (struct hblk *)start; h < (struct hblk *)(start + len); h++) {
+      for (h = (struct hblk *)start; (word)h < (word)(start + len); h++) {
         if (GC_is_black_listed(h, HBLKSIZE)) nbl++;
       }
       GC_printf("Section %d from %p to %p %lu/%lu blacklisted\n",
@@ -1159,7 +1159,8 @@ GC_INNER GC_bool GC_expand_hp_inner(word n)
     /* correctness.                                                     */
     expansion_slop = min_bytes_allocd() + 4*MAXHINCR*HBLKSIZE;
     if ((GC_last_heap_addr == 0 && !((word)space & SIGNB))
-        || (GC_last_heap_addr != 0 && GC_last_heap_addr < (ptr_t)space)) {
+        || (GC_last_heap_addr != 0
+            && (word)GC_last_heap_addr < (word)space)) {
         /* Assume the heap is growing up */
         word new_limit = (word)space + bytes + expansion_slop;
         if (new_limit > (word)space) {
index 6090f8d..6bd2621 100644 (file)
@@ -209,7 +209,7 @@ static void ensure_struct(ptr_t p)
     }
     be -> height = HEIGHT_UNKNOWN;
     be -> height_gc_no = (unsigned short)(GC_gc_no - 1);
-    GC_ASSERT(be >= back_edge_space);
+    GC_ASSERT((word)be >= (word)back_edge_space);
     SET_OH_BG_PTR(p, (word)be | FLAG_MANY);
   }
 }
@@ -327,7 +327,7 @@ static void add_back_edges(ptr_t p, size_t n_bytes, word gc_descr)
     if((gc_descr & GC_DS_TAGS) != GC_DS_LENGTH) {
       gc_descr = n_bytes;
     }
-  while (currentp < (word *)(p + gc_descr)) {
+  while ((word)currentp < (word)(p + gc_descr)) {
     word current = *currentp++;
     FIXUP_POINTER(current);
     if (current >= (word)GC_least_plausible_heap_addr &&
index 234aae7..626a95f 100644 (file)
@@ -265,7 +265,7 @@ STATIC word GC_number_stack_black_listed(struct hblk *start,
     register struct hblk * h;
     word result = 0;
 
-    for (h = start; h < endp1; h++) {
+    for (h = start; (word)h < (word)endp1; h++) {
         word index = PHT_HASH((word)h);
 
         if (get_pht_entry_from_index(GC_old_stack_bl, index)) result++;
index 414ee36..8ca587d 100644 (file)
@@ -68,7 +68,7 @@ STATIC word GC_checksum(struct hblk *h)
     word *lim = (word *)(h+1);
     word result = 0;
 
-    while (p < lim) {
+    while ((word)p < (word)lim) {
         result += *p++;
     }
     return(result | 0x80000000 /* doesn't look like pointer */);
@@ -193,8 +193,7 @@ void GC_check_dirty(void)
     for (i = 0; i < GC_n_heap_sects; i++) {
         start = GC_heap_sects[i].hs_start;
         for (h = (struct hblk *)start;
-             h < (struct hblk *)(start + GC_heap_sects[i].hs_bytes);
-             h++) {
+             (word)h < (word)(start + GC_heap_sects[i].hs_bytes); h++) {
              GC_update_check_page(h, index);
              index++;
              if (index >= NSUMS) goto out;
index cd72779..8851893 100644 (file)
@@ -290,7 +290,7 @@ GC_INNER void GC_push_all_stacks(void)
       for (i = 0; i < (int)listcount; i++) {
         thread_act_t thread = act_list[i];
         lo = GC_stack_range_for(&hi, thread, NULL, FALSE, my_thread);
-        GC_ASSERT(lo <= hi);
+        GC_ASSERT((word)lo <= (word)hi);
         total_size += hi - lo;
         GC_push_all_stack(lo, hi);
         nthreads++;
@@ -311,7 +311,7 @@ GC_INNER void GC_push_all_stacks(void)
           thread_act_t thread = (thread_act_t)p->stop_info.mach_thread;
           lo = GC_stack_range_for(&hi, thread, p, (GC_bool)p->thread_blocked,
                                   my_thread);
-          GC_ASSERT(lo <= hi);
+          GC_ASSERT((word)lo <= (word)hi);
           total_size += hi - lo;
           GC_push_all_stack_sections(lo, hi, p->traced_stack_sect);
           nthreads++;
index 94cbe16..5f03d10 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
         ptr_t target = *(ptr_t *)bp;
         ptr_t alternate_target = *(ptr_t *)alternate_ptr;
 
-        if (alternate_target >= GC_least_plausible_heap_addr
-            && alternate_target <= GC_greatest_plausible_heap_addr
-            && (target < GC_least_plausible_heap_addr
-                || target > GC_greatest_plausible_heap_addr)) {
+        if ((word)alternate_target >= (word)GC_least_plausible_heap_addr
+            && (word)alternate_target <= (word)GC_greatest_plausible_heap_addr
+            && ((word)target < (word)GC_least_plausible_heap_addr
+                || (word)target > (word)GC_greatest_plausible_heap_addr)) {
             bp = alternate_ptr;
         }
       }
@@ -411,7 +411,7 @@ STATIC void GC_debug_print_heap_obj_proc(ptr_t p)
 #   ifdef LINT2
       if (!ohdr) ABORT("Invalid GC_print_smashed_obj argument");
 #   endif
-    if (clobbered_addr <= (ptr_t)(&(ohdr -> oh_sz))
+    if ((word)clobbered_addr <= (word)(&ohdr->oh_sz)
         || ohdr -> oh_string == 0) {
         GC_err_printf(
                 "%s %p in or near object at %p(<smashed>, appr. sz = %lu)\n",
@@ -941,7 +941,8 @@ STATIC void GC_check_heap_block(struct hblk *hbp, word dummy GC_ATTR_UNUSED)
       plim = hbp->hb_body + HBLKSIZE - sz;
     }
     /* go through all words in block */
-    for (bit_no = 0; p <= plim; bit_no += MARK_BIT_OFFSET(sz), p += sz) {
+    for (bit_no = 0; (word)p <= (word)plim;
+         bit_no += MARK_BIT_OFFSET(sz), p += sz) {
       if (mark_bit_from_hdr(hhdr, bit_no) && GC_HAS_DEBUG_INFO((ptr_t)p)) {
         ptr_t clobbered = GC_check_annotated_obj((oh *)p);
         if (clobbered != 0)
index 62cb6ed..3be74eb 100644 (file)
@@ -246,18 +246,18 @@ static void sort_heap_sects(struct HeapSect *base, size_t number_of_elements)
 
     while (nsorted < n) {
       while (nsorted < n &&
-             base[nsorted-1].hs_start < base[nsorted].hs_start)
+             (word)base[nsorted-1].hs_start < (word)base[nsorted].hs_start)
           ++nsorted;
       if (nsorted == n) break;
-      GC_ASSERT(base[nsorted-1].hs_start > base[nsorted].hs_start);
+      GC_ASSERT((word)base[nsorted-1].hs_start > (word)base[nsorted].hs_start);
       i = nsorted - 1;
-      while (i >= 0 && base[i].hs_start > base[i+1].hs_start) {
+      while (i >= 0 && (word)base[i].hs_start > (word)base[i+1].hs_start) {
         struct HeapSect tmp = base[i];
         base[i] = base[i+1];
         base[i+1] = tmp;
         --i;
       }
-      GC_ASSERT(base[nsorted-1].hs_start < base[nsorted].hs_start);
+      GC_ASSERT((word)base[nsorted-1].hs_start < (word)base[nsorted].hs_start);
       ++nsorted;
     }
 }
@@ -298,7 +298,8 @@ STATIC word GC_register_map_entries(char *maps)
             /* This is a writable mapping.  Add it to           */
             /* the root set unless it is already otherwise      */
             /* accounted for.                                   */
-            if (start <= GC_stackbottom && end >= GC_stackbottom) {
+            if ((word)start <= (word)GC_stackbottom
+                && (word)end >= (word)GC_stackbottom) {
                 /* Stack mapping; discard       */
                 continue;
             }
@@ -328,32 +329,34 @@ STATIC word GC_register_map_entries(char *maps)
               /* very suboptimal for performance reasons.               */
 #           endif
             /* We no longer exclude the main data segment.              */
-            if (end <= least_ha || start >= greatest_ha) {
+            if ((word)end <= (word)least_ha
+                || (word)start >= (word)greatest_ha) {
               /* The easy case; just trace entire segment */
               GC_add_roots_inner((char *)start, (char *)end, TRUE);
               continue;
             }
             /* Add sections that don't belong to us. */
               i = 0;
-              while (GC_our_memory[i].hs_start + GC_our_memory[i].hs_bytes
-                     start)
+              while ((word)(GC_our_memory[i].hs_start
+                                + GC_our_memory[i].hs_bytes) < (word)start)
                   ++i;
               GC_ASSERT(i < GC_n_memory);
-              if (GC_our_memory[i].hs_start <= start) {
+              if ((word)GC_our_memory[i].hs_start <= (word)start) {
                   start = GC_our_memory[i].hs_start
                           + GC_our_memory[i].hs_bytes;
                   ++i;
               }
-              while (i < GC_n_memory && GC_our_memory[i].hs_start < end
-                     && start < end) {
-                  if ((char *)start < GC_our_memory[i].hs_start)
+              while (i < GC_n_memory
+                     && (word)GC_our_memory[i].hs_start < (word)end
+                     && (word)start < (word)end) {
+                  if ((word)start < (word)GC_our_memory[i].hs_start)
                     GC_add_roots_inner((char *)start,
                                        GC_our_memory[i].hs_start, TRUE);
                   start = GC_our_memory[i].hs_start
                           + GC_our_memory[i].hs_bytes;
                   ++i;
               }
-              if (start < end)
+              if ((word)start < (word)end)
                   GC_add_roots_inner((char *)start, (char *)end, TRUE);
         }
     }
@@ -448,11 +451,12 @@ STATIC int GC_register_dynlib_callback(struct dl_phdr_info * info,
             start = ((ptr_t)(p->p_vaddr)) + info->dlpi_addr;
             end = start + p->p_memsz;
             for (j = n_load_segs; --j >= 0; ) {
-              if (start >= load_segs[j].start && start < load_segs[j].end) {
+              if ((word)start >= (word)load_segs[j].start
+                  && (word)start < (word)load_segs[j].end) {
                 if (load_segs[j].start2 != 0) {
                   WARN("More than one GNU_RELRO segment per load seg\n",0);
                 } else {
-                  GC_ASSERT(end <= load_segs[j].end);
+                  GC_ASSERT((word)end <= (word)load_segs[j].end);
                   /* Remove from the existing load segment */
                   load_segs[j].end2 = load_segs[j].end;
                   load_segs[j].end = start;
@@ -544,10 +548,10 @@ STATIC GC_bool GC_register_dynamic_libraries_dl_iterate_phdr(void)
       int i;
 
       for (i = 0; i < n_load_segs; ++i) {
-        if (load_segs[i].end > load_segs[i].start) {
+        if ((word)load_segs[i].end > (word)load_segs[i].start) {
           GC_add_roots_inner(load_segs[i].start, load_segs[i].end, TRUE);
         }
-        if (load_segs[i].end2 > load_segs[i].start2) {
+        if ((word)load_segs[i].end2 > (word)load_segs[i].start2) {
           GC_add_roots_inner(load_segs[i].start2, load_segs[i].end2, TRUE);
         }
       }
@@ -755,7 +759,8 @@ GC_INNER void GC_register_dynamic_libraries(void)
     if (GC_n_heap_sects > 0) {
         heap_end = GC_heap_sects[GC_n_heap_sects-1].hs_start
                         + GC_heap_sects[GC_n_heap_sects-1].hs_bytes;
-        if (heap_end < GC_scratch_last_end_ptr) heap_end = GC_scratch_last_end_ptr;
+        if ((word)heap_end < (word)GC_scratch_last_end_ptr)
+          heap_end = GC_scratch_last_end_ptr;
     }
     for (i = 0; i < needed_sz; i++) {
         flags = addr_map[i].pr_mflags;
@@ -770,7 +775,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
           /* This makes no sense to me. - HB                            */
         start = (ptr_t)(addr_map[i].pr_vaddr);
         if (GC_roots_present(start)) goto irrelevant;
-        if (start < heap_end && start >= heap_start)
+        if ((word)start < (word)heap_end && (word)start >= (word)heap_start)
                 goto irrelevant;
 
         limit = start + addr_map[i].pr_size;
@@ -839,18 +844,20 @@ GC_INNER void GC_register_dynamic_libraries(void)
       if (base == limit) return;
       for(;;) {
           GC_get_next_stack(curr_base, limit, &next_stack_lo, &next_stack_hi);
-          if (next_stack_lo >= limit) break;
-          if (next_stack_lo > curr_base)
+          if ((word)next_stack_lo >= (word)limit) break;
+          if ((word)next_stack_lo > (word)curr_base)
             GC_add_roots_inner(curr_base, next_stack_lo, TRUE);
           curr_base = next_stack_hi;
       }
-      if (curr_base < limit) GC_add_roots_inner(curr_base, limit, TRUE);
+      if ((word)curr_base < (word)limit)
+        GC_add_roots_inner(curr_base, limit, TRUE);
 #   else
       char dummy;
       char * stack_top
          = (char *) ((word)(&dummy) & ~(GC_sysinfo.dwAllocationGranularity-1));
       if (base == limit) return;
-      if (limit > stack_top && base < GC_stackbottom) {
+      if ((word)limit > (word)stack_top
+          && (word)base < (word)GC_stackbottom) {
           /* Part of the stack; ignore it. */
           return;
       }
@@ -907,7 +914,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
       if (GC_no_win32_dlls) return;
 #   endif
     base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
-    while (p < GC_sysinfo.lpMaximumApplicationAddress) {
+    while ((word)p < (word)GC_sysinfo.lpMaximumApplicationAddress) {
         result = VirtualQuery(p, &buf, sizeof(buf));
 #       ifdef MSWINCE
           if (result == 0) {
@@ -948,7 +955,7 @@ GC_INNER void GC_register_dynamic_libraries(void)
                 limit = new_limit;
             }
         }
-        if (p > (LPVOID)new_limit /* overflow */) break;
+        if ((word)p > (word)new_limit /* overflow */) break;
         p = (LPVOID)new_limit;
     }
     GC_cond_add_roots(base, limit);
index 5bc216a..7884ecd 100644 (file)
@@ -314,7 +314,7 @@ size_t GetDescriptionFromAddress(void* address, const char* format,
     *buffer = 0;
   }
   buffer += GetFileLineFromAddress(address, buffer, size, &line_number, NULL);
-  size = end < buffer ? 0 : end - buffer;
+  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   if (line_number) {
     wsprintf(str, "(%d) : ", line_number);
@@ -322,26 +322,26 @@ size_t GetDescriptionFromAddress(void* address, const char* format,
       strncpy(buffer, str, size)[size - 1] = 0;
     }
     buffer += strlen(str);
-    size = end < buffer ? 0 : end - buffer;
+    size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
   }
 
   if (size) {
     strncpy(buffer, "at ", size)[size - 1] = 0;
   }
   buffer += strlen("at ");
-  size = end < buffer ? 0 : end - buffer;
+  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   buffer += GetSymbolNameFromAddress(address, buffer, size, NULL);
-  size = end < buffer ? 0 : end - buffer;
+  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   if (size) {
     strncpy(buffer, " in ", size)[size - 1] = 0;
   }
   buffer += strlen(" in ");
-  size = end < buffer ? 0 : end - buffer;
+  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   buffer += GetModuleNameFromAddress(address, buffer, size);
-  size = end < buffer ? 0 : end - buffer;
+  size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
 
   return buffer - begin;
 }
@@ -356,7 +356,7 @@ size_t GetDescriptionFromStack(void* const frames[], size_t count,
   size_t i;
   for (i = 0; i < count; ++i) {
     if (description) description[i] = buffer;
-    size = end < buffer ? 0 : end - buffer;
+    size = (GC_ULONG_PTR)end < (GC_ULONG_PTR)buffer ? 0 : end - buffer;
     buffer += 1 + GetDescriptionFromAddress(frames[i], NULL, buffer, size);
   }
   if (description) description[count] = NULL;
index 62bed34..0e20f55 100644 (file)
@@ -324,9 +324,9 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
     } else {
        scan_limit = target_limit + 1 - sizeof(word);
     }
-    for (q = p; q <= scan_limit; q += ALIGNMENT) {
+    for (q = p; (word)q <= (word)scan_limit; q += ALIGNMENT) {
         r = *(word *)q;
-        if ((ptr_t)r < p || (ptr_t)r > target_limit) {
+        if (r < (word)p || r > (word)target_limit) {
             GC_PUSH_ONE_HEAP(r, q, GC_mark_stack_top);
         }
     }
index de82c20..71ab29f 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -122,7 +122,7 @@ GC_INNER ptr_t GC_scratch_alloc(size_t bytes)
     bytes += GRANULE_BYTES-1;
     bytes &= ~(GRANULE_BYTES-1);
     scratch_free_ptr += bytes;
-    if (scratch_free_ptr <= GC_scratch_end_ptr) {
+    if ((word)scratch_free_ptr <= (word)GC_scratch_end_ptr) {
         return(result);
     }
     {
@@ -276,11 +276,11 @@ GC_INNER GC_bool GC_install_counts(struct hblk *h, size_t sz/* bytes */)
     struct hblk * hbp;
     word i;
 
-    for (hbp = h; (char *)hbp < (char *)h + sz; hbp += BOTTOM_SZ) {
+    for (hbp = h; (word)hbp < (word)h + sz; hbp += BOTTOM_SZ) {
         if (!get_index((word) hbp)) return(FALSE);
     }
     if (!get_index((word)h + sz - 1)) return(FALSE);
-    for (hbp = h + 1; (char *)hbp < (char *)h + sz; hbp += 1) {
+    for (hbp = h + 1; (word)hbp < (word)h + sz; hbp += 1) {
         i = HBLK_PTR_DIFF(hbp, h);
         SET_HDR(hbp, (hdr *)(i > MAX_JUMP? MAX_JUMP : i));
     }
@@ -300,7 +300,7 @@ GC_INNER void GC_remove_header(struct hblk *h)
 GC_INNER void GC_remove_counts(struct hblk *h, size_t sz/* bytes */)
 {
     register struct hblk * hbp;
-    for (hbp = h+1; (char *)hbp < (char *)h + sz; hbp += 1) {
+    for (hbp = h+1; (word)hbp < (word)h + sz; hbp += 1) {
         SET_HDR(hbp, 0);
     }
 }
index 80d104c..f3958f9 100644 (file)
@@ -1460,9 +1460,9 @@ GC_API int GC_CALL GC_get_force_unmap_on_gcollect(void);
   /* Similarly gnu-win32 DLLs need explicit initialization from the     */
   /* main program, as does AIX.                                         */
   extern int _data_start__[], _data_end__[], _bss_start__[], _bss_end__[];
-# define GC_DATASTART (_data_start__ < _bss_start__ ? \
+# define GC_DATASTART ((GC_word)_data_start__ < (GC_word)_bss_start__ ? \
                        (void *)_data_start__ : (void *)_bss_start__)
-# define GC_DATAEND (_data_end__ > _bss_end__ ? \
+# define GC_DATAEND ((GC_word)_data_end__ > (GC_word)_bss_end__ ? \
                      (void *)_data_end__ : (void *)_bss_end__)
 # define GC_INIT_CONF_ROOTS GC_add_roots(GC_DATASTART, GC_DATAEND); \
                                  GC_gcollect() /* For blacklisting. */
index f14e6bb..8351d6b 100644 (file)
@@ -138,7 +138,7 @@ GC_INNER mse * GC_signal_mark_stack_overflow(mse *msp);
     GC_ASSERT(!HBLK_IS_FREE(hhdr)); \
     if (_descr != 0) { \
         mark_stack_top++; \
-        if (mark_stack_top >= mark_stack_limit) { \
+        if ((word)mark_stack_top >= (word)(mark_stack_limit)) { \
           mark_stack_top = GC_signal_mark_stack_overflow(mark_stack_top); \
         } \
         mark_stack_top -> mse_start = (obj); \
@@ -273,7 +273,7 @@ exit_label: ; \
           gran_displ = 0; \
           GC_ASSERT(hhdr -> hb_sz > HBLKSIZE || \
                     hhdr -> hb_block == HBLKPTR(current)); \
-          GC_ASSERT((ptr_t)(hhdr -> hb_block) <= (ptr_t) current); \
+          GC_ASSERT((word)hhdr->hb_block <= (word)(current)); \
         } else { \
           size_t obj_displ = GRANULES_TO_BYTES(gran_offset) \
                              + byte_offset; \
@@ -329,7 +329,7 @@ exit_label: ; \
           } \
           GC_ASSERT(hhdr -> hb_sz > HBLKSIZE || \
                     hhdr -> hb_block == HBLKPTR(current)); \
-          GC_ASSERT((ptr_t)(hhdr -> hb_block) < (ptr_t) current); \
+          GC_ASSERT((word)hhdr->hb_block < (word)(current)); \
         } else { \
           /* Accurate enough if HBLKSIZE <= 2**15.      */ \
           GC_STATIC_ASSERT(HBLKSIZE <= (1 << 15)); \
@@ -377,19 +377,19 @@ exit_label: ; \
 #if NEED_FIXUP_POINTER
     /* Try both the raw version and the fixed up one.   */
 # define GC_PUSH_ONE_STACK(p, source) \
-      if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
-          && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+      if ((word)(p) >= (word)GC_least_plausible_heap_addr \
+          && (word)(p) < (word)GC_greatest_plausible_heap_addr) { \
          PUSH_ONE_CHECKED_STACK(p, source); \
       } \
       FIXUP_POINTER(p); \
-      if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
-          && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+      if ((word)(p) >= (word)GC_least_plausible_heap_addr \
+          && (word)(p) < (word)GC_greatest_plausible_heap_addr) { \
          PUSH_ONE_CHECKED_STACK(p, source); \
       }
 #else /* !NEED_FIXUP_POINTER */
 # define GC_PUSH_ONE_STACK(p, source) \
-      if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
-          && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) { \
+      if ((word)(p) >= (word)GC_least_plausible_heap_addr \
+          && (word)(p) < (word)GC_greatest_plausible_heap_addr) { \
          PUSH_ONE_CHECKED_STACK(p, source); \
       }
 #endif
@@ -398,8 +398,8 @@ exit_label: ; \
 #define GC_PUSH_ONE_HEAP(p,source,mark_stack_top) \
     { \
       FIXUP_POINTER(p); \
-      if ((ptr_t)(p) >= (ptr_t)GC_least_plausible_heap_addr \
-          && (ptr_t)(p) < (ptr_t)GC_greatest_plausible_heap_addr) \
+      if ((word)(p) >= (word)GC_least_plausible_heap_addr \
+          && (word)(p) < (word)GC_greatest_plausible_heap_addr) \
         mark_stack_top = GC_mark_and_push((void *)(p), mark_stack_top, \
                                 GC_mark_stack_limit, (void * *)(source)); \
     }
@@ -415,7 +415,7 @@ GC_INNER mse * GC_mark_from(mse * top, mse * bottom, mse *limit);
                                          GC_mark_stack, \
                                          GC_mark_stack + GC_mark_stack_size);
 
-#define GC_mark_stack_empty() (GC_mark_stack_top < GC_mark_stack)
+#define GC_mark_stack_empty() ((word)GC_mark_stack_top < (word)GC_mark_stack)
 
 /*
  * Mark from one finalizable object using the specified
index 08f7880..0a30c70 100644 (file)
@@ -184,13 +184,14 @@ typedef char * ptr_t;   /* A generic pointer to which we can add        */
 # ifdef STACK_GROWS_DOWN
 #   define COOLER_THAN >
 #   define HOTTER_THAN <
-#   define MAKE_COOLER(x,y) if ((x)+(y) > (x)) {(x) += (y);} \
+#   define MAKE_COOLER(x,y) if ((word)((x) + (y)) > (word)(x)) {(x) += (y);} \
                             else {(x) = (ptr_t)ONES;}
 #   define MAKE_HOTTER(x,y) (x) -= (y)
 # else
 #   define COOLER_THAN <
 #   define HOTTER_THAN >
-#   define MAKE_COOLER(x,y) if ((x)-(y) < (x)) {(x) -= (y);} else {(x) = 0;}
+#   define MAKE_COOLER(x,y) if ((word)((x) - (y)) < (word)(x)) {(x) -= (y);} \
+                            else {(x) = 0;}
 #   define MAKE_HOTTER(x,y) (x) += (y)
 # endif
 
index 28ad562..cf842fc 100644 (file)
@@ -287,7 +287,7 @@ GC_INNER void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
 
         /* Setjmp doesn't always clear all of the buffer.               */
         /* That tends to preserve garbage.  Clear it.                   */
-        for (; (char *)i < lim; i++) {
+        for (; (word)i < (word)lim; i++) {
             *i = 0;
         }
 #       if defined(MSWIN32) || defined(MSWINCE) || defined(UTS4) \
index bbe81a1..da68f13 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -386,8 +386,10 @@ void * calloc(size_t n, size_t lb)
             GC_init_lib_bounds();
             lib_bounds_set = TRUE;
           }
-          if ((caller >= GC_libpthread_start && caller < GC_libpthread_end)
-              || (caller >= GC_libld_start && caller < GC_libld_end))
+          if (((word)caller >= (word)GC_libpthread_start
+               && (word)caller < (word)GC_libpthread_end)
+              || ((word)caller >= (word)GC_libld_start
+                  && (word)caller < (word)GC_libld_end))
             return GC_malloc_uncollectable(n*lb);
           /* The two ranges are actually usually adjacent, so there may */
           /* be a way to speed this up.                                 */
@@ -552,8 +554,10 @@ GC_API void GC_CALL GC_free(void * p)
           ptr_t caller = (ptr_t)__builtin_return_address(0);
           /* This test does not need to ensure memory visibility, since */
           /* the bounds will be set when/if we create another thread.   */
-          if (caller >= GC_libpthread_start && caller < GC_libpthread_end
-              || (caller >= GC_libld_start && caller < GC_libld_end)) {
+          if (((word)caller >= (word)GC_libpthread_start
+               && (word)caller < (word)GC_libpthread_end)
+              || ((word)caller >= (word)GC_libld_start
+                  && (word)caller < (word)GC_libld_end)) {
             GC_free(p);
             return;
           }
diff --git a/mark.c b/mark.c
index 62e3813..1bf9f4e 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -328,8 +328,8 @@ static void alloc_mark_stack(size_t);
             break;
 
         case MS_PUSH_RESCUERS:
-            if (GC_mark_stack_top
-                >= GC_mark_stack_limit - INITIAL_MARK_STACK_SIZE/2) {
+            if ((word)GC_mark_stack_top
+                >= (word)(GC_mark_stack_limit - INITIAL_MARK_STACK_SIZE/2)) {
                 /* Go ahead and mark, even though that might cause us to */
                 /* see more marked dirty objects later on.  Avoid this   */
                 /* in the future.                                        */
@@ -353,8 +353,8 @@ static void alloc_mark_stack(size_t);
             break;
 
         case MS_PUSH_UNCOLLECTABLE:
-            if (GC_mark_stack_top
-                >= GC_mark_stack + GC_mark_stack_size/4) {
+            if ((word)GC_mark_stack_top
+                >= (word)(GC_mark_stack + GC_mark_stack_size/4)) {
 #               ifdef PARALLEL_MARK
                   /* Avoid this, since we don't parallelize the marker  */
                   /* here.                                              */
@@ -386,7 +386,7 @@ static void alloc_mark_stack(size_t);
               /* the allocation lock.                                   */
                 if (GC_parallel) {
                   GC_do_parallel_mark();
-                  GC_ASSERT(GC_mark_stack_top < (mse *)GC_first_nonempty);
+                  GC_ASSERT((word)GC_mark_stack_top < (word)GC_first_nonempty);
                   GC_mark_stack_top = GC_mark_stack - 1;
                   if (GC_mark_stack_too_small) {
                     alloc_mark_stack(2*GC_mark_stack_size);
@@ -398,7 +398,7 @@ static void alloc_mark_stack(size_t);
                   break;
                 }
 #           endif
-            if (GC_mark_stack_top >= GC_mark_stack) {
+            if ((word)GC_mark_stack_top >= (word)GC_mark_stack) {
                 MARK_FROM_MARK_STACK();
                 break;
             } else {
@@ -415,7 +415,7 @@ static void alloc_mark_stack(size_t);
                 GC_mark_state = MS_PUSH_UNCOLLECTABLE;
                 break;
             }
-            if (GC_mark_stack_top >= GC_mark_stack) {
+            if ((word)GC_mark_stack_top >= (word)GC_mark_stack) {
                 MARK_FROM_MARK_STACK();
                 break;
             }
@@ -634,7 +634,7 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
   GC_objects_are_marked = TRUE;
   INIT_HDR_CACHE;
 # ifdef OS2 /* Use untweaked version to circumvent compiler problem */
-    while (mark_stack_top >= mark_stack && credit >= 0)
+    while ((word)mark_stack_top >= (word)mark_stack && credit >= 0)
 # else
     while ((((ptr_t)mark_stack_top - (ptr_t)mark_stack) | credit) >= 0)
 # endif
@@ -658,8 +658,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
           GC_ASSERT(descr < (word)GC_greatest_plausible_heap_addr
                             - (word)GC_least_plausible_heap_addr);
 #         ifdef ENABLE_TRACE
-            if (GC_trace_addr >= current_p
-                && GC_trace_addr < current_p + descr) {
+            if ((word)GC_trace_addr >= (word)current_p
+                && (word)GC_trace_addr < (word)(current_p + descr)) {
               GC_log_printf("GC:%u Large section; start %p len %lu\n",
                         (unsigned)GC_gc_no, current_p, (unsigned long)descr);
             }
@@ -667,7 +667,7 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
 #         ifdef PARALLEL_MARK
 #           define SHARE_BYTES 2048
             if (descr > SHARE_BYTES && GC_parallel
-                && mark_stack_top < mark_stack_limit - 1) {
+                && (word)mark_stack_top < (word)(mark_stack_limit - 1)) {
               int new_size = (descr/2) & ~(sizeof(word)-1);
               mark_stack_top -> mse_start = current_p;
               mark_stack_top -> mse_descr.w = new_size + sizeof(word);
@@ -675,8 +675,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
                                         /* misaligned pointers.         */
               mark_stack_top++;
 #             ifdef ENABLE_TRACE
-                if (GC_trace_addr >= current_p
-                    && GC_trace_addr < current_p + descr) {
+                if ((word)GC_trace_addr >= (word)current_p
+                    && (word)GC_trace_addr < (word)(current_p + descr)) {
                   GC_log_printf("GC:%u Splitting (parallel) %p at %p\n",
                         (unsigned)GC_gc_no, current_p, current_p + new_size);
                 }
@@ -691,8 +691,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
           mark_stack_top -> mse_descr.w =
                                 descr - WORDS_TO_BYTES(SPLIT_RANGE_WORDS-1);
 #         ifdef ENABLE_TRACE
-            if (GC_trace_addr >= current_p
-                && GC_trace_addr < current_p + descr) {
+            if ((word)GC_trace_addr >= (word)current_p
+                && (word)GC_trace_addr < (word)(current_p + descr)) {
               GC_log_printf("GC:%u Splitting %p at %p\n",
                             (unsigned)GC_gc_no, current_p, limit);
             }
@@ -704,8 +704,9 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
         case GC_DS_BITMAP:
           mark_stack_top--;
 #         ifdef ENABLE_TRACE
-            if (GC_trace_addr >= current_p
-                && GC_trace_addr < current_p + WORDS_TO_BYTES(WORDSZ-2)) {
+            if ((word)GC_trace_addr >= (word)current_p
+                && (word)GC_trace_addr < (word)(current_p
+                                                + WORDS_TO_BYTES(WORDSZ-2))) {
               GC_log_printf("GC:%u Tracing from %p bitmap descr %lu\n",
                         (unsigned)GC_gc_no, current_p, (unsigned long)descr);
             }
@@ -716,7 +717,7 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
             if ((signed_word)descr < 0) {
               current = *(word *)current_p;
               FIXUP_POINTER(current);
-              if ((ptr_t)current >= least_ha && (ptr_t)current < greatest_ha) {
+              if (current >= (word)least_ha && current < (word)greatest_ha) {
                 PREFETCH((ptr_t)current);
 #               ifdef ENABLE_TRACE
                   if (GC_trace_addr == current_p) {
@@ -735,7 +736,7 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
         case GC_DS_PROC:
           mark_stack_top--;
 #         ifdef ENABLE_TRACE
-            if (GC_trace_addr >= current_p
+            if ((word)GC_trace_addr >= (word)current_p
                 && GC_base(current_p) != 0
                 && GC_base(current_p) == GC_base(GC_trace_addr)) {
               GC_log_printf("GC:%u Tracing from %p proc descr %lu\n",
@@ -788,8 +789,8 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
       limit = current_p + (word)descr;
     }
 #   ifdef ENABLE_TRACE
-        if (GC_trace_addr >= current_p
-            && GC_trace_addr < limit) {
+        if ((word)GC_trace_addr >= (word)current_p
+            && (word)GC_trace_addr < (word)limit) {
           GC_log_printf("GC:%u Tracing from %p, length is %lu\n",
                         (unsigned)GC_gc_no, current_p, (unsigned long)descr);
         }
@@ -812,36 +813,36 @@ GC_INNER mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack,
         /* for this loop is still not great.                            */
         for(;;) {
           PREFETCH(limit - PREF_DIST*CACHE_LINE_SIZE);
-          GC_ASSERT(limit >= current_p);
+          GC_ASSERT((word)limit >= (word)current_p);
           deferred = *(word *)limit;
           FIXUP_POINTER(deferred);
           limit -= ALIGNMENT;
-          if ((ptr_t)deferred >= least_ha && (ptr_t)deferred <  greatest_ha) {
+          if (deferred >= (word)least_ha && deferred < (word)greatest_ha) {
             PREFETCH((ptr_t)deferred);
             break;
           }
-          if (current_p > limit) goto next_object;
+          if ((word)current_p > (word)limit) goto next_object;
           /* Unroll once, so we don't do too many of the prefetches     */
           /* based on limit.                                            */
           deferred = *(word *)limit;
           FIXUP_POINTER(deferred);
           limit -= ALIGNMENT;
-          if ((ptr_t)deferred >= least_ha && (ptr_t)deferred <  greatest_ha) {
+          if (deferred >= (word)least_ha && deferred < (word)greatest_ha) {
             PREFETCH((ptr_t)deferred);
             break;
           }
-          if (current_p > limit) goto next_object;
+          if ((word)current_p > (word)limit) goto next_object;
         }
 #     endif
 
-      while (current_p <= limit) {
+      while ((word)current_p <= (word)limit) {
         /* Empirically, unrolling this loop doesn't help a lot. */
         /* Since PUSH_CONTENTS expands to a lot of code,        */
         /* we don't.                                            */
         current = *(word *)current_p;
         FIXUP_POINTER(current);
         PREFETCH(current_p + PREF_DIST*CACHE_LINE_SIZE);
-        if ((ptr_t)current >= least_ha && (ptr_t)current <  greatest_ha) {
+        if (current >= (word)least_ha && current < (word)greatest_ha) {
           /* Prefetch the contents of the object we just pushed.  It's  */
           /* likely we will need them soon.                             */
           PREFETCH((ptr_t)current);
@@ -908,8 +909,9 @@ STATIC mse * GC_steal_mark_stack(mse * low, mse * high, mse * local,
     mse *top = local - 1;
     unsigned i = 0;
 
-    GC_ASSERT(high >= low-1 && (word)(high - low + 1) <= GC_mark_stack_size);
-    for (p = low; p <= high && i <= max; ++p) {
+    GC_ASSERT((word)high >= (word)(low - 1)
+              && (word)(high - low + 1) <= GC_mark_stack_size);
+    for (p = low; (word)p <= (word)high && i <= max; ++p) {
         word descr = (word)AO_load(&p->mse_descr.ao);
         if (descr != 0) {
             /* Must be ordered after read of descr: */
@@ -940,12 +942,13 @@ STATIC void GC_return_mark_stack(mse * low, mse * high)
     mse * my_start;
     size_t stack_size;
 
-    if (high < low) return;
+    if ((word)high < (word)low) return;
     stack_size = high - low + 1;
     GC_acquire_mark_lock();
     my_top = GC_mark_stack_top; /* Concurrent modification impossible. */
     my_start = my_top + 1;
-    if (my_start - GC_mark_stack + stack_size > GC_mark_stack_size) {
+    if ((word)(my_start - GC_mark_stack + stack_size)
+                > (word)GC_mark_stack_size) {
       if (GC_print_stats) {
           GC_log_printf("No room to copy back mark stack\n");
       }
@@ -982,17 +985,17 @@ STATIC void GC_do_local_mark(mse *local_mark_stack, mse *local_top)
         for (n = 0; n < N_LOCAL_ITERS; ++n) {
             local_top = GC_mark_from(local_top, local_mark_stack,
                                      local_mark_stack + LOCAL_MARK_STACK_SIZE);
-            if (local_top < local_mark_stack) return;
+            if ((word)local_top < (word)local_mark_stack) return;
             if ((word)(local_top - local_mark_stack)
                         >= LOCAL_MARK_STACK_SIZE / 2) {
                 GC_return_mark_stack(local_mark_stack, local_top);
                 return;
             }
         }
-        if ((mse *)AO_load((volatile AO_t *)(&GC_mark_stack_top))
-            < (mse *)AO_load(&GC_first_nonempty)
+        if ((word)AO_load((volatile AO_t *)&GC_mark_stack_top)
+            < (word)AO_load(&GC_first_nonempty)
             && GC_active_count < GC_helper_count
-            && local_top > local_mark_stack + 1) {
+            && (word)local_top > (word)(local_mark_stack + 1)) {
             /* Try to share the load, since the main stack is empty,    */
             /* and helper threads are waiting for a refill.             */
             /* The entries near the bottom of the stack are likely      */
@@ -1000,8 +1003,8 @@ STATIC void GC_do_local_mark(mse *local_mark_stack, mse *local_top)
             /* it's harder.                                             */
             mse * new_bottom = local_mark_stack
                                 + (local_top - local_mark_stack)/2;
-            GC_ASSERT(new_bottom > local_mark_stack
-                      && new_bottom < local_top);
+            GC_ASSERT((word)new_bottom > (word)local_mark_stack
+                      && (word)new_bottom < (word)local_top);
             GC_return_mark_stack(local_mark_stack, new_bottom - 1);
             memmove(local_mark_stack, new_bottom,
                     (local_top - new_bottom + 1) * sizeof(mse));
@@ -1025,9 +1028,9 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
     GC_acquire_mark_lock();
     GC_active_count++;
     my_first_nonempty = (mse *)AO_load(&GC_first_nonempty);
-    GC_ASSERT((mse *)AO_load(&GC_first_nonempty) >= GC_mark_stack &&
-              (mse *)AO_load(&GC_first_nonempty) <=
-              (mse *)AO_load((volatile AO_t *)(&GC_mark_stack_top)) + 1);
+    GC_ASSERT((word)AO_load(&GC_first_nonempty) >= (word)GC_mark_stack &&
+        (word)AO_load(&GC_first_nonempty) <=
+            (word)AO_load((volatile AO_t *)&GC_mark_stack_top) + sizeof(mse));
     if (GC_print_stats == VERBOSE)
         GC_log_printf("Starting mark helper %lu\n", (unsigned long)id);
     GC_release_mark_lock();
@@ -1038,15 +1041,17 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
         mse * local_top;
         mse * global_first_nonempty = (mse *)AO_load(&GC_first_nonempty);
 
-        GC_ASSERT(my_first_nonempty >= GC_mark_stack &&
-                  my_first_nonempty <=
-                  (mse *)AO_load((volatile AO_t *)(&GC_mark_stack_top))  + 1);
-        GC_ASSERT(global_first_nonempty >= GC_mark_stack &&
-                  global_first_nonempty <=
-                  (mse *)AO_load((volatile AO_t *)(&GC_mark_stack_top))  + 1);
-        if (my_first_nonempty < global_first_nonempty) {
+        GC_ASSERT((word)my_first_nonempty >= (word)GC_mark_stack &&
+                  (word)my_first_nonempty <=
+                        (word)AO_load((volatile AO_t *)&GC_mark_stack_top)
+                        + sizeof(mse));
+        GC_ASSERT((word)global_first_nonempty >= (word)GC_mark_stack &&
+                  (word)global_first_nonempty <=
+                        (word)AO_load((volatile AO_t *)&GC_mark_stack_top)
+                        + sizeof(mse));
+        if ((word)my_first_nonempty < (word)global_first_nonempty) {
             my_first_nonempty = global_first_nonempty;
-        } else if (global_first_nonempty < my_first_nonempty) {
+        } else if ((word)global_first_nonempty < (word)my_first_nonempty) {
             AO_compare_and_swap(&GC_first_nonempty,
                                 (AO_t) global_first_nonempty,
                                 (AO_t) my_first_nonempty);
@@ -1070,15 +1075,16 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
                 /* on the stack.                                */
                 if (0 == GC_active_count) GC_notify_all_marker();
                 while (GC_active_count > 0
-                       && (mse *)AO_load(&GC_first_nonempty)
-                          GC_mark_stack_top) {
+                       && (word)AO_load(&GC_first_nonempty)
+                                > (word)GC_mark_stack_top) {
                     /* We will be notified if either GC_active_count    */
                     /* reaches zero, or if more objects are pushed on   */
                     /* the global mark stack.                           */
                     GC_wait_marker();
                 }
-                if (GC_active_count == 0 &&
-                    (mse *)AO_load(&GC_first_nonempty) > GC_mark_stack_top) {
+                if (GC_active_count == 0
+                    && (word)AO_load(&GC_first_nonempty)
+                        > (word)GC_mark_stack_top) {
                     GC_bool need_to_notify = FALSE;
                     /* The above conditions can't be falsified while we */
                     /* hold the mark lock, since neither                */
@@ -1110,9 +1116,10 @@ STATIC void GC_mark_local(mse *local_mark_stack, int id)
         local_top = GC_steal_mark_stack(my_first_nonempty, my_top,
                                         local_mark_stack, n_to_get,
                                         &my_first_nonempty);
-        GC_ASSERT(my_first_nonempty >= GC_mark_stack &&
-                  my_first_nonempty <=
-                    (mse *)AO_load((volatile AO_t *)(&GC_mark_stack_top)) + 1);
+        GC_ASSERT((word)my_first_nonempty >= (word)GC_mark_stack &&
+                  (word)my_first_nonempty <=
+                        (word)AO_load((volatile AO_t *)&GC_mark_stack_top)
+                        + sizeof(mse));
         GC_do_local_mark(local_mark_stack, local_top);
     }
 }
@@ -1260,10 +1267,10 @@ GC_INNER void GC_push_all(ptr_t bottom, ptr_t top)
 
     bottom = (ptr_t)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
     top = (ptr_t)(((word) top) & ~(ALIGNMENT-1));
-    if (bottom >= top) return;
+    if ((word)bottom >= (word)top) return;
 
     GC_mark_stack_top++;
-    if (GC_mark_stack_top >= GC_mark_stack_limit) {
+    if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
         ABORT("Unexpected mark stack overflow");
     }
     length = top - bottom;
@@ -1292,10 +1299,10 @@ GC_INNER void GC_push_all(ptr_t bottom, ptr_t top)
 
     bottom = (ptr_t)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
     top = (ptr_t)(((word) top) & ~(ALIGNMENT-1));
-    if (bottom >= top) return;
+    if ((word)bottom >= (word)top) return;
 
     h = HBLKPTR(bottom + HBLKSIZE);
-    if (top <= (ptr_t) h) {
+    if ((word)top <= (word)h) {
         if ((*dirty_fn)(h-1)) {
             GC_push_all(bottom, top);
         }
@@ -1305,7 +1312,7 @@ GC_INNER void GC_push_all(ptr_t bottom, ptr_t top)
         GC_push_all(bottom, (ptr_t)h);
     }
 
-    while ((ptr_t)(h+1) <= top) {
+    while ((word)(h+1) <= (word)top) {
         if ((*dirty_fn)(h)) {
             if ((word)(GC_mark_stack_top - GC_mark_stack)
                 > 3 * GC_mark_stack_size / 4) {
@@ -1322,7 +1329,7 @@ GC_INNER void GC_push_all(ptr_t bottom, ptr_t top)
     if ((ptr_t)h != top && (*dirty_fn)(h)) {
        GC_push_all((ptr_t)h, top);
     }
-    if (GC_mark_stack_top >= GC_mark_stack_limit) {
+    if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
         ABORT("Unexpected mark stack overflow");
     }
   }
@@ -1506,7 +1513,8 @@ GC_INNER void GC_push_all_eager(ptr_t bottom, ptr_t top)
     /* check all pointers in range and push if they appear      */
     /* to be valid.                                             */
       lim = t - 1 /* longword */;
-      for (p = b; p <= lim; p = (word *)(((ptr_t)p) + ALIGNMENT)) {
+      for (p = b; (word)p <= (word)lim;
+           p = (word *)(((ptr_t)p) + ALIGNMENT)) {
         q = *p;
         GC_PUSH_ONE_STACK(q, p);
       }
@@ -1582,7 +1590,7 @@ STATIC void GC_push_marked1(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while (p < plim) {
+        while ((word)p < (word)plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
@@ -1630,7 +1638,7 @@ STATIC void GC_push_marked2(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while (p < plim) {
+        while ((word)p < (word)plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
@@ -1678,7 +1686,7 @@ STATIC void GC_push_marked4(struct hblk *h, hdr *hhdr)
     plim = (word *)(((word)h) + HBLKSIZE);
 
     /* go through all words in block */
-        while (p < plim) {
+        while ((word)p < (word)plim) {
             mark_word = *mark_word_addr++;
             q = p;
             while(mark_word != 0) {
@@ -1746,7 +1754,7 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
 #   endif
      default:
       GC_mark_stack_top_reg = GC_mark_stack_top;
-      for (p = h -> hb_body, bit_no = 0; p <= lim;
+      for (p = h -> hb_body, bit_no = 0; (word)p <= (word)lim;
            p += sz, bit_no += MARK_BIT_OFFSET(sz)) {
          if (mark_bit_from_hdr(hhdr, bit_no)) {
            /* Mark from fields inside the object */
@@ -1787,7 +1795,7 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
         lim = (h + 1)->hb_body - sz;
 
     GC_mark_stack_top_reg = GC_mark_stack_top;
-    for (p = h -> hb_body; p <= lim; p += sz)
+    for (p = h -> hb_body; (word)p <= (word)lim; p += sz)
         if ((*(GC_word *)p & 0x3) != 0)
             PUSH_OBJ(p, hhdr, GC_mark_stack_top_reg, mark_stack_limit);
     GC_mark_stack_top = GC_mark_stack_top_reg;
@@ -1804,7 +1812,7 @@ STATIC void GC_push_marked(struct hblk *h, hdr *hhdr)
          return(GC_page_was_dirty(h));
     } else {
          ptr_t p = (ptr_t)h;
-         while (p < (ptr_t)h + sz) {
+         while ((word)p < (word)h + sz) {
              if (GC_page_was_dirty((struct hblk *)p)) return(TRUE);
              p += HBLKSIZE;
          }
index ceba6ae..60f35a5 100644 (file)
@@ -82,13 +82,14 @@ static int n_root_sets = 0;
     int i;
 
     if (last_root_set < n_root_sets
-        && p >= GC_static_roots[last_root_set].r_start
-        && p < GC_static_roots[last_root_set].r_end) return(TRUE);
+        && (word)p >= (word)GC_static_roots[last_root_set].r_start
+        && (word)p < (word)GC_static_roots[last_root_set].r_end)
+      return(TRUE);
     for (i = 0; i < n_root_sets; i++) {
-        if (p >= GC_static_roots[i].r_start
-            && p < GC_static_roots[i].r_end) {
-            last_root_set = i;
-            return(TRUE);
+        if ((word)p >= (word)GC_static_roots[i].r_start
+            && (word)p < (word)GC_static_roots[i].r_end) {
+          last_root_set = i;
+          return(TRUE);
         }
     }
     return(FALSE);
@@ -168,12 +169,12 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)
 {
     struct roots * old;
 
-    GC_ASSERT(b <= e);
+    GC_ASSERT((word)b <= (word)e);
     b = (ptr_t)(((word)b + (sizeof(word) - 1)) & ~(sizeof(word) - 1));
                                         /* round b up to word boundary */
     e = (ptr_t)((word)e & ~(sizeof(word) - 1));
                                         /* round e down to word boundary */
-    if (b >= e) return; /* nothing to do */
+    if ((word)b >= (word)e) return; /* nothing to do */
 
 #   if defined(MSWIN32) || defined(MSWINCE) || defined(CYGWIN32)
       /* Spend the time to ensure that there are no overlapping */
@@ -187,12 +188,13 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)
         old = 0; /* initialized to prevent warning. */
         for (i = 0; i < n_root_sets; i++) {
             old = GC_static_roots + i;
-            if (b <= old -> r_end && e >= old -> r_start) {
-                if (b < old -> r_start) {
+            if ((word)b <= (word)old->r_end
+                 && (word)e >= (word)old->r_start) {
+                if ((word)b < (word)old->r_start) {
                     GC_root_size += old->r_start - b;
                     old -> r_start = b;
                 }
-                if (e > old -> r_end) {
+                if ((word)e > (word)old->r_end) {
                     GC_root_size += e - old->r_end;
                     old -> r_end = e;
                 }
@@ -208,12 +210,13 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)
               other = GC_static_roots + i;
               b = other -> r_start;
               e = other -> r_end;
-              if (b <= old -> r_end && e >= old -> r_start) {
-                if (b < old -> r_start) {
+              if ((word)b <= (word)old->r_end
+                  && (word)e >= (word)old->r_start) {
+                if ((word)b < (word)old->r_start) {
                     GC_root_size += old->r_start - b;
                     old -> r_start = b;
                 }
-                if (e > old -> r_end) {
+                if ((word)e > (word)old->r_end) {
                     GC_root_size += e - old->r_end;
                     old -> r_end = e;
                 }
@@ -231,7 +234,7 @@ void GC_add_roots_inner(ptr_t b, ptr_t e, GC_bool tmp)
 #   else
       old = (struct roots *)GC_roots_present(b);
       if (old != 0) {
-        if (e <= old -> r_end) /* already there */ return;
+        if ((word)e <= (word)old->r_end) /* already there */ return;
         /* else extend */
         GC_root_size += e - old -> r_end;
         old -> r_end = e;
@@ -343,8 +346,8 @@ STATIC void GC_remove_tmp_roots(void)
   {
     int i;
     for (i = 0; i < n_root_sets; ) {
-        if (GC_static_roots[i].r_start >= b
-            && GC_static_roots[i].r_end <= e) {
+        if ((word)GC_static_roots[i].r_start >= (word)b
+            && (word)GC_static_roots[i].r_end <= (word)e) {
             GC_remove_root_at_pos(i);
         } else {
             i++;
@@ -365,12 +368,12 @@ STATIC void GC_remove_tmp_roots(void)
     register int i;
 
     if (last_root_set < n_root_sets
-        && p >= GC_static_roots[last_root_set].r_start
-        && p < GC_static_roots[last_root_set].r_end)
+        && (word)p >= (word)GC_static_roots[last_root_set].r_start
+        && (word)p < (word)GC_static_roots[last_root_set].r_end)
         return GC_static_roots[last_root_set].r_tmp;
     for (i = 0; i < n_root_sets; i++) {
-        if (p >= GC_static_roots[i].r_start
-            && p < GC_static_roots[i].r_end) {
+        if ((word)p >= (word)GC_static_roots[i].r_start
+            && (word)p < (word)GC_static_roots[i].r_end) {
             last_root_set = i;
             return GC_static_roots[i].r_tmp;
         }
@@ -437,7 +440,7 @@ GC_INNER void GC_exclude_static_roots_inner(void *start, void *finish)
     size_t next_index, i;
 
     GC_ASSERT((word)start % sizeof(word) == 0);
-    GC_ASSERT(start < finish);
+    GC_ASSERT((word)start < (word)finish);
 
     if (0 == GC_excl_table_entries) {
         next = 0;
@@ -490,13 +493,14 @@ STATIC void GC_push_conditional_with_exclusions(ptr_t bottom, ptr_t top,
     struct exclusion * next;
     ptr_t excl_start;
 
-    while (bottom < top) {
+    while ((word)bottom < (word)top) {
         next = GC_next_exclusion(bottom);
-        if (0 == next || (excl_start = next -> e_start) >= top) {
+        if (0 == next || (word)(excl_start = next -> e_start) >= (word)top) {
             GC_push_conditional(bottom, top, all);
             return;
         }
-        if (excl_start > bottom) GC_push_conditional(bottom, excl_start, all);
+        if ((word)excl_start > (word)bottom)
+          GC_push_conditional(bottom, excl_start, all);
         bottom = next -> e_end;
     }
 }
@@ -508,7 +512,7 @@ STATIC void GC_push_conditional_with_exclusions(ptr_t bottom, ptr_t top,
   {
     while (traced_stack_sect != NULL) {
         ptr_t frame_bs_lo = traced_stack_sect -> backing_store_end;
-        GC_ASSERT(frame_bs_lo <= bs_hi);
+        GC_ASSERT((word)frame_bs_lo <= (word)bs_hi);
         if (eager) {
             GC_push_all_eager(frame_bs_lo, bs_hi);
         } else {
@@ -517,7 +521,7 @@ STATIC void GC_push_conditional_with_exclusions(ptr_t bottom, ptr_t top,
         bs_hi = traced_stack_sect -> saved_backing_store_ptr;
         traced_stack_sect = traced_stack_sect -> prev;
     }
-    GC_ASSERT(bs_lo <= bs_hi);
+    GC_ASSERT((word)bs_lo <= (word)bs_hi);
     if (eager) {
         GC_push_all_eager(bs_lo, bs_hi);
     } else {
@@ -532,7 +536,7 @@ GC_INNER void GC_push_all_stack_sections(ptr_t lo, ptr_t hi,
                         struct GC_traced_stack_sect_s *traced_stack_sect)
 {
     while (traced_stack_sect != NULL) {
-        GC_ASSERT(lo HOTTER_THAN (ptr_t)traced_stack_sect);
+        GC_ASSERT((word)lo HOTTER_THAN (word)traced_stack_sect);
 #       ifdef STACK_GROWS_UP
             GC_push_all_stack((ptr_t)traced_stack_sect, lo);
 #       else /* STACK_GROWS_DOWN */
@@ -542,7 +546,7 @@ GC_INNER void GC_push_all_stack_sections(ptr_t lo, ptr_t hi,
         GC_ASSERT(lo != NULL);
         traced_stack_sect = traced_stack_sect -> prev;
     }
-    GC_ASSERT(!(hi HOTTER_THAN lo));
+    GC_ASSERT(!((word)hi HOTTER_THAN (word)lo));
 #   ifdef STACK_GROWS_UP
         /* We got them backwards! */
         GC_push_all_stack(hi, lo);
@@ -584,7 +588,8 @@ STATIC void GC_push_all_stack_partially_eager(ptr_t bottom, ptr_t top,
         GC_push_all_stack(bottom, top);
         return;
     }
-    GC_ASSERT(bottom <= cold_gc_frame && cold_gc_frame <= top);
+    GC_ASSERT((word)bottom <= (word)cold_gc_frame
+              && (word)cold_gc_frame <= (word)top);
 #   ifdef STACK_GROWS_DOWN
         GC_push_all(cold_gc_frame - sizeof(ptr_t), top);
         GC_push_all_eager(bottom, cold_gc_frame);
@@ -605,10 +610,10 @@ STATIC void GC_push_all_stack_part_eager_sections(ptr_t lo, ptr_t hi,
         ptr_t cold_gc_frame, struct GC_traced_stack_sect_s *traced_stack_sect)
 {
     GC_ASSERT(traced_stack_sect == NULL || cold_gc_frame == NULL ||
-                cold_gc_frame HOTTER_THAN (ptr_t)traced_stack_sect);
+              (word)cold_gc_frame HOTTER_THAN (word)traced_stack_sect);
 
     while (traced_stack_sect != NULL) {
-        GC_ASSERT(lo HOTTER_THAN (ptr_t)traced_stack_sect);
+        GC_ASSERT((word)lo HOTTER_THAN (word)traced_stack_sect);
 #       ifdef STACK_GROWS_UP
             GC_push_all_stack_partially_eager((ptr_t)traced_stack_sect, lo,
                                               cold_gc_frame);
@@ -622,7 +627,7 @@ STATIC void GC_push_all_stack_part_eager_sections(ptr_t lo, ptr_t hi,
         cold_gc_frame = NULL; /* Use at most once.      */
     }
 
-    GC_ASSERT(!(hi HOTTER_THAN lo));
+    GC_ASSERT(!((word)hi HOTTER_THAN (word)lo));
 #   ifdef STACK_GROWS_UP
         /* We got them backwards! */
         GC_push_all_stack_partially_eager(hi, lo, cold_gc_frame);
@@ -673,12 +678,13 @@ STATIC void GC_push_current_stack(ptr_t cold_gc_frame,
               {
                 ptr_t bsp = GC_save_regs_ret_val;
                 ptr_t cold_gc_bs_pointer = bsp - 2048;
-                if (GC_all_interior_pointers &&
-                    cold_gc_bs_pointer > BACKING_STORE_BASE) {
+                if (GC_all_interior_pointers
+                    && (word)cold_gc_bs_pointer > (word)BACKING_STORE_BASE) {
                   /* Adjust cold_gc_bs_pointer if below our innermost   */
                   /* "traced stack section" in backing store.           */
-                  if (GC_traced_stack_sect != NULL && cold_gc_bs_pointer <
-                                GC_traced_stack_sect->backing_store_end)
+                  if (GC_traced_stack_sect != NULL
+                      && (word)cold_gc_bs_pointer
+                          < (word)GC_traced_stack_sect->backing_store_end)
                     cold_gc_bs_pointer =
                                 GC_traced_stack_sect->backing_store_end;
                   GC_push_all_register_sections(BACKING_STORE_BASE,
diff --git a/misc.c b/misc.c
index 68d2fe4..1fece0f 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -278,7 +278,7 @@ GC_INNER void GC_extend_size_map(size_t i)
     word dummy[CLEAR_SIZE];
 
     BZERO(dummy, CLEAR_SIZE*sizeof(word));
-    if ((ptr_t)(dummy) COOLER_THAN limit) {
+    if ((word)(&dummy[0]) COOLER_THAN (word)limit) {
         (void) GC_clear_stack_inner(arg, limit);
     }
     /* Make sure the recursive call is not a tail call, and the bzero   */
@@ -340,13 +340,13 @@ GC_INNER void * GC_clear_stack(void *arg)
     }
     /* Adjust GC_high_water */
         MAKE_COOLER(GC_high_water, WORDS_TO_BYTES(DEGRADE_RATE) + GC_SLOP);
-        if (sp HOTTER_THAN GC_high_water) {
+        if ((word)sp HOTTER_THAN (word)GC_high_water) {
             GC_high_water = sp;
         }
         MAKE_HOTTER(GC_high_water, GC_SLOP);
     limit = GC_min_sp;
     MAKE_HOTTER(limit, SLOP);
-    if (sp COOLER_THAN limit) {
+    if ((word)sp COOLER_THAN (word)limit) {
         limit = (ptr_t)((word)limit & ~0xf);
                         /* Make it sufficiently aligned for assembly    */
                         /* implementations of GC_clear_stack_inner.     */
@@ -356,7 +356,8 @@ GC_INNER void * GC_clear_stack(void *arg)
         /* Restart clearing process, but limit how much clearing we do. */
         GC_min_sp = sp;
         MAKE_HOTTER(GC_min_sp, CLEAR_THRESHOLD/4);
-        if (GC_min_sp HOTTER_THAN GC_high_water) GC_min_sp = GC_high_water;
+        if ((word)GC_min_sp HOTTER_THAN (word)GC_high_water)
+          GC_min_sp = GC_high_water;
         GC_bytes_allocd_at_reset = GC_bytes_allocd;
     }
     return(arg);
@@ -397,10 +398,10 @@ GC_API void * GC_CALL GC_base(void * p)
 
             r -= obj_displ;
             limit = r + sz;
-            if (limit > (ptr_t)(h + 1) && sz <= HBLKSIZE) {
+            if ((word)limit > (word)(h + 1) && sz <= HBLKSIZE) {
                 return(0);
             }
-            if ((ptr_t)p >= limit) return(0);
+            if ((word)p >= (word)limit) return(0);
         }
     return((void *)r);
 }
@@ -971,10 +972,8 @@ GC_API void GC_CALL GC_init(void)
       GC_STATIC_ASSERT((word)(-1) > (word)0);
       /* word should be unsigned */
 #   endif
-#   if !defined(__BORLANDC__) && !defined(__CC_ARM) /* Workaround */
-      GC_STATIC_ASSERT((ptr_t)(word)(-1) > (ptr_t)0);
-      /* Ptr_t comparisons should behave as unsigned comparisons.       */
-#   endif
+    /* We no longer check for ((void*)(-1) > NULL) since all pointers   */
+    /* are explicitly cast to word in every less-greater comparison.    */
     GC_STATIC_ASSERT((signed_word)(-1) < (signed_word)0);
 #   ifndef GC_DISABLE_INCREMENTAL
       if (GC_incremental || 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
@@ -1616,7 +1615,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
     /* Adjust our stack base value (this could happen if        */
     /* GC_get_main_stack_base() is unimplemented or broken for  */
     /* the platform).                                           */
-    if (GC_stackbottom HOTTER_THAN (ptr_t)(&stacksect))
+    if ((word)GC_stackbottom HOTTER_THAN (word)(&stacksect))
       GC_stackbottom = (ptr_t)(&stacksect);
 
     if (GC_blocked_sp == NULL) {
index 1366b13..e2992d4 100644 (file)
@@ -37,7 +37,7 @@
     p[2] = (word)p;
     p[3] = 0;
     p += 4;
-    for (; p < lim; p += 4) {
+    for (; (word)p < (word)lim; p += 4) {
         p[0] = (word)(p-2);
         p[1] = 0;
         p[2] = (word)p;
@@ -57,7 +57,7 @@
     p[2] = 0;
     p[3] = 0;
     p += 4;
-    for (; p < lim; p += 4) {
+    for (; (word)p < (word)lim; p += 4) {
         PREFETCH_FOR_WRITE((ptr_t)(p+64));
         p[0] = (word)(p-4);
         p[1] = 0;
@@ -75,7 +75,7 @@
     p[0] = (word)ofl;
     p[2] = (word)p;
     p += 4;
-    for (; p < lim; p += 4) {
+    for (; (word)p < (word)lim; p += 4) {
         p[0] = (word)(p-2);
         p[2] = (word)p;
     };
@@ -91,7 +91,7 @@
     p[0] = (word)ofl;
     p[4] = (word)p;
     p += 8;
-    for (; p < lim; p += 8) {
+    for (; (word)p < (word)lim; p += 8) {
         PREFETCH_FOR_WRITE((ptr_t)(p+64));
         p[0] = (word)(p-4);
         p[4] = (word)p;
@@ -150,7 +150,7 @@ GC_INNER ptr_t GC_build_fl(struct hblk *h, size_t sz, GC_bool clear,
                             /* Last place for last object to start */
 
   /* make a list of all objects in *h with head as last object */
-    while (p <= last_object) {
+    while ((word)p <= (word)last_object) {
       /* current object's link points to last object */
         obj_link(p) = (ptr_t)prev;
         prev = p;
index b90d9a8..c06728d 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -371,7 +371,7 @@ GC_INNER char * GC_get_maps(void)
 
       if (buf_ptr == NULL) return FALSE;
       if (prot[1] == 'w' && maj_dev == 0) {
-          if (my_end > addr && my_start <= addr) {
+          if ((word)my_end > (word)addr && (word)my_start <= (word)addr) {
             *startp = my_start;
             *endp = my_end;
             return TRUE;
@@ -405,7 +405,7 @@ GC_INNER char * GC_get_maps(void)
           char *p = map_path;
           /* Set p to point just past last slash, if any. */
             while (*p != '\0' && *p != '\n' && *p != ' ' && *p != '\t') ++p;
-            while (*p != '/' && p >= map_path) --p;
+            while (*p != '/' && (word)p >= (word)map_path) --p;
             ++p;
           if (strncmp(nm, p, nm_len) == 0) {
             *startp = my_start;
@@ -499,7 +499,7 @@ GC_INNER char * GC_get_maps(void)
   {
     void *p = ecos_gc_brk;
     ecos_gc_brk += increment;
-    if (ecos_gc_brk > ecos_gc_memory + sizeof(ecos_gc_memory)) {
+    if ((word)ecos_gc_brk > (word)(ecos_gc_memory + sizeof(ecos_gc_memory))) {
       ecos_gc_brk -= increment;
       return NULL;
     }
@@ -564,7 +564,7 @@ GC_INNER char * GC_get_maps(void)
       result = (ptr_t)((word)p & ~(pgsz-1));
       for (;;) {
         result += pgsz;
-        if (result >= bound) {
+        if ((word)result >= (word)bound) {
           result = bound;
           break;
         }
@@ -602,7 +602,7 @@ GC_INNER char * GC_get_maps(void)
     if (sigsetjmp(GC_jmp_buf_openbsd, 1) != 0 || firstpass) {
       firstpass = 0;
       result += pgsz;
-      if (result >= bound) {
+      if ((word)result >= (word)bound) {
         result = bound;
       } else {
         GC_noop1((word)(*result));
@@ -947,13 +947,13 @@ GC_INNER word GC_page_size = 0;
             for (;;) {
                 if (up) {
                     result += MIN_PAGE_SIZE;
-                    if (result >= bound) {
+                    if ((word)result >= (word)bound) {
                       result = bound;
                       break;
                     }
                 } else {
                     result -= MIN_PAGE_SIZE;
-                    if (result <= bound) {
+                    if ((word)result <= (word)bound) {
                       result = bound - MIN_PAGE_SIZE;
                                         /* This is to compensate        */
                                         /* further result increment (we */
@@ -1207,16 +1207,16 @@ GC_INNER word GC_page_size = 0;
 #       ifdef STACK_GROWS_DOWN
           result = GC_find_limit((ptr_t)(&result), TRUE);
 #         ifdef HEURISTIC2_LIMIT
-            if (result > HEURISTIC2_LIMIT
-                && (ptr_t)(&result) < HEURISTIC2_LIMIT) {
+            if ((word)result > (word)HEURISTIC2_LIMIT
+                && (word)(&result) < (word)HEURISTIC2_LIMIT) {
               result = HEURISTIC2_LIMIT;
             }
 #         endif
 #       else
           result = GC_find_limit((ptr_t)(&result), FALSE);
 #         ifdef HEURISTIC2_LIMIT
-            if (result < HEURISTIC2_LIMIT
-                && (ptr_t)(&result) > HEURISTIC2_LIMIT) {
+            if ((word)result < (word)HEURISTIC2_LIMIT
+                && (word)(&result) > (word)HEURISTIC2_LIMIT) {
               result = HEURISTIC2_LIMIT;
             }
 #         endif
@@ -1227,7 +1227,7 @@ GC_INNER word GC_page_size = 0;
           result = (ptr_t)(signed_word)(-sizeof(ptr_t));
 #     endif
 #   endif
-    GC_ASSERT((ptr_t)(&result) HOTTER_THAN result);
+    GC_ASSERT((word)(&result) HOTTER_THAN (word)result);
     return(result);
   }
 # define GET_MAIN_STACKBASE_SPECIAL
@@ -1298,7 +1298,7 @@ GC_INNER word GC_page_size = 0;
     /* pthread_get_stackaddr_np() should return stack bottom (highest   */
     /* stack address plus 1).                                           */
     b->mem_base = pthread_get_stackaddr_np(pthread_self());
-    GC_ASSERT((void *)&dummy HOTTER_THAN b->mem_base);
+    GC_ASSERT((word)(&dummy) HOTTER_THAN (word)b->mem_base);
     return GC_SUCCESS;
   }
 # define HAVE_GET_STACK_BASE
@@ -1354,7 +1354,7 @@ GC_INNER word GC_page_size = 0;
       ABORT("thr_stksegment failed");
     }
     /* s.ss_sp holds the pointer to the stack bottom. */
-    GC_ASSERT((void *)&s HOTTER_THAN s.ss_sp);
+    GC_ASSERT((word)(&s) HOTTER_THAN (word)s.ss_sp);
 
     if (!stackbase_main_self && thr_main() != 0)
       {
@@ -1430,7 +1430,7 @@ GC_INNER word GC_page_size = 0;
     struct GC_stack_base sb;
     if (GC_get_stack_base(&sb) != GC_SUCCESS)
       ABORT("GC_get_stack_base failed");
-    GC_ASSERT((void *)&sb HOTTER_THAN sb.mem_base);
+    GC_ASSERT((word)(&sb) HOTTER_THAN (word)sb.mem_base);
     return (ptr_t)sb.mem_base;
   }
 #endif /* !GET_MAIN_STACKBASE_SPECIAL */
@@ -1706,7 +1706,7 @@ void GC_register_data_segments(void)
     p = (ptr_t)((word)start & ~(GC_page_size - 1));
     for (;;) {
         q = (LPVOID)(p - GC_page_size);
-        if ((ptr_t)q > (ptr_t)p /* underflow */ || q < limit) break;
+        if ((word)q > (word)p /* underflow */ || (word)q < (word)limit) break;
         result = VirtualQuery(q, &buf, sizeof(buf));
         if (result != sizeof(buf) || buf.AllocationBase == 0) break;
         p = (ptr_t)(buf.AllocationBase);
@@ -1825,7 +1825,7 @@ void GC_register_data_segments(void)
 
       if (!GC_no_win32_dlls) return;
       p = base = limit = GC_least_described_address(static_root);
-      while (p < GC_sysinfo.lpMaximumApplicationAddress) {
+      while ((word)p < (word)GC_sysinfo.lpMaximumApplicationAddress) {
         result = VirtualQuery(p, &buf, sizeof(buf));
         if (result != sizeof(buf) || buf.AllocationBase == 0
             || GC_is_heap_base(buf.AllocationBase)) break;
@@ -1841,7 +1841,7 @@ void GC_register_data_segments(void)
                 limit = new_limit;
             }
         }
-        if (p > (LPVOID)new_limit /* overflow */) break;
+        if ((word)p > (word)new_limit /* overflow */) break;
         p = (LPVOID)new_limit;
       }
       if (base != limit) GC_add_roots_inner(base, limit, FALSE);
@@ -1943,7 +1943,7 @@ void GC_register_data_segments(void)
   for (;;) {
     region_end = GC_find_limit_openbsd(region_start, DATAEND);
     GC_add_roots_inner(region_start, region_end, FALSE);
-    if (region_end >= DATAEND)
+    if ((word)region_end >= (word)(DATAEND))
       break;
     region_start = GC_skip_hole_openbsd(region_end, DATAEND);
   }
@@ -1965,7 +1965,7 @@ void GC_register_data_segments(void)
         GC_ASSERT(DATASTART);
         {
           ptr_t p = (ptr_t)sbrk(0);
-          if (DATASTART < p)
+          if ((word)(DATASTART) < (word)p)
             GC_add_roots_inner(DATASTART, p, FALSE);
         }
 #     else
@@ -2368,7 +2368,7 @@ STATIC ptr_t GC_unmap_start(ptr_t start, size_t bytes)
     ptr_t result;
     /* Round start to next page boundary.       */
     result = (ptr_t)((word)(start + GC_page_size - 1) & ~(GC_page_size - 1));
-    if (result + GC_page_size > start + bytes) return 0;
+    if ((word)(result + GC_page_size) > (word)(start + bytes)) return 0;
     return result;
 }
 
@@ -2780,9 +2780,9 @@ STATIC void GC_default_push_other_roots(void)
           while (pages != pages_end) {
             struct hblk * h = (struct hblk *) *pages++;
             struct hblk * h_end = (struct hblk *) ((char *) h + page_size);
-            do
+            do {
               set_pht_entry_from_index(GC_grungy_pages, PHT_HASH(h));
-            while (++h < h_end);
+            } while ((word)(++h) < (word)h_end);
           }
         }
       } while (count == GC_GWW_BUF_LEN);
@@ -3266,9 +3266,10 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
         /* already marked dirty, and hence unprotected. */
         return;
     }
-    for (current = h_trunc; current < h_end; ++current) {
+    for (current = h_trunc; (word)current < (word)h_end; ++current) {
         size_t index = PHT_HASH(current);
-        if (!is_ptrfree || current < h || current >= h + nblocks) {
+        if (!is_ptrfree || (word)current < (word)h
+            || (word)current >= (word)(h + nblocks)) {
             async_set_pht_entry_from_index(GC_dirty_pages, index);
         }
     }
@@ -3398,7 +3399,7 @@ STATIC void GC_protect_heap(void)
           GC_ASSERT(PAGE_ALIGNED(start));
           current_start = current = (struct hblk *)start;
           limit = (struct hblk *)(start + len);
-          while (current < limit) {
+          while ((word)current < (word)limit) {
             hdr * hhdr;
             word nhblks;
             GC_bool is_ptrfree;
@@ -3423,7 +3424,7 @@ STATIC void GC_protect_heap(void)
               is_ptrfree = IS_PTRFREE(hhdr);
             }
             if (is_ptrfree) {
-              if (current_start < current) {
+              if ((word)current_start < (word)current) {
                 PROTECT(current_start, (ptr_t)current - (ptr_t)current_start);
               }
               current_start = (current += nhblks);
@@ -3431,7 +3432,7 @@ STATIC void GC_protect_heap(void)
               current += nhblks;
             }
           }
-          if (current_start < current) {
+          if ((word)current_start < (word)current) {
             PROTECT(current_start, (ptr_t)current - (ptr_t)current_start);
           }
         }
@@ -3512,7 +3513,7 @@ void GC_unprotect_range(ptr_t addr, word len)
     start_block = (struct hblk *)((word)addr & ~(GC_page_size - 1));
     end_block = (struct hblk *)((word)(addr + len - 1) & ~(GC_page_size - 1));
     end_block += GC_page_size/HBLKSIZE - 1;
-    for (h = start_block; h <= end_block; h++) {
+    for (h = start_block; (word)h <= (word)end_block; h++) {
         register word index = PHT_HASH(h);
 
         async_set_pht_entry_from_index(GC_dirty_pages, index);
@@ -3700,7 +3701,6 @@ GC_INNER void GC_read_dirty(void)
 #   ifdef DEBUG_DIRTY_BITS
       GC_log_printf("Proc VDB read: pr_nmap= %u, pr_npage= %lu\n",
                     nmaps, ((struct prpageheader *)bufp)->pr_npage);
-
 #   endif
     bufp += sizeof(struct prpageheader);
     for (i = 0; i < nmaps; i++) {
@@ -3716,14 +3716,15 @@ GC_INNER void GC_read_dirty(void)
 
         bufp += sizeof(struct prasmap);
         limit = vaddr + pagesize * npages;
-        for (; vaddr < limit; vaddr += pagesize) {
+        for (; (word)vaddr < (word)limit; vaddr += pagesize) {
             if ((*bufp++) & PG_MODIFIED) {
                 register struct hblk * h;
                 ptr_t next_vaddr = vaddr + pagesize;
 #               ifdef DEBUG_DIRTY_BITS
                   GC_log_printf("dirty page at: %p\n", vaddr);
 #               endif
-                for (h = (struct hblk *)vaddr; (ptr_t)h < next_vaddr; h++) {
+                for (h = (struct hblk *)vaddr;
+                     (word)h < (word)next_vaddr; h++) {
                     register word index = PHT_HASH(h);
                     set_pht_entry_from_index(GC_grungy_pages, index);
                 }
@@ -3789,8 +3790,9 @@ GC_INNER void GC_read_dirty(void)
 
 GC_INNER GC_bool GC_page_was_dirty(struct hblk *h)
 {
-    if((ptr_t)h < GC_vd_base || (ptr_t)h >= GC_vd_base + NPAGES*HBLKSIZE) {
-        return(TRUE);
+    if ((word)h < (word)GC_vd_base
+        || (word)h >= (word)(GC_vd_base + NPAGES*HBLKSIZE)) {
+      return(TRUE);
     }
     return(GC_grungy_bits[h - (struct hblk *)GC_vd_base] & PCR_VD_DB_dirtyBit);
 }
@@ -4564,8 +4566,9 @@ GC_INNER void GC_save_callers(struct callinfo info[NFRAMES])
     fp = (struct frame *)((long) frame -> FR_SAVFP + BIAS);
 #endif
 
-   for (; (!(fp HOTTER_THAN frame) && !(GC_stackbottom HOTTER_THAN (ptr_t)fp)
-           && (nframes < NFRAMES));
+   for (; !((word)fp HOTTER_THAN (word)frame)
+          && !((word)GC_stackbottom HOTTER_THAN (word)fp)
+          && nframes < NFRAMES;
        fp = (struct frame *)((long) fp -> FR_SAVFP + BIAS), nframes++) {
       register int i;
 
@@ -4703,7 +4706,8 @@ GC_INNER void GC_print_callers(struct callinfo info[NFRAMES])
                 /* Get rid of embedded newline, if any.  Test for "main" */
                 {
                    char * nl = strchr(result_buf, '\n');
-                   if (nl != NULL && nl < result_buf + result_len) {
+                   if (nl != NULL
+                       && (word)nl < (word)(result_buf + result_len)) {
                      *nl = ':';
                    }
                    if (strncmp(result_buf, "main", nl - result_buf) == 0) {
index a359b2d..c6c868c 100644 (file)
@@ -41,7 +41,7 @@ void * GC_DebugAllocProc(size_t size, PCR_Bool ptrFree, PCR_Bool clear )
 {
     if (ptrFree) {
         void * result = (void *)GC_debug_malloc_atomic(size, __FILE__,
-                                                            __LINE__);
+                                                             __LINE__);
         if (clear && result != 0) BZERO(result, size);
         return(result);
     } else {
@@ -79,7 +79,7 @@ void GC_enumerate_block(struct hblk *h; enumerate_data * ed)
     descr = hhdr -> hb_descr;
     sz = hhdr -> hb_sz;
     if (descr != 0 && ed -> ed_pointerfree
-       || descr == 0 && !(ed -> ed_pointerfree)) return;
+        || descr == 0 && !(ed -> ed_pointerfree)) return;
     lim = (ptr_t)(h+1) - sz;
     p = (ptr_t)h;
     do {
@@ -87,7 +87,7 @@ void GC_enumerate_block(struct hblk *h; enumerate_data * ed)
         ed -> ed_fail_code =
             (*(ed -> ed_proc))(p, sz, ed -> ed_client_data);
         p+= sz;
-    } while (p <= lim);
+    } while ((word)p <= (word)lim);
 }
 
 struct PCR_MM_ProcsRep * GC_old_allocator = 0;
@@ -108,8 +108,8 @@ PCR_ERes GC_EnumerateProc(
     if (ed.ed_fail_code != PCR_ERes_okay) {
         return(ed.ed_fail_code);
     } else {
-       /* Also enumerate objects allocated by my predecessors */
-       return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data));
+        /* Also enumerate objects allocated by my predecessors */
+        return((*(GC_old_allocator->mmp_enumerate))(ptrFree, proc, data));
     }
 }
 
@@ -118,23 +118,23 @@ void GC_DummyFreeProc(void *p) {}
 void GC_DummyShutdownProc(void) {}
 
 struct PCR_MM_ProcsRep GC_Rep = {
-       MY_MAGIC,
-       GC_AllocProc,
-       GC_ReallocProc,
-       GC_DummyFreeProc,       /* mmp_free */
-       GC_FreeProc,            /* mmp_unsafeFree */
-       GC_EnumerateProc,
-       GC_DummyShutdownProc    /* mmp_shutdown */
+        MY_MAGIC,
+        GC_AllocProc,
+        GC_ReallocProc,
+        GC_DummyFreeProc,       /* mmp_free */
+        GC_FreeProc,            /* mmp_unsafeFree */
+        GC_EnumerateProc,
+        GC_DummyShutdownProc    /* mmp_shutdown */
 };
 
 struct PCR_MM_ProcsRep GC_DebugRep = {
-       MY_DEBUGMAGIC,
-       GC_DebugAllocProc,
-       GC_DebugReallocProc,
-       GC_DummyFreeProc,       /* mmp_free */
-       GC_DebugFreeProc,               /* mmp_unsafeFree */
-       GC_EnumerateProc,
-       GC_DummyShutdownProc    /* mmp_shutdown */
+        MY_DEBUGMAGIC,
+        GC_DebugAllocProc,
+        GC_DebugReallocProc,
+        GC_DummyFreeProc,       /* mmp_free */
+        GC_DebugFreeProc,               /* mmp_unsafeFree */
+        GC_EnumerateProc,
+        GC_DummyShutdownProc    /* mmp_shutdown */
 };
 
 GC_bool GC_use_debug = 0;
@@ -163,9 +163,9 @@ PCR_GC_Run(void)
              * awful hack to test whether VD is implemented ...
              */
             if( PCR_VD_Start( 0, NIL, 0) != PCR_ERes_FromErr(ENOSYS) ) {
-               GC_enable_incremental();
-           }
-       }
+                GC_enable_incremental();
+            }
+        }
     }
     return PCR_ERes_okay;
 }
index 3e62858..272a734 100644 (file)
@@ -628,8 +628,8 @@ GC_INNER unsigned char *GC_check_finalizer_nested(void)
     LOCK();
     me = GC_lookup_thread(pthread_self());
     UNLOCK();
-    return (char *)tsd >= (char *)&me->tlfs
-            && (char *)tsd < (char *)&me->tlfs + sizeof(me->tlfs);
+    return (word)tsd >= (word)(&me->tlfs)
+            && (word)tsd < (word)(&me->tlfs) + sizeof(me->tlfs);
   }
 #endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */
 
@@ -700,9 +700,12 @@ STATIC void GC_remove_all_threads_but_me(void)
     GC_ASSERT(I_HOLD_LOCK());
 #   ifdef PARALLEL_MARK
       for (i = 0; i < GC_markers_m1; ++i) {
-        if (marker_sp[i] > lo && marker_sp[i] < hi) return TRUE;
+        if ((word)marker_sp[i] > (word)lo && (word)marker_sp[i] < (word)hi)
+          return TRUE;
 #       ifdef IA64
-          if (marker_bsp[i] > lo && marker_bsp[i] < hi) return TRUE;
+          if ((word)marker_bsp[i] > (word)lo
+              && (word)marker_bsp[i] < (word)hi)
+            return TRUE;
 #       endif
       }
 #   endif
@@ -710,9 +713,13 @@ STATIC void GC_remove_all_threads_but_me(void)
       for (p = GC_threads[i]; p != 0; p = p -> next) {
         if (0 != p -> stack_end) {
 #         ifdef STACK_GROWS_UP
-            if (p -> stack_end >= lo && p -> stack_end < hi) return TRUE;
+            if ((word)p->stack_end >= (word)lo
+                && (word)p->stack_end < (word)hi)
+              return TRUE;
 #         else /* STACK_GROWS_DOWN */
-            if (p -> stack_end > lo && p -> stack_end <= hi) return TRUE;
+            if ((word)p->stack_end > (word)lo
+                && (word)p->stack_end <= (word)hi)
+              return TRUE;
 #         endif
         }
       }
@@ -734,13 +741,15 @@ STATIC void GC_remove_all_threads_but_me(void)
     GC_ASSERT(I_HOLD_LOCK());
 #   ifdef PARALLEL_MARK
       for (i = 0; i < GC_markers_m1; ++i) {
-        if (marker_sp[i] > result && marker_sp[i] < bound)
+        if ((word)marker_sp[i] > (word)result
+            && (word)marker_sp[i] < (word)bound)
           result = marker_sp[i];
       }
 #   endif
     for (i = 0; i < THREAD_TABLE_SZ; i++) {
       for (p = GC_threads[i]; p != 0; p = p -> next) {
-        if (p -> stack_end > result && p -> stack_end < bound) {
+        if ((word)p->stack_end > (word)result
+            && (word)p->stack_end < (word)bound) {
           result = p -> stack_end;
         }
       }
@@ -812,7 +821,7 @@ STATIC void GC_remove_all_threads_but_me(void)
   }
 
 #elif defined(GC_DGUX386_THREADS)
-  /* Return the number of processors, or i<= 0 if it can't be determined. */
+  /* Return the number of processors, or i <= 0 if it can't be determined. */
   STATIC int GC_get_nprocs(void)
   {
     int numCpus;
@@ -1220,11 +1229,11 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
     /* GC_get_stack_base() was used which returned GC_SUCCESS). */
     if ((me -> flags & MAIN_THREAD) == 0) {
       GC_ASSERT(me -> stack_end != NULL);
-      if (me -> stack_end HOTTER_THAN (ptr_t)(&stacksect))
+      if ((word)me->stack_end HOTTER_THAN (word)(&stacksect))
         me -> stack_end = (ptr_t)(&stacksect);
     } else {
       /* The original stack. */
-      if (GC_stackbottom HOTTER_THAN (ptr_t)(&stacksect))
+      if ((word)GC_stackbottom HOTTER_THAN (word)(&stacksect))
         GC_stackbottom = (ptr_t)(&stacksect);
     }
 
index a476633..068eb18 100644 (file)
@@ -62,7 +62,8 @@ GC_API void * GC_CALL GC_same_obj(void *p, void *q)
            hhdr = HDR(h);
         }
         limit = (ptr_t)h + hhdr -> hb_sz;
-        if ((ptr_t)p >= limit || (ptr_t)q >= limit || (ptr_t)q < (ptr_t)h ) {
+        if ((word)p >= (word)limit || (word)q >= (word)limit
+            || (word)q < (word)h) {
             goto fail;
         }
         return(p);
@@ -71,7 +72,7 @@ GC_API void * GC_CALL GC_same_obj(void *p, void *q)
     if (sz > MAXOBJBYTES) {
       base = (ptr_t)HBLKPTR(p);
       limit = base + sz;
-      if ((ptr_t)p >= limit) {
+      if ((word)p >= (word)limit) {
         goto fail;
       }
     } else {
@@ -90,7 +91,7 @@ GC_API void * GC_CALL GC_same_obj(void *p, void *q)
     /* If p is not inside a valid object, then either q is      */
     /* also outside any valid object, or it is outside          */
     /* [base, limit).                                           */
-    if ((ptr_t)q >= limit || (ptr_t)q < base) {
+    if ((word)q >= (word)limit || (word)q < (word)base) {
         goto fail;
     }
     return(p);
@@ -138,9 +139,9 @@ GC_API void * GC_CALL GC_is_valid_displacement(void *p)
     sz = hhdr -> hb_sz;
     pdispl = HBLKDISPL(p);
     offset = pdispl % sz;
-    if ((sz > MAXOBJBYTES && (ptr_t)p >= (ptr_t)h + sz)
+    if ((sz > MAXOBJBYTES && (word)p >= (word)h + sz)
         || !GC_valid_offsets[offset]
-        || (ptr_t)p - offset + sz > (ptr_t)(h + 1)) {
+        || (word)p - offset + sz > (word)(h + 1)) {
         goto fail;
     }
     return(p);
@@ -164,11 +165,11 @@ void (GC_CALLBACK *GC_is_visible_print_proc)(void * p) =
    {
         int dummy;
 #       ifdef STACK_GROWS_DOWN
-            if ((ptr_t)p >= (ptr_t)(&dummy) && (ptr_t)p < GC_stackbottom ) {
+            if ((word)p >= (word)(&dummy) && (word)p < (word)GC_stackbottom) {
                 return(TRUE);
             }
 #       else
-            if ((ptr_t)p <= (ptr_t)(&dummy) && (ptr_t)p > GC_stackbottom ) {
+            if ((word)p <= (word)(&dummy) && (word)p > (word)GC_stackbottom) {
                 return(TRUE);
             }
 #       endif
@@ -223,12 +224,11 @@ GC_API void * GC_CALL GC_is_visible(void *p)
     retry:
             switch(descr & GC_DS_TAGS) {
                 case GC_DS_LENGTH:
-                    if ((word)((ptr_t)p - (ptr_t)base) > (word)descr) goto fail;
+                    if ((word)p - (word)base > descr) goto fail;
                     break;
                 case GC_DS_BITMAP:
-                    if ((word)((ptr_t)p - (ptr_t)base)
-                         >= WORDS_TO_BYTES(BITMAP_BITS)
-                         || ((word)p & (sizeof(word) - 1))) goto fail;
+                    if ((word)p - (word)base >= WORDS_TO_BYTES(BITMAP_BITS)
+                        || ((word)p & (sizeof(word) - 1))) goto fail;
                     if (!(((word)1 << (WORDSZ - ((ptr_t)p - (ptr_t)base) - 1))
                           & descr)) goto fail;
                     break;
@@ -242,8 +242,8 @@ GC_API void * GC_CALL GC_is_visible(void *p)
                     } else {
                       ptr_t type_descr = *(ptr_t *)base;
                       descr = *(word *)(type_descr
-                              - (descr - (word)(GC_DS_PER_OBJECT
-                                          - GC_INDIR_PER_OBJ_BIAS)));
+                                        - (descr - (word)(GC_DS_PER_OBJECT
+                                           - GC_INDIR_PER_OBJ_BIAS)));
                     }
                     goto retry;
             }
index dee0d56..074bd43 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -155,8 +155,8 @@ STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
     plim = (word *)(hbp->hb_body + HBLKSIZE - sz);
 
     /* go through all words in block */
-        while (p <= plim) {
-            if( mark_bit_from_hdr(hhdr, bit_no) ) {
+        while ((word)p <= (word)plim) {
+            if (mark_bit_from_hdr(hhdr, bit_no)) {
                 p = (word *)((ptr_t)p + sz);
             } else {
                 n_bytes_found += sz;
@@ -170,13 +170,13 @@ STATIC ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
                                 && !((word)p & (2 * sizeof(word) - 1)));
                       p[1] = 0;
                       p += 2;
-                      while (p < q) {
+                      while ((word)p < (word)q) {
                         CLEAR_DOUBLE(p);
                         p += 2;
                       }
 #                   else
                       p++; /* Skip link field */
-                      while (p < q) {
+                      while ((word)p < (word)q) {
                         *p++ = 0;
                       }
 #                   endif
@@ -200,8 +200,8 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
     plim = (word *)((ptr_t)hbp + HBLKSIZE - sz);
 
     /* go through all words in block */
-        while (p <= plim) {
-            if( !mark_bit_from_hdr(hhdr, bit_no) ) {
+        while ((word)p <= (word)plim) {
+            if (!mark_bit_from_hdr(hhdr, bit_no)) {
                 n_bytes_found += sz;
                 /* object is available - put on list */
                     obj_link(p) = list;
@@ -230,7 +230,7 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
     p = (word *)(hbp -> hb_body);
     plim = (word *)((ptr_t)p + HBLKSIZE - sz);
 
-    while (p <= plim) {
+    while ((word)p <= (word)plim) {
         int marked = mark_bit_from_hdr(hhdr, bit_no);
         if (!marked && (*disclaim)(p)) {
             hhdr -> hb_n_marks++;
@@ -250,13 +250,13 @@ STATIC ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
                       GC_ASSERT(((word)p & (2 * sizeof(word) - 1)) == 0);
                       p[1] = 0;
                       p += 2;
-                      while (p < q) {
+                      while ((word)p < (word)q) {
                         CLEAR_DOUBLE(p);
                         p += 2;
                       }
 #                   else
                       p++; /* Skip link field */
-                      while (p < q) {
+                      while ((word)p < (word)q) {
                         *p++ = 0;
                       }
 #                   endif
@@ -278,7 +278,8 @@ STATIC void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
     /* go through all words in block */
     p = hbp->hb_body;
     plim = p + HBLKSIZE - sz;
-    for (bit_no = 0; p <= plim; p += sz, bit_no += MARK_BIT_OFFSET(sz)) {
+    for (bit_no = 0; (word)p <= (word)plim;
+         p += sz, bit_no += MARK_BIT_OFFSET(sz)) {
       if (!mark_bit_from_hdr(hhdr, bit_no)) {
         GC_add_leaked(p);
       }
@@ -624,7 +625,8 @@ GC_INNER void GC_start_reclaim(GC_bool report_if_found)
         if (rlist == 0) continue;       /* This kind not used.  */
         if (!report_if_found) {
             lim = &(GC_obj_kinds[kind].ok_freelist[MAXOBJGRANULES+1]);
-            for( fop = GC_obj_kinds[kind].ok_freelist; fop < lim; fop++ ) {
+            for (fop = GC_obj_kinds[kind].ok_freelist;
+                 (word)fop < (word)lim; fop++) {
               if (*fop != 0) {
                 if (should_clobber) {
                   GC_clear_fl_links(fop);
index 3655789..bc33ab9 100644 (file)
@@ -45,7 +45,7 @@
 #   include <winbase.h>
 /* #   define assert ASSERT */
 # else
-#   include <assert.h>        /* Not normally used, but handy for debugging. */
+#   include <assert.h>  /* Not normally used, but handy for debugging.  */
 # endif
 
 # include "gc_typed.h"
@@ -202,7 +202,7 @@ sexpr cons (sexpr x, sexpr y)
     r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra);
     CHECK_OUT_OF_MEMORY(r);
     for (p = (int *)r;
-         ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
+         (word)p < (word)r + my_extra + sizeof(struct SEXPR); p++) {
         if (*p) {
             GC_printf("Found nonzero at %p - allocator is broken\n",
                       (void *)p);
index 7a1e285..fc54844 100644 (file)
@@ -76,7 +76,7 @@ int main(void)
     static int y = 0;
 
     printf("This appears to be a %s running %s\n", MACH_TYPE, OS_TYPE);
-    if (nested_sp() < &dummy) {
+    if ((word)nested_sp() < (word)(&dummy)) {
       printf("Stack appears to grow down, which is the default.\n");
       printf("A good guess for STACKBOTTOM on this machine is 0x%lx.\n",
              ((unsigned long)(&dummy) + ps) & ~(ps-1));
index 36d1e61..9a22304 100644 (file)
@@ -395,7 +395,7 @@ STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
         if (bm & 1) {
             current = *current_p;
             FIXUP_POINTER(current);
-            if ((ptr_t)current >= least_ha && (ptr_t)current <= greatest_ha) {
+            if (current >= (word)least_ha && current <= (word)greatest_ha) {
                 PUSH_CONTENTS((ptr_t)current, mark_stack_ptr,
                               mark_stack_limit, (ptr_t)current_p, exit1);
             }
@@ -407,7 +407,7 @@ STATIC mse * GC_typed_mark_proc(word * addr, mse * mark_stack_ptr,
         /* we also can't overflow the mark stack unless we actually     */
         /* mark something.                                              */
         mark_stack_ptr++;
-        if (mark_stack_ptr >= mark_stack_limit) {
+        if ((word)mark_stack_ptr >= (word)mark_stack_limit) {
             mark_stack_ptr = GC_signal_mark_stack_overflow(mark_stack_ptr);
         }
         mark_stack_ptr -> mse_start = (ptr_t)(addr + WORDSZ);
index 652191d..0fd65a5 100644 (file)
@@ -587,8 +587,8 @@ GC_INNER unsigned char *GC_check_finalizer_nested(void)
     LOCK();
     me = GC_lookup_thread_inner(GetCurrentThreadId());
     UNLOCK();
-    return (char *)tsd >= (char *)&me->tlfs
-            && (char *)tsd < (char *)&me->tlfs + sizeof(me->tlfs);
+    return (word)tsd >= (word)(&me->tlfs)
+            && (word)tsd < (word)(&me->tlfs) + sizeof(me->tlfs);
   }
 #endif /* GC_ASSERTIONS && THREAD_LOCAL_ALLOC */
 
@@ -884,7 +884,7 @@ GC_API void * GC_CALL GC_call_with_gc_active(GC_fn_type fn,
   /* Adjust our stack base value (this could happen unless      */
   /* GC_get_stack_base() was used which returned GC_SUCCESS).   */
   GC_ASSERT(me -> stack_base != NULL);
-  if (me -> stack_base < (ptr_t)(&stacksect))
+  if ((word)me->stack_base < (word)(&stacksect))
     me -> stack_base = (ptr_t)(&stacksect);
 
   if (me -> thread_blocked_sp == NULL) {
@@ -1411,21 +1411,23 @@ STATIC word GC_push_stack_for(GC_thread thread, DWORD me)
     /* First, adjust the latest known minimum stack address if we       */
     /* are inside GC_call_with_gc_active().                             */
     if (traced_stack_sect != NULL &&
-        thread -> last_stack_min > (ptr_t)traced_stack_sect) {
+        (word)thread->last_stack_min > (word)traced_stack_sect) {
       UNPROTECT_THREAD(thread);
       thread -> last_stack_min = (ptr_t)traced_stack_sect;
     }
 
-    if (sp < thread -> stack_base && sp >= thread -> last_stack_min) {
+    if ((word)sp < (word)thread->stack_base
+        && (word)sp >= (word)thread->last_stack_min) {
       stack_min = sp;
     } else {
       /* In the current thread it is always safe to use sp value.       */
       if (may_be_in_stack(thread -> id == me &&
-                          sp < thread -> last_stack_min ?
+                          (word)sp < (word)thread->last_stack_min ?
                           sp : thread -> last_stack_min)) {
         stack_min = last_info.BaseAddress;
         /* Do not probe rest of the stack if sp is correct. */
-        if (sp < stack_min || sp >= thread->stack_base)
+        if ((word)sp < (word)stack_min
+            || (word)sp >= (word)thread->stack_base)
           stack_min = GC_get_stack_min(thread -> last_stack_min);
       } else {
         /* Stack shrunk?  Is this possible? */
@@ -1438,10 +1440,12 @@ STATIC word GC_push_stack_for(GC_thread thread, DWORD me)
 
   GC_ASSERT(GC_dont_query_stack_min
             || stack_min == GC_get_stack_min(thread -> stack_base)
-            || (sp >= stack_min && stack_min < thread -> stack_base
-                && stack_min > GC_get_stack_min(thread -> stack_base)));
+            || ((word)sp >= (word)stack_min
+                && (word)stack_min < (word)thread->stack_base
+                && (word)stack_min
+                        > (word)GC_get_stack_min(thread -> stack_base)));
 
-  if (sp >= stack_min && sp < thread->stack_base) {
+  if ((word)sp >= (word)stack_min && (word)sp < (word)thread->stack_base) {
 #   ifdef DEBUG_THREADS
       GC_log_printf("Pushing stack for 0x%x from sp %p to %p from 0x%x\n",
                     (int)thread -> id, sp, thread -> stack_base, (int)me);
@@ -1451,8 +1455,8 @@ STATIC word GC_push_stack_for(GC_thread thread, DWORD me)
     /* If not current thread then it is possible for sp to point to     */
     /* the guarded (untouched yet) page just below the current          */
     /* stack_min of the thread.                                         */
-    if (thread -> id == me || sp >= thread->stack_base
-        || sp + GC_page_size < stack_min)
+    if (thread -> id == me || (word)sp >= (word)thread->stack_base
+        || (word)(sp + GC_page_size) < (word)stack_min)
       WARN("Thread stack pointer %p out of range, pushing everything\n",
            sp);
 #   ifdef DEBUG_THREADS
@@ -1559,7 +1563,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
     for (i = 0; i <= my_max; i++) {
       ptr_t s = (ptr_t)(dll_thread_table[i].stack_base);
 
-      if (s > start && s < current_min) {
+      if ((word)s > (word)start && (word)s < (word)current_min) {
         /* Update address of last_stack_min. */
         plast_stack_min = (ptr_t * /* no volatile */)
                             &dll_thread_table[i].last_stack_min;
@@ -1573,7 +1577,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
       for (t = GC_threads[i]; t != 0; t = t -> tm.next) {
         ptr_t s = t -> stack_base;
 
-        if (s > start && s < current_min) {
+        if ((word)s > (word)start && (word)s < (word)current_min) {
           /* Update address of last_stack_min. */
           plast_stack_min = &t -> last_stack_min;
           thread = t; /* Remember current thread to unprotect. */
@@ -1587,7 +1591,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
 #       ifdef IA64
           /* FIXME: not implemented */
 #       endif
-        if (s > start && s < current_min) {
+        if ((word)s > (word)start && (word)s < (word)current_min) {
           GC_ASSERT(marker_last_stack_min[i] != NULL);
           plast_stack_min = &marker_last_stack_min[i];
           current_min = s;
@@ -1603,7 +1607,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
       return;
   }
 
-  GC_ASSERT(current_min > start && plast_stack_min != NULL);
+  GC_ASSERT((word)current_min > (word)start && plast_stack_min != NULL);
 # ifdef MSWINCE
     if (GC_dont_query_stack_min) {
       *lo = GC_wince_evaluate_stack_min(current_min);
@@ -1612,7 +1616,7 @@ GC_INNER void GC_get_next_stack(char *start, char *limit,
     }
 # endif
 
-  if (current_min > limit && !may_be_in_stack(limit)) {
+  if ((word)current_min > (word)limit && !may_be_in_stack(limit)) {
     /* Skip the rest since the memory region at limit address is        */
     /* not a stack (so the lowest address of the found stack would      */
     /* be above the limit value anyway).                                */