summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2011-08-21 11:45:57 +0400
committerIvan Maidanski <ivmai@mail.ru>2011-08-21 11:57:43 +0400
commit2c23fbee16d82b05c69588d83d52b17d107d8eb3 (patch)
tree356cba3b857f6f9f9dd8c0376ff3904b1c3b40fb
parent00d105946fc3b7d424a2d017288feb72e2c80849 (diff)
downloadbdwgc-2c23fbee16d82b05c69588d83d52b17d107d8eb3.tar.gz
Resolve "comparison of signed and unsigned values" compiler warnings.
* allchblk.c (GC_allochblk_nth): Cast MAX_BLACK_LIST_ALLOC and HBLKSIZE to signed_word. * mallocx.c (GC_generic_malloc_many): Cast my_bytes_allocd to word. * mark.c (GC_do_local_mark): Cast the result of local_top minus local_mark_stack to word (since is non-negative). * misc.c (GC_base): Declare sz as unsigned word. * misc.c (GC_enable_incremental): Cast bytes_written to size_t in comparison to len. * obj_map.c (GC_initialize_offsets): Declare 'i' as unsigned. * os_dep.c (GC_or_pages): Ditto. * typd_mlc.c (GC_init_explicit_typing): Ditto. * ptr_chck.c (GC_is_visible): Cast the result of p minus base to word. * typd_mlc.c (GC_make_descriptor): Cast last_set_bit to word (since non-negative) when compared to BITMAP_BITS.
-rw-r--r--allchblk.c10
-rw-r--r--mallocx.c2
-rw-r--r--mark.c3
-rw-r--r--misc.c4
-rw-r--r--obj_map.c2
-rw-r--r--os_dep.c2
-rw-r--r--ptr_chck.c2
-rw-r--r--typd_mlc.c7
8 files changed, 17 insertions, 15 deletions
diff --git a/allchblk.c b/allchblk.c
index efcc00ab..dc35bc28 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -680,14 +680,14 @@ GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n,
}
}
}
- if ( !IS_UNCOLLECTABLE(kind) &&
- (kind != PTRFREE || size_needed > MAX_BLACK_LIST_ALLOC)) {
+ if ( !IS_UNCOLLECTABLE(kind) && (kind != PTRFREE
+ || size_needed > (signed_word)MAX_BLACK_LIST_ALLOC)) {
struct hblk * lasthbp = hbp;
ptr_t search_end = (ptr_t)hbp + size_avail - size_needed;
signed_word orig_avail = size_avail;
- signed_word eff_size_needed = ((flags & IGNORE_OFF_PAGE)?
- HBLKSIZE
- : size_needed);
+ signed_word eff_size_needed = (flags & IGNORE_OFF_PAGE) != 0 ?
+ (signed_word)HBLKSIZE
+ : size_needed;
while ((ptr_t)lasthbp <= search_end
diff --git a/mallocx.c b/mallocx.c
index d92014c9..e5928358 100644
--- a/mallocx.c
+++ b/mallocx.c
@@ -377,7 +377,7 @@ GC_API void GC_CALL GC_generic_malloc_many(size_t lb, int k, void **result)
my_bytes_allocd = 0;
for (p = op; p != 0; p = obj_link(p)) {
my_bytes_allocd += lb;
- if (my_bytes_allocd >= HBLKSIZE) {
+ if ((word)my_bytes_allocd >= HBLKSIZE) {
*opp = obj_link(p);
obj_link(p) = 0;
break;
diff --git a/mark.c b/mark.c
index 9a34082d..434bec76 100644
--- a/mark.c
+++ b/mark.c
@@ -986,7 +986,8 @@ STATIC void GC_do_local_mark(mse *local_mark_stack, mse *local_top)
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 (local_top - local_mark_stack >= LOCAL_MARK_STACK_SIZE/2) {
+ if ((word)(local_top - local_mark_stack)
+ >= LOCAL_MARK_STACK_SIZE / 2) {
GC_return_mark_stack(local_mark_stack, local_top);
return;
}
diff --git a/misc.c b/misc.c
index ab3fef99..2ea209f2 100644
--- a/misc.c
+++ b/misc.c
@@ -375,7 +375,7 @@ GC_API void * GC_CALL GC_base(void * p)
r = (ptr_t)((word)r & ~(WORDS_TO_BYTES(1) - 1));
{
size_t offset = HBLKDISPL(r);
- signed_word sz = candidate_hdr -> hb_sz;
+ word sz = candidate_hdr -> hb_sz;
size_t obj_displ = offset % sz;
r -= obj_displ;
@@ -1257,7 +1257,7 @@ GC_API void GC_CALL GC_enable_incremental(void)
IF_CANCEL(int cancel_state;)
DISABLE_CANCEL(cancel_state);
- while (bytes_written < len) {
+ while ((size_t)bytes_written < len) {
# ifdef GC_SOLARIS_THREADS
result = syscall(SYS_write, fd, buf + bytes_written,
len - bytes_written);
diff --git a/obj_map.c b/obj_map.c
index 082a0aa7..ed75ef12 100644
--- a/obj_map.c
+++ b/obj_map.c
@@ -78,7 +78,7 @@ GC_INNER void GC_register_displacement_inner(size_t offset)
GC_INNER void GC_initialize_offsets(void)
{
- int i;
+ unsigned i;
if (GC_all_interior_pointers) {
for (i = 0; i < VALID_OFFSET_SZ; ++i)
GC_valid_offsets[i] = TRUE;
diff --git a/os_dep.c b/os_dep.c
index 3cc6fff4..82223e9e 100644
--- a/os_dep.c
+++ b/os_dep.c
@@ -2627,7 +2627,7 @@ STATIC void GC_default_push_other_roots(void)
/* Add all pages in pht2 to pht1 */
STATIC void GC_or_pages(page_hash_table pht1, page_hash_table pht2)
{
- register int i;
+ register unsigned i;
for (i = 0; i < PHT_SIZE; i++) pht1[i] |= pht2[i];
}
diff --git a/ptr_chck.c b/ptr_chck.c
index d8076e84..5b3cc0a6 100644
--- a/ptr_chck.c
+++ b/ptr_chck.c
@@ -226,7 +226,7 @@ GC_API void * GC_CALL GC_is_visible(void *p)
if ((word)((ptr_t)p - (ptr_t)base) > (word)descr) goto fail;
break;
case GC_DS_BITMAP:
- if ((ptr_t)p - (ptr_t)base
+ if ((word)((ptr_t)p - (ptr_t)base)
>= WORDS_TO_BYTES(BITMAP_BITS)
|| ((word)p & (sizeof(word) - 1))) goto fail;
if (!(((word)1 << (WORDSZ - ((ptr_t)p - (ptr_t)base) - 1))
diff --git a/typd_mlc.c b/typd_mlc.c
index b031f61e..32a9b0f3 100644
--- a/typd_mlc.c
+++ b/typd_mlc.c
@@ -346,7 +346,7 @@ STATIC mse * GC_array_mark_proc(word * addr, mse * mark_stack_ptr,
/* Caller does not hold allocation lock. */
STATIC void GC_init_explicit_typing(void)
{
- register int i;
+ register unsigned i;
DCL_LOCK_STATE;
GC_STATIC_ASSERT(sizeof(struct LeafDescriptor) % sizeof(word) == 0);
@@ -540,7 +540,8 @@ GC_API GC_descr GC_CALL GC_make_descriptor(GC_bitmap bm, size_t len)
# define HIGH_BIT (((word)1) << (WORDSZ - 1))
if (!GC_explicit_typing_initialized) GC_init_explicit_typing();
- while (last_set_bit >= 0 && !GC_get_bit(bm, last_set_bit)) last_set_bit --;
+ while (last_set_bit >= 0 && !GC_get_bit(bm, last_set_bit))
+ last_set_bit--;
if (last_set_bit < 0) return(0 /* no pointers */);
# if ALIGNMENT == CPP_WORDSZ/8
{
@@ -557,7 +558,7 @@ GC_API GC_descr GC_CALL GC_make_descriptor(GC_bitmap bm, size_t len)
}
}
# endif
- if (last_set_bit < BITMAP_BITS) {
+ if ((word)last_set_bit < BITMAP_BITS) {
/* Hopefully the common case. */
/* Build bitmap descriptor (with bits reversed) */
result = HIGH_BIT;