summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-01-14 22:18:00 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2008-01-14 22:18:00 (GMT)
commitf3f7cb2bef0c949f7938c609a1bcdfeb7ad5631c (patch)
tree0d201becd8f19ca48cf495bfa97ea8fbe02abd3e
parentf6d514d7403b1a2f50a75227b72a6b208cf9b79a (diff)
downloadlpsm-f3f7cb2bef0c949f7938c609a1bcdfeb7ad5631c.zip
lpsm-f3f7cb2bef0c949f7938c609a1bcdfeb7ad5631c.tar.gz
lpsm-f3f7cb2bef0c949f7938c609a1bcdfeb7ad5631c.tar.bz2
lpsm-f3f7cb2bef0c949f7938c609a1bcdfeb7ad5631c.tar.xz
Type fixes: clean up 64-bit brokenness
Various things which assumed sizeof(int) == sizeof(size_t).
-rw-r--r--internals.h6
-rw-r--r--malloc.c7
-rw-r--r--realloc.c4
-rw-r--r--teststore.c2
4 files changed, 10 insertions, 9 deletions
diff --git a/internals.h b/internals.h
index cb96970..94a2e27 100644
--- a/internals.h
+++ b/internals.h
@@ -114,17 +114,17 @@ extern struct arena_header *lpsm_arena_header;
/* This is the minimal order before going to SLAB allocation. */
#define BUDDY_ORDER_MIN 12
-#define BUDDY_SIZE_MIN (1U << BUDDY_ORDER_MIN)
+#define BUDDY_SIZE_MIN (1L << BUDDY_ORDER_MIN)
/* Align allocations at least this large (2^n) to this boundary */
#define MINIMUM_ALIGN_LG2 4
-#define MINIMUM_ALIGN (1 << MINIMUM_ALIGN_LG2)
+#define MINIMUM_ALIGN (1L << MINIMUM_ALIGN_LG2)
#define MINIMUM_ALIGN_MASK (MINIMUM_ALIGN-1)
/* This is the size (2^n) allocated for a brand new arena.
This allocation will be sparse, so don't freak out too much! */
#define ARENA_START_SIZE_LG2 17 /* 128K */
-#define ARENA_START_SIZE (1UL << ARENA_START_SIZE_LG2)
+#define ARENA_START_SIZE (1L << ARENA_START_SIZE_LG2)
/* Function definitions used across modules */
diff --git a/malloc.c b/malloc.c
index c4e3494..5f71da0 100644
--- a/malloc.c
+++ b/malloc.c
@@ -199,7 +199,8 @@ void *lpsm_malloc_buddy(size_t size)
p = (void *)((char *)AH->data_start + ((uintptr_t)(xbit-obit) << order));
- DPRINTF(("buddy: allocated %u/%u bytes at %p\n", size, 1U << order, p));
+ DPRINTF(("buddy: allocated %zu/%zu bytes at %p\n",
+ size, (size_t)1 << order, p));
return p;
}
@@ -264,7 +265,7 @@ void *lpsm_malloc_slab(size_t size)
}
/* Now si points to the slab_info header we want to allocate from */
- DPRINTF(("slab: trying to allocate %d bytes, slab size %d bytes\n",
+ DPRINTF(("slab: trying to allocate %zu bytes, slab size %d bytes\n",
size, si->size));
sh = si->list;
@@ -300,7 +301,7 @@ void *lpsm_malloc_slab(size_t size)
}
p = (void *)((char *)sh + si->data_offset + which*si->size);
- DPRINTF(("slab: allocated %d/%d bytes at %p, %d/%d slabs in use\n",
+ DPRINTF(("slab: allocated %zu/%d bytes at %p, %d/%d slabs in use\n",
size, si->size, p, si->count-sh->free_count, si->count));
return p;
}
diff --git a/realloc.c b/realloc.c
index 308765e..22760fd 100644
--- a/realloc.c
+++ b/realloc.c
@@ -158,7 +158,7 @@ static void *lpsm_realloc_slab(void *ptr, size_t new_size)
si = &AH->slab[sh->index];
- DPRINTF(("slab: realloc %p size %d new_size %d\n",
+ DPRINTF(("slab: realloc %p size %d new_size %zu\n",
ptr, si->size, new_size));
/* For realloc(), tolerate the size being off by as much as a
@@ -199,7 +199,7 @@ void *lpsm_realloc(void *ptr, size_t new_size)
return NULL;
}
- DPRINTF(("realloc: ptr = %p, new_size = %d, is_slab = %d\n",
+ DPRINTF(("realloc: ptr = %p, new_size = %zu, is_slab = %d\n",
ptr, new_size, is_slab));
if ( is_slab ) {
diff --git a/teststore.c b/teststore.c
index 74d4d1e..8f95e45 100644
--- a/teststore.c
+++ b/teststore.c
@@ -19,7 +19,7 @@
int main(int argc, char *argv[])
{
void *buf;
- int arena_len = 16384;
+ size_t arena_len = 16384;
buf = lpsm_arena_init("test.dat", "test.log", &arena_len, NULL);