]> granicus.if.org Git - gc/commitdiff
2007-06-06 Hans Boehm <Hans.Boehm@hp.com>
authorhboehm <hboehm>
Thu, 7 Jun 2007 02:53:32 +0000 (02:53 +0000)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 26 Jul 2011 17:06:40 +0000 (21:06 +0400)
* Makefile.am, Makefile.direct: Add NT_X64_STATIC_THREADS_MAKEFILE.
* Makefile.in: Regenerate.
* NT_X64_STATIC_THREADS_MAKEFILE: Fix warning flags.
* allochblk.c, alloc.c, blacklst.c, dbg_malc.c, dyn_load.c,
finalize.c, headers.c, mach_dep.c, malloc.c, mark.c, misc.c,
obj_map.c, os_dep.c, ptr_chck.c, reclaim.c, typd_mlc.c,
win32_threads.c, cord/de_win.c, include/gc_mark.h,
include/private/gc_hdrs.h, include/private/gc_pmark.h,
include/private/gc_priv.h, tests/test_cpp.cc:
Replace old style function declarations.  Clean up integral types.
Remove register declarations.  The change in malloc.c and the
"int descr" declaration in mark.c are the most likely to have
been real bugs outside of win64.
* msvc_dbg.c: Disable on win64.
* win32_threads.c: Add AMD64 support.
* include/gc.h: no backtrace on AMD64 for now.

30 files changed:
ChangeLog
Makefile.am
Makefile.direct
Makefile.in
NT_X64_STATIC_THREADS_MAKEFILE
allchblk.c
alloc.c
blacklst.c
cord/de_win.c
dbg_mlc.c
dyn_load.c
finalize.c
headers.c
include/gc.h
include/gc_mark.h
include/private/gc_hdrs.h
include/private/gc_pmark.h
include/private/gc_priv.h
mach_dep.c
malloc.c
mark.c
misc.c
msvc_dbg.c
obj_map.c
os_dep.c
ptr_chck.c
reclaim.c
tests/test_cpp.cc
typd_mlc.c
win32_threads.c

index a7f68ac0b8097e06e8efdaf6bc6d27d6786787f0..1734f17f01d6910d61b02e745d072bb55a1036b9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2007-06-06  Hans Boehm <Hans.Boehm@hp.com>
+
+       * Makefile.am, Makefile.direct: Add NT_X64_STATIC_THREADS_MAKEFILE.
+       * Makefile.in: Regenerate.
+       * NT_X64_STATIC_THREADS_MAKEFILE: Fix warning flags.
+       * allochblk.c, alloc.c, blacklst.c, dbg_malc.c, dyn_load.c,
+       finalize.c, headers.c, mach_dep.c, malloc.c, mark.c, misc.c,
+       obj_map.c, os_dep.c, ptr_chck.c, reclaim.c, typd_mlc.c,
+       win32_threads.c, cord/de_win.c, include/gc_mark.h,
+       include/private/gc_hdrs.h, include/private/gc_pmark.h,
+       include/private/gc_priv.h, tests/test_cpp.cc:
+       Replace old style function declarations.  Clean up integral types.
+       Remove register declarations.  The change in malloc.c and the
+       "int descr" declaration in mark.c are the most likely to have
+       been real bugs outside of win64.
+       * msvc_dbg.c: Disable on win64.
+       * win32_threads.c: Add AMD64 support.
+       * include/gc.h: no backtrace on AMD64 for now.
+
 2007-06-06  Hans Boehm <Hans.Boehm@hp.com>
 
        * msvc_dbg.c(GetModuleBase): Replace strcat with strcat_s.
index 648e04059f7aa8384ed65d7a6b10c05416b6f265..23ab2602f958e2be1cc2df6adfe9233bde002470 100644 (file)
@@ -167,7 +167,7 @@ EXTRA_DIST += BCC_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE \
     OS2_MAKEFILE PCR-Makefile digimars.mak EMX_MAKEFILE        \
     Makefile.direct Makefile.dj        Makefile.DLLs SMakefile.amiga \
     WCC_MAKEFILE configure_atomic_ops.sh \
-    NT_STATIC_THREADS_MAKEFILE
+    NT_STATIC_THREADS_MAKEFILE NT_X64_STATIC_THREADS_MAKEFILE
 
 # files used by makefiles other than Makefile.am
 #
index e40e06ab060f93fd6ac86e523797af6d8c379f83..778b344a8c77624c7f7bdea8cdfbe3904d6a665b 100644 (file)
@@ -385,7 +385,7 @@ OTHER_MAKEFILES= OS2_MAKEFILE NT_MAKEFILE NT_THREADS_MAKEFILE gc.mak \
                 BCC_MAKEFILE EMX_MAKEFILE WCC_MAKEFILE Makefile.dj \
                 PCR-Makefile SMakefile.amiga Makefile.DLLs \
                 digimars.mak Makefile.direct NT_STATIC_THREADS_MAKEFILE \
-                configure_atomic_ops.sh
+                NT_X64_STATIC_THREADS_MAKEFILE configure_atomic_ops.sh
 #      Makefile and Makefile.direct are copies of each other.
 
 OTHER_FILES= Makefile setjmp_t.c callprocs \
index 70ae6a7a04f98b50da5f0146a80f842fcce42ad4..bcea07c2672690fb97a9eeec1c8d39fe981fbfcb 100644 (file)
@@ -448,10 +448,11 @@ EXTRA_DIST = gc_cpp.cpp README.QUICK BCC_MAKEFILE NT_MAKEFILE \
        NT_THREADS_MAKEFILE OS2_MAKEFILE PCR-Makefile digimars.mak \
        EMX_MAKEFILE Makefile.direct Makefile.dj Makefile.DLLs \
        SMakefile.amiga WCC_MAKEFILE configure_atomic_ops.sh \
-       NT_STATIC_THREADS_MAKEFILE add_gc_prefix.c gcname.c if_mach.c \
-       if_not_there.c hpux_test_and_clear.s gc.mak MacOS.c \
-       MacProjects.sit.hqx mach_dep.c setjmp_t.c threadlibs.c \
-       AmigaOS.c Mac_files/datastart.c Mac_files/dataend.c \
+       NT_STATIC_THREADS_MAKEFILE NT_X64_STATIC_THREADS_MAKEFILE \
+       add_gc_prefix.c gcname.c if_mach.c if_not_there.c \
+       hpux_test_and_clear.s gc.mak MacOS.c MacProjects.sit.hqx \
+       mach_dep.c setjmp_t.c threadlibs.c AmigaOS.c \
+       Mac_files/datastart.c Mac_files/dataend.c \
        Mac_files/MacOS_config.h Mac_files/MacOS_Test_config.h \
        include/private/msvc_dbg.h msvc_dbg.c libatomic_ops-1.2 \
        libtool.m4 cord/cordbscs.c cord/cordtest.c cord/de.c \
index 31ca3dbf402faf8af78fe99d3ff89bbc6a6c9c1c..95c086255e07374dabfeb3da80a926d78420f425 100644 (file)
@@ -24,13 +24,13 @@ OBJS= alloc.obj reclaim.obj allchblk.obj misc.obj mach_dep.obj os_dep.obj mark_r
 all: gctest.exe cord\de.exe test_cpp.exe
 
 .c.obj:
-       $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -D__STDC__ -DGC_NOT_DLL -DGC_WIN32_THREADS -DTHREAD_LOCAL_ALLOC $*.c /Fo$*.obj /wd4107 -D_CRT_SECURE_NO_DEPRECATE
+       $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -D__STDC__ -DGC_NOT_DLL -DGC_WIN32_THREADS -DTHREAD_LOCAL_ALLOC $*.c /Fo$*.obj /wd4701 -D_CRT_SECURE_NO_DEPRECATE
 # Disable "may not be initialized" warnings.  They're too approximate.
 # Disable crt security warnings, since unfortunately they warn about all sorts
 # of safe uses of strncpy.  It would be nice to leave the rest enabled.
 
 .cpp.obj:
-       $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP -DGC_WIN32_THREADS -DTHREAD_LOCAL_ALLOC /Fo$*.obj
+       $(cc) $(cdebug) $(cflags) $(cvarsmt) -Iinclude -I$(AO_INCLUDE_DIR) -DALL_INTERIOR_POINTERS -DGC_NOT_DLL $*.CPP -DGC_WIN32_THREADS -DTHREAD_LOCAL_ALLOC /Fo$*.obj -D_CRT_SECURE_NO_DEPRECATE
 
 $(OBJS) tests\test.obj: include\private\gc_priv.h include\private\gc_hdrs.h include\gc.h include\private\gcconfig.h include\private\gc_locks.h include\private\gc_pmark.h include\gc_mark.h include\private\msvc_dbg.h
 
index 997580ac37ca4432a614c1d3afc0666d20f9d4f5..0cec29d60e2b29cdaed211a74a49700aa511ae4a 100644 (file)
@@ -56,9 +56,7 @@ struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 };
 # ifdef __GNUC__
   __inline__
 # endif
-  static GC_bool GC_enough_large_bytes_left(bytes,n)
-  word bytes;
-  int n;
+  static GC_bool GC_enough_large_bytes_left(word bytes, int n)
   {
     int i;
     for (i = N_HBLK_FLS; i >= n; --i) {
@@ -80,12 +78,11 @@ struct hblk * GC_hblkfreelist[N_HBLK_FLS+1] = { 0 };
 #endif /* USE_MUNMAP */
 
 /* Map a number of blocks to the appropriate large block free list index. */
-int GC_hblk_fl_from_blocks(blocks_needed)
-word blocks_needed;
+int GC_hblk_fl_from_blocks(word blocks_needed)
 {
-    if (blocks_needed <= UNIQUE_THRESHOLD) return blocks_needed;
+    if (blocks_needed <= UNIQUE_THRESHOLD) return (int)blocks_needed;
     if (blocks_needed >= HUGE_THRESHOLD) return N_HBLK_FLS;
-    return (blocks_needed - UNIQUE_THRESHOLD)/FL_COMPRESSION
+    return (int)(blocks_needed - UNIQUE_THRESHOLD)/FL_COMPRESSION
                                        + UNIQUE_THRESHOLD;
     
 }
@@ -120,7 +117,7 @@ void GC_print_hblkfreelist()
       while (h != 0) {
         hhdr = HDR(h);
         sz = hhdr -> hb_sz;
-       GC_printf("\t0x%lx size %lu ", (unsigned long)h, (unsigned long)sz);
+       GC_printf("\t%p size %lu ", h, (unsigned long)sz);
        total_free += sz;
         if (GC_is_black_listed(h, HBLKSIZE) != 0) {
              GC_printf("start black listed\n");
@@ -143,8 +140,7 @@ void GC_print_hblkfreelist()
 
 /* Return the free list index on which the block described by the header */
 /* appears, or -1 if it appears nowhere.                                */
-int free_list_index_of(wanted)
-hdr * wanted;
+int free_list_index_of(hdr *wanted)
 {
     struct hblk * h;
     hdr * hhdr;
@@ -222,15 +218,15 @@ void GC_dump_regions()
 /* kind of objects.                                                    */
 /* Return FALSE on failure.                                            */
 static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz,
-                           int kind, unsigned char flags)
+                           int kind, unsigned flags)
 {
     word descr;
     size_t granules;
     
     /* Set size, kind and mark proc fields */
       hhdr -> hb_sz = byte_sz;
-      hhdr -> hb_obj_kind = kind;
-      hhdr -> hb_flags = flags;
+      hhdr -> hb_obj_kind = (unsigned char)kind;
+      hhdr -> hb_flags = (unsigned char)flags;
       hhdr -> hb_block = block;
       descr = GC_obj_kinds[kind].ok_descriptor;
       if (GC_obj_kinds[kind].ok_relocate_descr) descr += byte_sz;
@@ -257,7 +253,7 @@ static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz,
        hhdr -> hb_inv_sz = inv_sz;
       }
 #   else /* MARK_BIT_PER_GRANULE */
-      hhdr -> hb_large_block = (byte_sz > MAXOBJBYTES);
+      hhdr -> hb_large_block = (unsigned char)(byte_sz > MAXOBJBYTES);
       granules = BYTES_TO_GRANULES(byte_sz);
       if (EXPECT(!GC_add_map_entry(granules), FALSE)) {
         /* Make it look like a valid block. */
@@ -267,7 +263,7 @@ static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz,
         hhdr -> hb_map = 0;
         return FALSE;
       } else {
-        int index = (hhdr -> hb_large_block? 0 : granules);
+        size_t index = (hhdr -> hb_large_block? 0 : granules);
         hhdr -> hb_map = GC_obj_map[index];
       }
 #   endif /* MARK_BIT_PER_GRANULE */
@@ -285,9 +281,7 @@ static GC_bool setup_header(hdr * hhdr, struct hblk *block, size_t byte_sz,
  * We assume it is on the nth free list, or on the size
  * appropriate free list if n is FL_UNKNOWN.
  */
-void GC_remove_from_fl(hhdr, n)
-hdr * hhdr;
-int n;
+void GC_remove_from_fl(hdr *hhdr, int n)
 {
     int index;
 
@@ -328,8 +322,7 @@ int n;
 /*
  * Return a pointer to the free block ending just before h, if any.
  */
-struct hblk * GC_free_block_ending_at(h)
-struct hblk *h;
+struct hblk * GC_free_block_ending_at(struct hblk *h)
 {
     struct hblk * p = h - 1;
     hdr * phdr;
@@ -360,9 +353,7 @@ struct hblk *h;
  * Add hhdr to the appropriate free list.
  * We maintain individual free lists sorted by address.
  */
-void GC_add_to_fl(h, hhdr)
-struct hblk *h;
-hdr * hhdr;
+void GC_add_to_fl(struct hblk *h, hdr *hhdr)
 {
     int index = GC_hblk_fl_from_blocks(divHBLKSZ(hhdr -> hb_sz));
     struct hblk *second = GC_hblkfreelist[index];
@@ -485,11 +476,8 @@ void GC_merge_unmapped(void)
  * The header for the returned block must be set up by the caller.
  * If the return value is not 0, then hhdr is the header for it.
  */
-struct hblk * GC_get_first_part(h, hhdr, bytes, index)
-struct hblk *h;
-hdr * hhdr;
-word bytes;
-int index;
+struct hblk * GC_get_first_part(struct hblk *h, hdr *hhdr,
+                               size_t bytes, int index)
 {
     word total_size = hhdr -> hb_sz;
     struct hblk * rest;
@@ -527,12 +515,8 @@ int index;
  * (Hence adding it to a free list is silly.  But this path is hopefully
  * rare enough that it doesn't matter.  The code is cleaner this way.)
  */
-void GC_split_block(h, hhdr, n, nhdr, index)
-struct hblk *h;
-hdr * hhdr;
-struct hblk *n;
-hdr * nhdr;
-int index;     /* Index of free list */
+void GC_split_block(struct hblk *h, hdr *hhdr, struct hblk *n,
+                   hdr *nhdr, int index /* Index of free list */)
 {
     word total_size = hhdr -> hb_sz;
     word h_size = (word)n - (word)h;
@@ -568,7 +552,7 @@ int index;  /* Index of free list */
 }
        
 struct hblk *
-GC_allochblk_nth(size_t sz/* bytes */, int kind, unsigned char flags, int n);
+GC_allochblk_nth(size_t sz/* bytes */, int kind, unsigned flags, int n);
 
 /*
  * Allocate (and return pointer to) a heap block
@@ -580,7 +564,7 @@ GC_allochblk_nth(size_t sz/* bytes */, int kind, unsigned char flags, int n);
  * The client is responsible for clearing the block, if necessary.
  */
 struct hblk *
-GC_allochblk(size_t sz, int kind, unsigned char flags/* IGNORE_OFF_PAGE or 0 */)
+GC_allochblk(size_t sz, int kind, unsigned flags/* IGNORE_OFF_PAGE or 0 */)
 {
     word blocks;
     int start_list;
@@ -603,7 +587,7 @@ GC_allochblk(size_t sz, int kind, unsigned char flags/* IGNORE_OFF_PAGE or 0 */)
  * Unlike the above, sz is in bytes.
  */
 struct hblk *
-GC_allochblk_nth(size_t sz, int kind, unsigned char flags, int n)
+GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n)
 {
     struct hblk *hbp;
     hdr * hhdr;                /* Header corr. to hbp */
diff --git a/alloc.c b/alloc.c
index 2fdc4587a125e9e0f1cefabe4b322eda06d24686..2c51873ecbc2a99354d9f2284ea163aa4d5f393c 100644 (file)
--- a/alloc.c
+++ b/alloc.c
@@ -213,7 +213,7 @@ void GC_clear_a_few_frames()
 {
 #   define NWORDS 64
     word frames[NWORDS];
-    register int i;
+    int i;
     
     for (i = 0; i < NWORDS; i++) frames[i] = 0;
 }
@@ -517,7 +517,7 @@ void GC_set_fl_marks(ptr_t q)
    struct hblk * h, * last_h = 0;
    hdr *hhdr;  /* gcc "might be uninitialized" warning is bogus. */
    IF_PER_OBJ(size_t sz;)
-   int bit_no;
+   unsigned bit_no;
 
    for (p = q; p != 0; p = obj_link(p)){
        h = HBLKPTR(p);
@@ -558,7 +558,7 @@ void GC_clear_fl_marks(ptr_t q)
    struct hblk * h, * last_h = 0;
    hdr *hhdr;
    size_t sz;
-   int bit_no;
+   unsigned bit_no;
 
    for (p = q; p != 0; p = obj_link(p)){
        h = HBLKPTR(p);
@@ -569,7 +569,7 @@ void GC_clear_fl_marks(ptr_t q)
        }
        bit_no = MARK_BIT_NO((ptr_t)p - (ptr_t)h, sz);
        if (mark_bit_from_hdr(hhdr, bit_no)) {
-         int n_marks = hhdr -> hb_n_marks - 1;
+         size_t n_marks = hhdr -> hb_n_marks - 1;
          clear_mark_bit_from_hdr(hhdr, bit_no);
 #        ifdef PARALLEL_MARK
            /* Appr. count, don't decrement to zero! */
@@ -617,8 +617,8 @@ void GC_finish_collection()
       /* Mark all objects on the free list.  All objects should be */
       /* marked when we're done.                                  */
        {
-         register word size;           /* current object size          */
-         int kind;
+         word size;            /* current object size          */
+         unsigned kind;
          ptr_t q;
 
          for (kind = 0; kind < GC_n_kinds; kind++) {
@@ -658,9 +658,9 @@ void GC_finish_collection()
     /* Thus accidentally marking a free list is not a problem;  only     */
     /* objects on the list itself will be marked, and that's fixed here. */
       {
-       register word size;             /* current object size          */
-       register ptr_t q;       /* pointer to current object    */
-       int kind;
+       word size;              /* current object size          */
+       ptr_t q;        /* pointer to current object    */
+       unsigned kind;
 
        for (kind = 0; kind < GC_n_kinds; kind++) {
          for (size = 1; size <= MAXOBJGRANULES; size++) {
@@ -796,7 +796,7 @@ void GC_add_to_heap(struct hblk *p, size_t bytes)
 # if !defined(NO_DEBUGGING)
 void GC_print_heap_sects(void)
 {
-    register unsigned i;
+    unsigned i;
     
     GC_printf("Total heap size: %lu\n", (unsigned long) GC_heapsize);
     for (i = 0; i < GC_n_heap_sects; i++) {
@@ -806,7 +806,7 @@ void GC_print_heap_sects(void)
         unsigned nbl = 0;
         
        GC_printf("Section %d from %p to %p ", i,
-                  start, (unsigned long)(start + len));
+                  start, start + len);
        for (h = (struct hblk *)start; h < (struct hblk *)(start + len); h++) {
            if (GC_is_black_listed(h, HBLKSIZE)) nbl++;
        }
index 9811fb11af15bddad1ba7e1293bccc3a22c620c9..afcad9c216569d0bf946e52ed2c51b68094c782a 100644 (file)
@@ -168,7 +168,7 @@ void GC_unpromote_black_lists(void)
 {
     if (!(GC_modws_valid_offsets[p & (sizeof(word)-1)])) return;
     {
-        register int index = PHT_HASH(p);
+        word index = PHT_HASH((word)p);
         
         if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_normal_bl, index)) {
 #          ifdef PRINT_BLACK_LIST
@@ -194,7 +194,7 @@ void GC_unpromote_black_lists(void)
   void GC_add_to_black_list_stack(word p)
 #endif
 {
-    register int index = PHT_HASH(p);
+    word index = PHT_HASH((word)p);
         
     if (HDR(p) == 0 || get_pht_entry_from_index(GC_old_stack_bl, index)) {
 #      ifdef PRINT_BLACK_LIST
@@ -220,8 +220,8 @@ void GC_unpromote_black_lists(void)
  */
 struct hblk * GC_is_black_listed(struct hblk *h, word len)
 {
-    register int index = PHT_HASH((word)h);
-    register word i;
+    word index = PHT_HASH((word)h);
+    word i;
     word nblocks = divHBLKSZ(len);
 
     if (!GC_all_interior_pointers) {
@@ -259,7 +259,7 @@ word GC_number_stack_black_listed(struct hblk *start, struct hblk *endp1)
     word result = 0;
     
     for (h = start; h < endp1; h++) {
-        register int index = PHT_HASH((word)h);
+        word index = PHT_HASH((word)h);
         
         if (get_pht_entry_from_index(GC_old_stack_bl, index)) result++;
     }
index 64303253df79d1692cb3e0b7cbbe25df07e77c8a..1871736e393b18e9b2886e722b2dca9e60f44a64 100644 (file)
@@ -238,7 +238,7 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
           if (wParam == QUIT) {
               SendMessage( hwnd, WM_CLOSE, 0, 0L );
           } else {
-              do_command(wParam);
+              do_command((int)wParam);
           }
           return(0);
       
@@ -323,13 +323,14 @@ LRESULT CALLBACK WndProc (HWND hwnd, UINT message,
                   SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
                   
                   TextOut(dc, this_line.left, this_line.top,
-                          plain, len);
-                  TextOut(dc, this_line.left + len * char_width, this_line.top,
-                          blanks, COLS - len);
+                          plain, (int)len);
+                  TextOut(dc, this_line.left + (int)len * char_width,
+                          this_line.top,
+                          blanks, (int)(COLS - len));
                   SetBkMode(dc, TRANSPARENT);
                   SetTextColor(dc, RED);
                   TextOut(dc, this_line.left, this_line.top,
-                          control, strlen(control));
+                          control, (int)strlen(control));
               }
           }
           EndPaint(hwnd, &ps);
index d1acddee229f31f28f6d3c0b7120e45d098d5df6..4b72e390acd11ff7255dd5a788a58cc9b2176c4c 100644 (file)
--- a/dbg_mlc.c
+++ b/dbg_mlc.c
@@ -302,8 +302,7 @@ ptr_t GC_store_debug_info_inner(ptr_t p, word sz, char *string, word integer)
 /* Check the object with debugging info at ohdr                */
 /* return NIL if it's OK.  Else return clobbered       */
 /* address.                                            */
-ptr_t GC_check_annotated_obj(ohdr)
-register oh * ohdr;
+ptr_t GC_check_annotated_obj(oh *ohdr)
 {
     register ptr_t body = (ptr_t)(ohdr + 1);
     register word gc_sz = GC_size((ptr_t)ohdr);
@@ -326,17 +325,14 @@ register oh * ohdr;
 
 static GC_describe_type_fn GC_describe_type_fns[MAXOBJKINDS] = {0};
 
-void GC_register_describe_type_fn(kind, fn)
-int kind;
-GC_describe_type_fn fn;
+void GC_register_describe_type_fn(int kind, GC_describe_type_fn fn)
 {
   GC_describe_type_fns[kind] = fn;
 }
 
 /* Print a type description for the object whose client-visible address        */
 /* is p.                                                               */
-void GC_print_type(p)
-ptr_t p;
+void GC_print_type(ptr_t p)
 {
     hdr * hhdr = GC_find_header(p);
     char buffer[GC_TYPE_DESCR_LEN + 1];
@@ -377,8 +373,7 @@ ptr_t p;
 
     
 
-void GC_print_obj(p)
-ptr_t p;
+void GC_print_obj(ptr_t p)
 {
     register oh * ohdr = (oh *)GC_base(p);
     
@@ -609,13 +604,11 @@ void * GC_debug_malloc_stubborn(size_t lb, GC_EXTRA_PARAMS)
     return GC_debug_malloc(lb, OPT_RA s, i);
 }
 
-void GC_debug_change_stubborn(p)
-void * p;
+void GC_debug_change_stubborn(void *p)
 {
 }
 
-void GC_debug_end_stubborn_change(p)
-void * p;
+void GC_debug_end_stubborn_change(void *p)
 {
 }
 
@@ -862,7 +855,7 @@ void GC_check_heap_block(struct hblk *hbp, word dummy)
 {
     struct hblkhdr * hhdr = HDR(hbp);
     size_t sz = hhdr -> hb_sz;
-    int bit_no;
+    size_t bit_no;
     char *p, *plim;
     
     p = hbp->hb_body;
index 50884b6450329392c52095ef7fdfb31ee1b7352c..7094fcafb499ce55b3d2fdb186d437e1a014087e 100644 (file)
@@ -716,7 +716,7 @@ void GC_register_dynamic_libraries()
   void GC_register_dynamic_libraries()
   {
     MEMORY_BASIC_INFORMATION buf;
-    DWORD result;
+    size_t result;
     DWORD protect;
     LPVOID p;
     char * base;
@@ -727,8 +727,8 @@ void GC_register_dynamic_libraries()
 #   endif
     base = limit = p = GC_sysinfo.lpMinimumApplicationAddress;
 #   if defined(MSWINCE) && !defined(_WIN32_WCE_EMULATION)
-    /* Only the first 32 MB of address space belongs to the current process */
-    while (p < (LPVOID)0x02000000) {
+      /* Only the first 32 MB of address space belongs to the current process */
+      while (p < (LPVOID)0x02000000) {
         result = VirtualQuery(p, &buf, sizeof(buf));
        if (result == 0) {
            /* Page is free; advance to the next possible allocation base */
@@ -737,7 +737,7 @@ void GC_register_dynamic_libraries()
                 & ~(GC_sysinfo.dwAllocationGranularity-1));
        } else
 #   else
-    while (p < GC_sysinfo.lpMaximumApplicationAddress) {
+      while (p < GC_sysinfo.lpMaximumApplicationAddress) {
         result = VirtualQuery(p, &buf, sizeof(buf));
 #   endif
        {
index 606b59a4d6a32e82d174b9df009c3728093f7591..85f21a13abc8ebd89a284c46be5a48dfdb751334 100644 (file)
@@ -104,10 +104,10 @@ void GC_grow_table(struct hash_chain_entry ***table,
 {
     register word i;
     register struct hash_chain_entry *p;
-    int log_old_size = *log_size_ptr;
-    register int log_new_size = log_old_size + 1;
+    signed_word log_old_size = *log_size_ptr;
+    signed_word log_new_size = log_old_size + 1;
     word old_size = ((log_old_size == -1)? 0: (1 << log_old_size));
-    register word new_size = 1 << log_new_size;
+    word new_size = (word)1 << log_new_size;
     /* FIXME: Power of 2 size often gets rounded up to one more page. */
     struct hash_chain_entry **new_table = (struct hash_chain_entry **)
        GC_INTERNAL_MALLOC_IGNORE_OFF_PAGE(
@@ -123,9 +123,9 @@ void GC_grow_table(struct hash_chain_entry ***table,
     for (i = 0; i < old_size; i++) {
       p = (*table)[i];
       while (p != 0) {
-        register ptr_t real_key = (ptr_t)REVEAL_POINTER(p -> hidden_key);
-        register struct hash_chain_entry *next = p -> next;
-        register int new_hash = HASH3(real_key, new_size, log_new_size);
+        ptr_t real_key = (ptr_t)REVEAL_POINTER(p -> hidden_key);
+        struct hash_chain_entry *next = p -> next;
+        size_t new_hash = HASH3(real_key, new_size, log_new_size);
         
         p -> next = new_table[new_hash];
         new_table[new_hash] = p;
@@ -149,7 +149,7 @@ int GC_register_disappearing_link(void * * link)
 int GC_general_register_disappearing_link(void * * link, void * obj)
 {
     struct disappearing_link *curr_dl;
-    int index;
+    size_t index;
     struct disappearing_link * new_dl;
     DCL_LOCK_STATE;
     
@@ -209,12 +209,12 @@ int GC_general_register_disappearing_link(void * * link, void * obj)
 int GC_unregister_disappearing_link(void * * link)
 {
     struct disappearing_link *curr_dl, *prev_dl;
-    int index;
+    size_t index;
     DCL_LOCK_STATE;
     
     LOCK();
     index = HASH2(link, log_dl_table_size);
-    if (((unsigned long)link & (ALIGNMENT-1))) goto out;
+    if (((word)link & (ALIGNMENT-1))) goto out;
     prev_dl = 0; curr_dl = dl_head[index];
     while (curr_dl != 0) {
         if (curr_dl -> dl_hidden_link == HIDE_POINTER(link)) {
@@ -287,8 +287,7 @@ GC_API void GC_null_finalize_mark_proc(ptr_t p)
 /* behavior.  Objects registered in this way are not finalized         */
 /* if they are reachable by other finalizable objects, eve if those    */
 /* other objects specify no ordering.                                  */
-GC_API void GC_unreachable_finalize_mark_proc(p)
-ptr_t p;
+GC_API void GC_unreachable_finalize_mark_proc(ptr_t p)
 {
     GC_normal_finalize_mark_proc(p);
 }
@@ -310,7 +309,7 @@ GC_API void GC_register_finalizer_inner(void * obj,
 {
     ptr_t base;
     struct finalizable_object * curr_fo, * prev_fo;
-    int index;
+    size_t index;
     struct finalizable_object *new_fo;
     hdr *hhdr;
     DCL_LOCK_STATE;
@@ -494,7 +493,7 @@ void GC_finalize(void)
     struct disappearing_link * curr_dl, * prev_dl, * next_dl;
     struct finalizable_object * curr_fo, * prev_fo, * next_fo;
     ptr_t real_ptr, real_link;
-    register int i;
+    size_t i;
     int dl_size = (log_dl_table_size == -1 ) ? 0 : (1 << log_dl_table_size);
     int fo_size = (log_fo_table_size == -1 ) ? 0 : (1 << log_fo_table_size);
     
@@ -752,6 +751,7 @@ int GC_invoke_finalizers(void)
 #      endif
        if (count == 0) {
            bytes_freed_before = GC_bytes_freed;
+           /* Don't do this outside, since we need the lock. */
        }
        curr_fo = GC_finalize_now;
 #      ifdef THREADS
@@ -773,6 +773,7 @@ int GC_invoke_finalizers(void)
            GC_free((void *)curr_fo);
 #      endif
     }
+    /* bytes_freed_before is initialized whenever count != 0 */
     if (count != 0 && bytes_freed_before != GC_bytes_freed) {
         LOCK();
        GC_finalizer_bytes_freed += (GC_bytes_freed - bytes_freed_before);
index 1a0ce887796699589bcb4339cde88a3bab58bf68..6b4eb8492272bff139f023747d3d60f081e96b52 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -204,7 +204,7 @@ static GC_bool get_index(word addr)
     bottom_index *pi;
     
 #   ifdef HASH_TL
-      unsigned i = TL_HASH(hi);
+      word i = TL_HASH(hi);
       bottom_index * old;
       
       old = p = GC_top_index[i];
@@ -262,8 +262,8 @@ struct hblkhdr * GC_install_header(struct hblk *h)
 /* Set up forwarding counts for block h of size sz */
 GC_bool GC_install_counts(struct hblk *h, size_t sz/* bytes */)
 {
-    register struct hblk * hbp;
-    register int i;
+    struct hblk * hbp;
+    word i;
     
     for (hbp = h; (char *)hbp < (char *)h + sz; hbp += BOTTOM_SZ) {
         if (!get_index((word) hbp)) return(FALSE);
@@ -301,7 +301,7 @@ void GC_remove_counts(struct hblk *h, size_t sz/* bytes */)
 void GC_apply_to_all_blocks(void (*fn)(struct hblk *h, word client_data),
                            word client_data)
 {
-    int j;
+    signed_word j;
     bottom_index * index_p;
     
     for (index_p = GC_all_bottom_indices; index_p != 0;
@@ -318,7 +318,7 @@ void GC_apply_to_all_blocks(void (*fn)(struct hblk *h, word client_data),
              } else if (index_p->index[j] == 0) {
                 j--;
              } else {
-                j -= (word)(index_p->index[j]);
+                j -= (signed_word)(index_p->index[j]);
              }
          }
      }
index ea11fff509fa9572fd3a0c13beff30fd15b8951b..cc950888f0939f235d33f6de6ce1689cba1a6e2f 100644 (file)
@@ -472,7 +472,8 @@ GC_API void * GC_malloc_atomic_ignore_off_page(size_t lb);
 # endif
 #endif
 
-#if defined(_MSC_VER) && _MSC_VER >= 1200 /* version 12.0+ (MSVC 6.0+)  */
+#if defined(_MSC_VER) && _MSC_VER >= 1200 /* version 12.0+ (MSVC 6.0+)  */ \
+    && !defined(_AMD64_)
 # ifndef GC_HAVE_NO_BUILTIN_BACKTRACE
 #   define GC_HAVE_BUILTIN_BACKTRACE
 # endif
index 79f5a8bf2789a3723995833247f2c84c40f7806d..8ee50b5d4deb8b36afc0ad6016be13fe33a013a3 100644 (file)
@@ -157,18 +157,18 @@ void ** GC_new_free_list(void);
 void ** GC_new_free_list_inner(void);
 
 /* Return a new kind, as specified. */
-int GC_new_kind(void **free_list, GC_word mark_descriptor_template,
+unsigned GC_new_kind(void **free_list, GC_word mark_descriptor_template,
                int add_size_to_descriptor, int clear_new_objects);
                /* The last two parameters must be zero or one. */
-int GC_new_kind_inner(void **free_list,
+unsigned GC_new_kind_inner(void **free_list,
                      GC_word mark_descriptor_template,
                      int add_size_to_descriptor,
                      int clear_new_objects);
 
 /* Return a new mark procedure identifier, suitable for use as */
 /* the first argument in GC_MAKE_PROC.                         */
-int GC_new_proc(GC_mark_proc);
-int GC_new_proc_inner(GC_mark_proc);
+unsigned GC_new_proc(GC_mark_proc);
+unsigned GC_new_proc_inner(GC_mark_proc);
 
 /* Allocate an object of a given kind.  Note that in multithreaded     */
 /* contexts, this is usually unsafe for kinds that have the descriptor */
index 80a29d86b53e994965f351a76a57557d18a51b8d..559556ca78a226409b1d7c8c1c1c1596569b27fa 100644 (file)
@@ -198,9 +198,9 @@ typedef struct bi {
                            
 /* Is the result a forwarding address to someplace closer to the       */
 /* beginning of the block or NIL?                                      */
-# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((unsigned long) (hhdr) <= MAX_JUMP)
+# define IS_FORWARDING_ADDR_OR_NIL(hhdr) ((size_t) (hhdr) <= MAX_JUMP)
 
 /* Get an HBLKSIZE aligned address closer to the beginning of the block */
 /* h.  Assumes hhdr == HDR(h) and IS_FORWARDING_ADDR(hhdr).            */
-# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (unsigned long)(hhdr))
+# define FORWARDED_ADDR(h, hhdr) ((struct hblk *)(h) - (size_t)(hhdr))
 # endif /*  GC_HEADERS_H */
index 1e96f184a9e4afbd5959a9d723c67013604d97e7..36083970acdcba98cd3a03d2943d8bd68085f4ce 100644 (file)
@@ -54,7 +54,7 @@ extern mark_proc GC_mark_procs[MAX_MARK_PROCS];
        (((word)1 << (WORDSZ - GC_DS_TAG_BITS - GC_LOG_MAX_MARK_PROCS)) - 1)
 
 
-extern word GC_n_mark_procs;
+extern unsigned GC_n_mark_procs;
 
 /* Number of mark stack entries to discard on overflow.        */
 #define GC_MARK_STACK_DISCARDS (INITIAL_MARK_STACK_SIZE/8)
index e9bc20f67f2236170d2593fb3175c75eb7c5922e..a6d7f400f747a8a2674b3c12134c4f48b08bddf3 100644 (file)
@@ -553,7 +553,7 @@ extern GC_warn_proc GC_current_warn_proc;
  
 # define HBLKPTR(objptr) ((struct hblk *)(((word) (objptr)) & ~(HBLKSIZE-1)))
 
-# define HBLKDISPL(objptr) (((word) (objptr)) & (HBLKSIZE-1))
+# define HBLKDISPL(objptr) (((size_t) (objptr)) & (HBLKSIZE-1))
 
 /* Round up byte allocation requests to integral number of words, etc. */
 # define ROUNDED_UP_WORDS(n) \
@@ -908,7 +908,7 @@ struct _GC_arrays {
     word _unmapped_bytes;
 # endif
 
-    unsigned _size_map[MAXOBJBYTES+1];
+    size_t _size_map[MAXOBJBYTES+1];
        /* Number of words to allocate for a given allocation request in */
        /* bytes.                                                        */
 
@@ -1132,7 +1132,7 @@ extern struct obj_kind {
 #   define IS_UNCOLLECTABLE(k) ((k) == UNCOLLECTABLE)
 # endif
 
-extern int GC_n_kinds;
+extern unsigned GC_n_kinds;
 
 GC_API word GC_fo_entries;
 
@@ -1241,7 +1241,7 @@ extern long GC_large_alloc_warn_suppressed;
 #endif /* !USE_MARK_BYTES */
 
 #ifdef MARK_BIT_PER_OBJ
-#  define MARK_BIT_NO(offset, sz) ((offset)/(sz))
+#  define MARK_BIT_NO(offset, sz) (((unsigned)(offset))/(sz))
        /* Get the mark bit index corresponding to the given byte       */
        /* offset and size (in bytes).                                  */
 #  define MARK_BIT_OFFSET(sz) 1
@@ -1250,7 +1250,7 @@ extern long GC_large_alloc_warn_suppressed;
 #  define FINAL_MARK_BIT(sz) ((sz) > MAXOBJBYTES? 1 : HBLK_OBJS(sz))
        /* Position of final, always set, mark bit.                     */
 #else /* MARK_BIT_PER_GRANULE */
-#  define MARK_BIT_NO(offset, sz) BYTES_TO_GRANULES(offset)
+#  define MARK_BIT_NO(offset, sz) BYTES_TO_GRANULES((unsigned)(offset))
 #  define MARK_BIT_OFFSET(sz) BYTES_TO_GRANULES(sz)
 #  define IF_PER_OBJ(x)
 #  define FINAL_MARK_BIT(sz) \
@@ -1542,7 +1542,7 @@ ptr_t GC_build_fl(struct hblk *h, size_t words, GC_bool clear, ptr_t list);
                                /* called explicitly without GC lock.   */
 
 struct hblk * GC_allochblk (size_t size_in_bytes, int kind,
-                           unsigned char flags);
+                           unsigned flags);
                                /* Allocate a heap block, inform        */
                                /* the marker that block is valid       */
                                /* for objects of indicated size.       */
index 11599c7a3a201a6a5fb72ec840181563277e88d0..eba019d34fc2ba8c274b5c5de8b7b1cd52dc8424 100644 (file)
@@ -224,8 +224,7 @@ void GC_with_callee_saves_pushed(void (*fn)(ptr_t, void *),
     GC_noop1((word)(&dummy));
 }
 
-void GC_push_regs_and_stack(cold_gc_frame)
-ptr_t cold_gc_frame;
+void GC_push_regs_and_stack(ptr_t cold_gc_frame)
 {
     GC_with_callee_saves_pushed(GC_push_current_stack, cold_gc_frame);
 }
index 7a546a68e570de0804a598e005c00eca2d6b1a6f..94032640e62b9f0b4a3560b46a82ab5629bdba49 100644 (file)
--- a/malloc.c
+++ b/malloc.c
@@ -64,7 +64,7 @@ ptr_t GC_alloc_large(size_t lb, int k, unsigned flags)
     if (h == 0) {
        result = 0;
     } else {
-       int total_bytes = n_blocks * HBLKSIZE;
+       size_t total_bytes = n_blocks * HBLKSIZE;
        if (n_blocks > 1) {
            GC_large_allocd_bytes += total_bytes;
            if (GC_large_allocd_bytes > GC_max_large_allocd_bytes)
diff --git a/mark.c b/mark.c
index 43f114bb2bdefb5aa3b325b050c62bb0ceba0f58..3e5c46d1b054ae3bab6a12580675c1acf65c841e 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -41,7 +41,7 @@ void GC_noop1(word x)
 
 /* mark_proc GC_mark_procs[MAX_MARK_PROCS] = {0} -- declared in gc_priv.h */
 
-word GC_n_mark_procs = GC_RESERVED_MARK_PROCS;
+unsigned GC_n_mark_procs = GC_RESERVED_MARK_PROCS;
 
 /* Initialize GC_obj_kinds properly and standard free lists properly.          */
 /* This must be done statically since they may be accessed before      */
@@ -69,15 +69,15 @@ struct obj_kind GC_obj_kinds[MAXOBJKINDS] = {
 
 # ifdef ATOMIC_UNCOLLECTABLE
 #   ifdef STUBBORN_ALLOC
-      int GC_n_kinds = 5;
+      unsigned GC_n_kinds = 5;
 #   else
-      int GC_n_kinds = 4;
+      unsigned GC_n_kinds = 4;
 #   endif
 # else
 #   ifdef STUBBORN_ALLOC
-      int GC_n_kinds = 4;
+      unsigned GC_n_kinds = 4;
 #   else
-      int GC_n_kinds = 3;
+      unsigned GC_n_kinds = 3;
 #   endif
 # endif
 
@@ -141,7 +141,7 @@ GC_bool GC_collection_in_progress(void)
 /* clear all mark bits in the header */
 void GC_clear_hdr_marks(hdr *hhdr)
 {
-    int last_bit = FINAL_MARK_BIT(hhdr -> hb_sz);
+    size_t last_bit = FINAL_MARK_BIT(hhdr -> hb_sz);
 
 #   ifdef USE_MARK_BYTES
       BZERO(hhdr -> hb_marks, MARK_BITS_SZ);
@@ -158,7 +158,7 @@ void GC_set_hdr_marks(hdr *hhdr)
 {
     unsigned i;
     size_t sz = hhdr -> hb_sz;
-    int n_marks = FINAL_MARK_BIT(sz);
+    size_t n_marks = FINAL_MARK_BIT(sz);
 
 #   ifdef USE_MARK_BYTES
       for (i = 0; i <= n_marks; i += MARK_BIT_OFFSET(sz)) {
@@ -196,7 +196,7 @@ void GC_set_mark_bit(ptr_t p)
 {
     struct hblk *h = HBLKPTR(p);
     hdr * hhdr = HDR(h);
-    int bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
+    word bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
     
     if (!mark_bit_from_hdr(hhdr, bit_no)) {
       set_mark_bit_from_hdr(hhdr, bit_no);
@@ -208,10 +208,10 @@ void GC_clear_mark_bit(ptr_t p)
 {
     struct hblk *h = HBLKPTR(p);
     hdr * hhdr = HDR(h);
-    int bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
+    word bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
     
     if (mark_bit_from_hdr(hhdr, bit_no)) {
-      int n_marks;
+      size_t n_marks;
       clear_mark_bit_from_hdr(hhdr, bit_no);
       n_marks = hhdr -> hb_n_marks - 1;
 #     ifdef PARALLEL_MARK
@@ -230,9 +230,9 @@ GC_bool GC_is_marked(ptr_t p)
 {
     struct hblk *h = HBLKPTR(p);
     hdr * hhdr = HDR(h);
-    int bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
+    word bit_no = MARK_BIT_NO(p - (ptr_t)h, hhdr -> hb_sz);
     
-    return(mark_bit_from_hdr(hhdr, bit_no));
+    return((GC_bool)mark_bit_from_hdr(hhdr, bit_no));
 }
 
 
@@ -602,7 +602,7 @@ mse * GC_signal_mark_stack_overflow(mse *msp)
  */
 mse * GC_mark_from(mse *mark_stack_top, mse *mark_stack, mse *mark_stack_limit)
 {
-  int credit = HBLKSIZE;       /* Remaining credit for marking work    */
+  signed_word credit = HBLKSIZE;  /* Remaining credit for marking work */
   ptr_t current_p;     /* Pointer to current candidate ptr.    */
   word current;        /* Candidate pointer.                   */
   ptr_t limit; /* (Incl) limit of current candidate    */
@@ -1169,7 +1169,7 @@ static void alloc_mark_stack(size_t n)
 #   ifdef GWW_VDB
       /* Don't recycle a stack segment obtained with the wrong flags.  */
       /* Win32 GetWriteWatch requires the right kind of memory.                */
-      static GC_incremental_at_stack_alloc = 0;
+      static GC_bool GC_incremental_at_stack_alloc = 0;
       GC_bool recycle_old = (!GC_incremental || GC_incremental_at_stack_alloc);
 
       GC_incremental_at_stack_alloc = GC_incremental;
@@ -1230,9 +1230,7 @@ void GC_mark_init()
  * Should only be used if there is no possibility of mark stack
  * overflow.
  */
-void GC_push_all(bottom, top)
-ptr_t bottom;
-ptr_t top;
+void GC_push_all(ptr_t bottom, ptr_t top)
 {
     register word length;
     
@@ -1268,8 +1266,8 @@ void GC_push_selected(ptr_t bottom, ptr_t top,
 {
     struct hblk * h;
 
-    bottom = (ptr_t)(((long) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
-    top = (ptr_t)(((long) top) & ~(ALIGNMENT-1));
+    bottom = (ptr_t)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
+    top = (ptr_t)(((word) top) & ~(ALIGNMENT-1));
 
     if (top == 0 || bottom == top) return;
     h = HBLKPTR(bottom + HBLKSIZE);
@@ -1733,10 +1731,10 @@ void GC_push_marked4(struct hblk *h, hdr *hhdr)
 /* Push all objects reachable from marked objects in the given block */
 void GC_push_marked(struct hblk *h, hdr *hhdr)
 {
-    int sz = hhdr -> hb_sz;
-    int descr = hhdr -> hb_descr;
+    size_t sz = hhdr -> hb_sz;
+    word descr = hhdr -> hb_descr;
     ptr_t p;
-    int bit_no;
+    word bit_no;
     ptr_t lim;
     mse * GC_mark_stack_top_reg;
     mse * mark_stack_limit = GC_mark_stack_limit;
@@ -1785,7 +1783,7 @@ void GC_push_marked(struct hblk *h, hdr *hhdr)
 /* Test whether any page in the given block is dirty   */
 GC_bool GC_block_was_dirty(struct hblk *h, hdr *hhdr)
 {
-    int sz = hhdr -> hb_sz;
+    size_t sz = hhdr -> hb_sz;
     
     if (sz <= MAXOBJBYTES) {
          return(GC_page_was_dirty(h));
diff --git a/misc.c b/misc.c
index c801baabf0bd2ea4715e827c513d2d2cd30d62cb..a26f95e0b91f4091a2a3312a3c26a9d5f22b1673 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -354,9 +354,9 @@ void * GC_base(void * p)
     /* Make sure r points to the beginning of the object */
        r = (ptr_t)((word)r & ~(WORDS_TO_BYTES(1) - 1));
         {
-           int offset = HBLKDISPL(r);
+           size_t offset = HBLKDISPL(r);
            signed_word sz = candidate_hdr -> hb_sz;
-           int obj_displ = offset % sz;
+           size_t obj_displ = offset % sz;
 
            r -= obj_displ;
             limit = r + sz;
@@ -401,6 +401,10 @@ size_t GC_get_total_bytes(void)
 
 GC_bool GC_is_initialized = FALSE;
 
+# if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
+  extern void GC_init_parallel(void);
+# endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
+
 void GC_init(void)
 {
     DCL_LOCK_STATE;
@@ -429,7 +433,6 @@ void GC_init(void)
        /* allocation is initialized, in case we didn't get      */
        /* called from GC_init_parallel();                       */
         {
-         extern void GC_init_parallel(void);
          GC_init_parallel();
        }
 #   endif /* PARALLEL_MARK || THREAD_LOCAL_ALLOC */
@@ -829,9 +832,7 @@ out:
 # ifndef THREADS
 #   define GC_need_to_lock 0  /* Not defined without threads */
 # endif
-  int GC_write(buf, len)
-  const char * buf;
-  size_t len;
+  int GC_write(const char *buf, size_t len)
   {
       BOOL tmp;
       DWORD written;
@@ -861,7 +862,7 @@ out:
        if (GC_stdout == INVALID_HANDLE_VALUE)
            ABORT("Open of log file failed");
       }
-      tmp = WriteFile(GC_stdout, buf, len, &written, NULL);
+      tmp = WriteFile(GC_stdout, buf, (DWORD)len, &written, NULL);
       if (!tmp)
          DebugBreak();
 #     if defined(_MSC_VER) && defined(_DEBUG)
@@ -1006,8 +1007,7 @@ void GC_log_printf(const char *format, ...)
     if (WRITE(GC_log, buf, strlen(buf)) < 0) ABORT("write to log failed");
 }
 
-void GC_err_puts(s)
-const char *s;
+void GC_err_puts(const char *s)
 {
     if (WRITE(GC_stderr, s, strlen(s)) < 0) ABORT("write to stderr failed");
 }
@@ -1050,8 +1050,7 @@ GC_word GC_set_free_space_divisor (GC_word value)
 }
 
 #ifndef PCR
-void GC_abort(msg)
-const char * msg;
+void GC_abort(const char *msg)
 {
 #   if defined(MSWIN32)
       (void) MessageBoxA(NULL, msg, "Fatal error in gc", MB_ICONERROR|MB_OK);
@@ -1106,9 +1105,9 @@ void ** GC_new_free_list()
     return result;
 }
 
-int GC_new_kind_inner(void **fl, GC_word descr, int adjust, int clear)
+unsigned GC_new_kind_inner(void **fl, GC_word descr, int adjust, int clear)
 {
-    int result = GC_n_kinds++;
+    unsigned result = GC_n_kinds++;
 
     if (GC_n_kinds > MAXOBJKINDS) ABORT("Too many kinds");
     GC_obj_kinds[result].ok_freelist = fl;
@@ -1119,27 +1118,27 @@ int GC_new_kind_inner(void **fl, GC_word descr, int adjust, int clear)
     return result;
 }
 
-int GC_new_kind(void **fl, GC_word descr, int adjust, int clear)
+unsigned GC_new_kind(void **fl, GC_word descr, int adjust, int clear)
 {
-    int result;
+    unsigned result;
     LOCK();
     result = GC_new_kind_inner(fl, descr, adjust, clear);
     UNLOCK();
     return result;
 }
 
-int GC_new_proc_inner(GC_mark_proc proc)
+unsigned GC_new_proc_inner(GC_mark_proc proc)
 {
-    int result = GC_n_mark_procs++;
+    unsigned result = GC_n_mark_procs++;
 
     if (GC_n_mark_procs > MAX_MARK_PROCS) ABORT("Too many mark procedures");
     GC_mark_procs[result] = proc;
     return result;
 }
 
-int GC_new_proc(GC_mark_proc proc)
+unsigned GC_new_proc(GC_mark_proc proc)
 {
-    int result;
+    unsigned result;
     LOCK();
     result = GC_new_proc_inner(proc);
     UNLOCK();
index e77a669301660569399e79e3bfc4f7377211cc2b..b172025ba532ec202f8f02589f404a883090e919 100644 (file)
   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   THE SOFTWARE.
 */
+#ifndef _M_AMD64
+
+/* X86_64 is ccurrently missing some meachine-dependent code below. */
+
 #include "private/msvc_dbg.h"
 
 #define WIN32_LEAN_AND_MEAN
@@ -340,3 +344,5 @@ char** backtrace_symbols(void*const* addresses, int count)
        GetDescriptionFromStack(addresses, count, NULL, symbols, size);
        return symbols;
 }
+
+#endif /* !_M_AMD64 */
index 3b9a09d1c30f83e5c4384e4258cdb041f1ce47df..c295c4033b60f26828975cb83347bd668ae1900a 100644 (file)
--- a/obj_map.c
+++ b/obj_map.c
@@ -68,7 +68,7 @@ GC_bool GC_add_map_entry(size_t granules)
       }
     } else {
       for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) {
-       new_map[displ] = displ % granules;
+       new_map[displ] = (short)(displ % granules);
       }
     }
     GC_obj_map[granules] = new_map;
index 1269a2b5e7e8233f314be49f474afe89faf2bf8d..a1293f10f9293fc236efa8187f7e4bd15f812f94 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -1378,7 +1378,7 @@ void GC_register_data_segments(void)
                                     PAGE_READWRITE);
         if (page != NULL) {
           PVOID pages[16];
-          DWORD count = 16;
+          ULONG_PTR count = 16;
           DWORD page_size;
           /* Check that it actually works.  In spite of some           */
          /* documentation it actually seems to exist on W2K.           */
@@ -1430,7 +1430,7 @@ void GC_register_data_segments(void)
   ptr_t GC_least_described_address(ptr_t start)
   {  
     MEMORY_BASIC_INFORMATION buf;
-    DWORD result;
+    size_t result;
     LPVOID limit;
     ptr_t p;
     LPVOID q;
@@ -1444,7 +1444,7 @@ void GC_register_data_segments(void)
        if (result != sizeof(buf) || buf.AllocationBase == 0) break;
        p = (ptr_t)(buf.AllocationBase);
     }
-    return(p);
+    return p;
   }
 # endif
 
@@ -1480,7 +1480,7 @@ void GC_register_data_segments(void)
   void *GC_get_allocation_base(void *p)
   {
     MEMORY_BASIC_INFORMATION buf;
-    DWORD result = VirtualQuery(p, &buf, sizeof(buf));
+    size_t result = VirtualQuery(p, &buf, sizeof(buf));
     if (result != sizeof(buf)) {
       ABORT("Weird VirtualQuery result");
     }
@@ -1528,7 +1528,7 @@ void GC_register_data_segments(void)
      unsigned i;
      
 #    ifndef REDIRECT_MALLOC
-       static word last_gc_no = -1;
+       static word last_gc_no = (word)(-1);
      
        if (last_gc_no != GC_gc_no) {
         GC_add_current_malloc_heap();
@@ -1547,7 +1547,7 @@ void GC_register_data_segments(void)
   void GC_register_root_section(ptr_t static_root)
   {
       MEMORY_BASIC_INFORMATION buf;
-      DWORD result;
+      size_t result;
       DWORD protect;
       LPVOID p;
       char * base;
@@ -2339,7 +2339,7 @@ void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
     BZERO(GC_grungy_pages, sizeof(GC_grungy_pages));
 
     for (i = 0; i != GC_n_heap_sects; ++i) {
-      DWORD count;
+      ULONG_PTR count;
 
       do {
         PVOID * pages, * pages_end;
@@ -2374,7 +2374,7 @@ void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
           unsigned j;
           struct hblk * start = (struct hblk *)GC_heap_sects[i].hs_start;
           static struct hblk *last_warned = 0;
-          unsigned nblocks = divHBLKSZ(GC_heap_sects[i].hs_bytes);
+          size_t nblocks = divHBLKSZ(GC_heap_sects[i].hs_bytes);
 
           if ( i != 0 && last_warned != start && warn_count++ < 5) {
             last_warned = start;
@@ -2532,6 +2532,7 @@ GC_bool GC_page_was_ever_dirty(struct hblk *h)
 /* entire object.                                                      */
 void GC_dirty(ptr_t p)
 {
+    word index = PHT_HASH(p);
     async_set_pht_entry_from_index(GC_dirty_pages, index);
 }
 
@@ -2660,7 +2661,7 @@ GC_bool GC_old_segv_handler_used_si;
 /* correctly.                                                          */
 #ifdef AO_HAVE_test_and_set_acquire
   static volatile AO_TS_t fault_handler_lock = 0;
-  void async_set_pht_entry_from_index(volatile page_hash_table db, int index) {
+  void async_set_pht_entry_from_index(volatile page_hash_table db, size_t index) {
     while (AO_test_and_set_acquire(&fault_handler_lock) == AO_TS_SET) {}
     /* Could also revert to set_pht_entry_from_index_safe if initial   */
     /* GC_test_and_set fails.                                          */
@@ -2668,8 +2669,9 @@ GC_bool GC_old_segv_handler_used_si;
     AO_CLEAR(&fault_handler_lock);
   }
 #else /* !AO_have_test_and_set_acquire */
-# error No test-and_set operation: Introduces a race.
-  /* THIS IS INCORRECT! The dirty bit vector may be temporarily wrong, */
+# error No test_and_set operation: Introduces a race.
+  /* THIS WOULD BE INCORRECT!                                          */
+  /* The dirty bit vector may be temporarily wrong,                    */
   /* just before we notice the conflict and correct it. We may end up   */
   /* looking at it while it's wrong.  But this requires contention     */
   /* exactly when a GC is triggered, which seems far less likely to    */
@@ -2677,7 +2679,7 @@ GC_bool GC_old_segv_handler_used_si;
   /* leave it this way while we think of something better, or support  */
   /* GC_test_and_set on the remaining platforms.                       */
   static volatile word currently_updating = 0;
-  void async_set_pht_entry_from_index(volatile page_hash_table db, int index) {
+  void async_set_pht_entry_from_index(volatile page_hash_table db, size_t index) {
     unsigned int update_dummy;
     currently_updating = (word)(&update_dummy);
     set_pht_entry_from_index(db, index);
@@ -2830,7 +2832,7 @@ GC_bool GC_old_segv_handler_used_si;
        /* and then to have the thread stopping code set the dirty      */
        /* flag, if necessary.                                          */
         for (i = 0; i < divHBLKSZ(GC_page_size); i++) {
-            register int index = PHT_HASH(h+i);
+            size_t index = PHT_HASH(h+i);
             
             async_set_pht_entry_from_index(GC_dirty_pages, index);
         }
@@ -2873,7 +2875,7 @@ void GC_remove_protection(struct hblk *h, word nblocks, GC_bool is_ptrfree)
                            & ~(GC_page_size-1));
     found_clean = FALSE;
     for (current = h_trunc; current < h_end; ++current) {
-        int index = PHT_HASH(current);
+        size_t index = PHT_HASH(current);
             
         if (!is_ptrfree || current < h || current >= h + nblocks) {
             async_set_pht_entry_from_index(GC_dirty_pages, index);
index ad20c9abed3c1922503c1902278cf5460c984608..d04d2daf5265a674a54c6280d1cd9bbf255fe673 100644 (file)
@@ -75,8 +75,8 @@ void * GC_same_obj(void *p, void *q)
         goto fail;
       }
     } else {
-      int offset;
-      int pdispl = HBLKDISPL(p);
+      size_t offset;
+      size_t pdispl = HBLKDISPL(p);
       
       offset = pdispl % sz;
       if (HBLKPTR(p) != HBLKPTR(q)) goto fail;
index b1ff6b7585afa61e6bf3d16aa97d5c5b9290d38b..cd50fa4811336114b34a3bc99704ec62778ef384 100644 (file)
--- a/reclaim.c
+++ b/reclaim.c
@@ -112,7 +112,7 @@ GC_bool GC_block_nearly_full(hdr *hhdr)
 ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
                       ptr_t list, signed_word *count)
 {
-    int bit_no = 0;
+    word bit_no = 0;
     word *p, *q, *plim;
     signed_word n_bytes_found = 0;
     
@@ -160,7 +160,7 @@ ptr_t GC_reclaim_clear(struct hblk *hbp, hdr *hhdr, size_t sz,
 ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
                        ptr_t list, signed_word *count)
 {
-    int bit_no = 0;
+    word bit_no = 0;
     word *p, *plim;
     signed_word n_bytes_found = 0;
     
@@ -187,7 +187,7 @@ ptr_t GC_reclaim_uninit(struct hblk *hbp, hdr *hhdr, size_t sz,
 /*ARGSUSED*/
 void GC_reclaim_check(struct hblk *hbp, hdr *hhdr, word sz)
 {
-    int bit_no = 0;
+    word bit_no = 0;
     ptr_t p, plim;
     
     GC_ASSERT(sz == hhdr -> hb_sz);
@@ -400,7 +400,7 @@ int GC_n_set_marks(hdr *hhdr)
 void GC_print_block_descr(struct hblk *h, word /* struct PrintStats */ raw_ps)
 {
     hdr * hhdr = HDR(h);
-    unsigned bytes = hhdr -> hb_sz;
+    size_t bytes = hhdr -> hb_sz;
     struct Print_stats *ps;
     unsigned n_marks = GC_n_set_marks(hhdr);
     
@@ -478,7 +478,7 @@ void GC_clear_fl_links(void **flp)
  */
 void GC_start_reclaim(GC_bool report_if_found)
 {
-    int kind;
+    unsigned kind;
     
 #   if defined(PARALLEL_MARK) || defined(THREAD_LOCAL_ALLOC)
       GC_ASSERT(0 == GC_fl_builder_count);
@@ -566,7 +566,7 @@ void GC_continue_reclaim(size_t sz /* granules */, int kind)
 GC_bool GC_reclaim_all(GC_stop_func stop_func, GC_bool ignore_old)
 {
     word sz;
-    int kind;
+    unsigned kind;
     hdr * hhdr;
     struct hblk * hbp;
     struct obj_kind * ok;
index 695f95121a1ef844ae06d600af43a92426d8ccd0..9bf53de811ec88b9c7dd031178cad0d9705354fd 100644 (file)
@@ -123,7 +123,7 @@ class D: public gc {public:
     static void CleanUp( void* obj, void* data ) {
         D* self = (D*) obj;
         nFreed++;
-        my_assert( self->i == (int) (long) data );}
+        my_assert( self->i == (int) (GC_word) data );}
     static void Test() {
         my_assert( nFreed >= .8 * nAllocated );}
        
@@ -170,10 +170,10 @@ int F::nFreed = 0;
 int F::nAllocated = 0;
    
 
-long Disguise( void* p ) {
-    return ~ (long) p;}
+GC_word Disguise( void* p ) {
+    return ~ (GC_word) p;}
 
-void* Undisguise( long i ) {
+void* Undisguise( GC_word i ) {
     return (void*) ~ i;}
 
 
@@ -229,8 +229,8 @@ int APIENTRY WinMain(
             /* Allocate some uncollectable As and disguise their pointers.
             Later we'll check to see if the objects are still there.  We're
             checking to make sure these objects really are uncollectable. */
-        long as[ 1000 ];
-        long bs[ 1000 ];
+        GC_word as[ 1000 ];
+        GC_word bs[ 1000 ];
         for (i = 0; i < 1000; i++) {
             as[ i ] = Disguise( new (NoGC) A( i ) );
             bs[ i ] = Disguise( new (NoGC) B( i ) );}
@@ -240,7 +240,7 @@ int APIENTRY WinMain(
         for (i = 0; i < 1000; i++) {
             C* c = new C( 2 );
             C c1( 2 );           /* stack allocation should work too */
-            D* d = ::new (USE_GC, D::CleanUp, (void*)(long)i) D( i );
+            D* d = ::new (USE_GC, D::CleanUp, (void*)(GC_word)i) D( i );
             F* f = new F;
             if (0 == i % 10) delete c;}
 
index 1124ff955e996c709848f7d165025d4a9acbf146..744d938fca39e60e116b8e04ad6fefabd0ed38fa 100644 (file)
@@ -107,7 +107,7 @@ signed_word GC_add_ext_descriptor(GC_bitmap bm, word nbits)
     signed_word result;
     size_t i;
     word last_part;
-    int extra_bits;
+    size_t extra_bits;
     DCL_LOCK_STATE;
 
     LOCK();
@@ -525,7 +525,7 @@ GC_descr GC_make_descriptor(GC_bitmap bm, size_t len)
 {
     signed_word last_set_bit = len - 1;
     GC_descr result;
-    int i;
+    signed_word i;
 #   define HIGH_BIT (((word)1) << (WORDSZ - 1))
     
     if (!GC_explicit_typing_initialized) GC_init_explicit_typing();
@@ -634,7 +634,7 @@ DCL_LOCK_STATE;
    } else {
        op = (ptr_t)GENERAL_MALLOC_IOP(lb, GC_explicit_kind);
        if (op != NULL)
-       lg = BYTES_TO_WORDS(GC_size(op));
+         lg = BYTES_TO_WORDS(GC_size(op));
    }
    if (op != NULL)
        ((word *)op)[GRANULES_TO_WORDS(lg) - 1] = d;
index c89d9724b0ffa488acb11c8db4688a949b7b41ee..fa62c568edbc4294c410b07f6f7dea5036935ffd 100644 (file)
@@ -206,7 +206,7 @@ volatile GC_bool GC_please_stop = FALSE;
  * If we notice this in the middle of marking.
  */
 
-AO_t GC_attached_thread = 0;
+AO_t GC_attached_thread = FALSE;
 /* Return TRUE if an thread was attached since we last asked or        */
 /* since GC_attached_thread was explicitly reset.              */
 GC_bool GC_started_thread_while_stopped(void)
@@ -219,7 +219,7 @@ GC_bool GC_started_thread_while_stopped(void)
     if (result) {
       AO_store(&GC_attached_thread, FALSE);
     }
-    return (result);
+    return ((GC_bool)result);
   } else {
     return FALSE;
   }
@@ -253,7 +253,7 @@ GC_bool GC_started_thread_while_stopped(void)
 /* Unlike the pthreads version, the id field is set by the caller.     */
 GC_thread GC_new_thread(DWORD id)
 {
-    int hv = ((word)id) % THREAD_TABLE_SZ;
+    word hv = ((word)id) % THREAD_TABLE_SZ;
     GC_thread result;
     /* It may not be safe to allocate when we register the first thread. */
     static struct GC_Thread_Rep first_thread;
@@ -439,7 +439,7 @@ GC_thread GC_lookup_thread_inner(DWORD thread_id) {
       return (GC_thread)(dll_thread_table + i);
     }
   } else {
-    int hv = ((word)thread_id) % THREAD_TABLE_SZ;
+    word hv = ((word)thread_id) % THREAD_TABLE_SZ;
     register GC_thread p = GC_threads[hv];
     
     GC_ASSERT(I_HOLD_LOCK());
@@ -494,7 +494,7 @@ void GC_delete_gc_thread(GC_vthread gc_id)
     /* Cast away volatile qualifier, since we have lock. */
     GC_thread gc_nvid = (GC_thread)gc_id;
     DWORD id = gc_nvid -> id;
-    int hv = ((word)id) % THREAD_TABLE_SZ;
+    word hv = ((word)id) % THREAD_TABLE_SZ;
     register GC_thread p = GC_threads[hv];
     register GC_thread prev = 0;
 
@@ -529,7 +529,7 @@ void GC_delete_thread(DWORD id)
       GC_delete_gc_thread(t);
     }
   } else {
-    int hv = ((word)id) % THREAD_TABLE_SZ;
+    word hv = ((word)id) % THREAD_TABLE_SZ;
     register GC_thread p = GC_threads[hv];
     register GC_thread prev = 0;
     
@@ -832,6 +832,10 @@ void GC_push_stack_for(GC_thread thread)
 #       if defined(I386)
           PUSH4(Edi,Esi,Ebx,Edx), PUSH2(Ecx,Eax), PUSH1(Ebp);
          sp = (ptr_t)context.Esp;
+#      elif defined(X86_64)
+         PUSH4(Rax,Rcx,Rdx,Rbx); PUSH2(Rbp, Rsi); PUSH1(Rdi);
+         PUSH4(R8, R9, R10, R11); PUSH4(R12, R13, R14, R15);
+         sp = (ptr_t)context.Rsp;
 #       elif defined(ARM32)
          PUSH4(R0,R1,R2,R3),PUSH4(R4,R5,R6,R7),PUSH4(R8,R9,R10,R11),PUSH1(R12);
          sp = (ptr_t)context.Sp;
@@ -876,7 +880,7 @@ void GC_push_stack_for(GC_thread thread)
         GC_push_all_stack(sp, thread->stack_base);
       } else {
         WARN("Thread stack pointer 0x%lx out of range, pushing everything\n",
-            (unsigned long)sp);
+            (unsigned long)(size_t)sp);
         GC_push_all_stack(stack_min, thread->stack_base);
       }
     } /* thread looks live */
@@ -986,7 +990,7 @@ void * GC_win32_start_inner(struct GC_stack_base *sb, LPVOID arg)
 #ifndef __GNUC__
     __try {
 #endif /* __GNUC__ */
-       ret = (void *)args->start (args->param);
+       ret = (void *)(size_t)args->start (args->param);
 #ifndef __GNUC__
     } __finally {
 #endif /* __GNUC__ */
@@ -1001,7 +1005,7 @@ void * GC_win32_start_inner(struct GC_stack_base *sb, LPVOID arg)
 
 DWORD WINAPI GC_win32_start(LPVOID arg)
 {
-    return (DWORD)GC_call_with_stack_base(GC_win32_start_inner, arg);
+    return (DWORD)(size_t)GC_call_with_stack_base(GC_win32_start_inner, arg);
 }
 
 GC_API HANDLE WINAPI GC_CreateThread(
@@ -1069,7 +1073,7 @@ uintptr_t GC_beginthreadex(
        /* Handed off to and deallocated by child thread.       */
       if (0 == args) {
        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
-        return -1L;
+        return (uintptr_t)(-1);
       }
 
       /* set up thread arguments */