summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2001-10-23 17:09:23 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2001-10-23 17:09:23 (GMT)
commit0eca7bb7913aa0c6c642c1ea13a981ac89345de3 (patch)
tree0ae204355d632573a909635c2877648df4396493
parent18a1b3bf7b3974d264243377a2ea51c7656c4473 (diff)
downloadlpsm-0eca7bb7913aa0c6c642c1ea13a981ac89345de3.zip
lpsm-0eca7bb7913aa0c6c642c1ea13a981ac89345de3.tar.gz
lpsm-0eca7bb7913aa0c6c642c1ea13a981ac89345de3.tar.bz2
lpsm-0eca7bb7913aa0c6c642c1ea13a981ac89345de3.tar.xz
Fix lpsm_zalloc(), and make debugging build work again.lpsm-0.1.6
-rw-r--r--CHANGES4
-rw-r--r--Makefile9
-rw-r--r--arena.c5
-rw-r--r--malloc.c2
-rw-r--r--zalloc.c4
5 files changed, 17 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..75e3fcc
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,4 @@
+Changes in 0.1.6:
+-----------------
+* Fix lpsm_zalloc()/lpsm_calloc() which were utterly broken.
+* Make debugging build work again.
diff --git a/Makefile b/Makefile
index 7aa7794..95357c7 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@
TEST = teststore test_mmap ftrunctest testbuddy testalloc testrecovery
SONAME = libpsm.so.0
-VERSION = 0.1.5
+VERSION = 0.1.6
LIBPSM = libpsm.so.$(VERSION) libpsm.a
CFILES = arena.c bitops.c \
@@ -23,13 +23,16 @@ OSPICOBJ = $(patsubst %.c,%.pic.o,$(CFILES))
MANPAGES = $(patsubst %.in,%,$(wildcard *.[1-9].in))
CC = gcc
+ifndef DEBUG
# This is a reasonable set of flags for production
# Add -NDEBUG if you don't want to retain assert()s
CFLAGS = -I. -Wall -O3 -fomit-frame-pointer -D_FILE_OFFSET_BITS=64 # -DNDEBUG
LDFLAGS =
+else
# This is for debugging
-# CFLAGS = -I. -Wall -O -g -DPRINT_DEBUG_INFO -D_FILE_OFFSET_BITS=64
-# LDFLAGS = -g
+CFLAGS = -I. -Wall -O -g -DPRINT_DEBUG_INFO -D_FILE_OFFSET_BITS=64
+LDFLAGS = -g
+endif
LIBS = libpsm.a -lm
PICFLAGS = $(CFLAGS) -fPIC
SOFLAGS = -shared
diff --git a/arena.c b/arena.c
index 0de97d9..ff8d2bf 100644
--- a/arena.c
+++ b/arena.c
@@ -145,7 +145,10 @@ static void lpsm_sigsegv(int signal, siginfo_t *siginfo, void *ptr)
siginfo->si_addr, (void *)ctxt->eip);
#endif
#endif
-
+#ifdef PRINT_DEBUG_INFO
+ abort(); /* Easier to tell from SIGSEGV */
+#endif
+
errno = old_errno;
return; /* Re-take fault */
}
diff --git a/malloc.c b/malloc.c
index d565ebc..6eb8aac 100644
--- a/malloc.c
+++ b/malloc.c
@@ -164,7 +164,7 @@ int lpsm_malloc_buddy_xbit(int order)
rorder = AH->arena_size_lg2 - order;
obit = 1 << rorder;
- DPRINTF(("buddy: trying to allocate %d bytes, rorder = %d\n", size, rorder));
+ DPRINTF(("buddy: trying to allocate rorder = %d\n", rorder));
xbit = lpsm_find_free_chunk(rorder);
if ( !xbit ) {
diff --git a/zalloc.c b/zalloc.c
index f972b16..2faa623 100644
--- a/zalloc.c
+++ b/zalloc.c
@@ -37,7 +37,7 @@ void *lpsm_zalloc(size_t size)
while ( size > ((size_t)1 << order) )
order++;
- xbit = lpsm_malloc_buddy_xbit(size);
+ xbit = lpsm_malloc_buddy_xbit(order);
if ( !xbit ) {
errno = ENOMEM;
return NULL;
@@ -53,7 +53,7 @@ void *lpsm_zalloc(size_t size)
size = (size_t)1 << order; /* "Real" size */
/* Do an anonymous mmap() over the affected area */
mv = mmap(ptr, size, PROT_READ|PROT_WRITE,
- MAP_FIXED|MAP_PRIVATE, 0, 0);
+ MAP_FIXED|MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
if ( mv != ptr ) {
memset(ptr, 0, size);
} else {