summaryrefslogtreecommitdiff
path: root/allchblk.c
diff options
context:
space:
mode:
authorhboehm <hboehm>2007-06-07 04:53:32 +0200
committerIvan Maidanski <ivmai@mail.ru>2011-07-26 19:06:40 +0200
commit16509ab0ddba3346db6ad5ca44a0c9e2cbda31a3 (patch)
tree47210e56e470e96e6de9ea57da8899a1cb21ab3f /allchblk.c
parente8a9ac333a5cb33944ec8a4c9c2884c4980c8cd7 (diff)
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.
Diffstat (limited to 'allchblk.c')
-rw-r--r--allchblk.c58
1 files changed, 21 insertions, 37 deletions
diff --git a/allchblk.c b/allchblk.c
index 997580a..0cec29d 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -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 */