diff --git a/sys/rump/Makefile.rump b/sys/rump/Makefile.rump index cedcc536d42a..455fafebd870 100644 --- a/sys/rump/Makefile.rump +++ b/sys/rump/Makefile.rump @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.rump,v 1.3 2007/08/07 21:33:13 pooka Exp $ +# $NetBSD: Makefile.rump,v 1.4 2007/08/15 22:13:15 pooka Exp $ # .include @@ -20,4 +20,6 @@ CPPFLAGS+= -D_KERNEL -DDIAGNOSTIC -I${NETBSDSRCDIR}/common/include CPPFLAGS+= -nostdinc -I${NETBSDSRCDIR}/sys .endif +LDFLAGS+= -Wl,--wrap=malloc + LIBRUMPDIR != cd ${NETBSDSRCDIR}/sys/rump/librump/rumpkern && ${PRINTOBJDIR} diff --git a/sys/rump/librump/rumpkern/emul.c b/sys/rump/librump/rumpkern/emul.c index c2888b3f4caa..f23f69bd26c0 100644 --- a/sys/rump/librump/rumpkern/emul.c +++ b/sys/rump/librump/rumpkern/emul.c @@ -1,4 +1,4 @@ -/* $NetBSD: emul.c,v 1.8 2007/08/14 13:54:15 pooka Exp $ */ +/* $NetBSD: emul.c,v 1.9 2007/08/15 22:13:15 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#define malloc(a,b,c) __wrap_malloc(a,b,c) + #include #include #include @@ -243,6 +245,18 @@ malloc_type_detach(struct malloc_type *type) return; } +void * +__wrap_malloc(unsigned long size, struct malloc_type *type, int flags) +{ + void *rv; + + rv = rumpuser_malloc(size, flags * (M_CANFAIL | M_NOWAIT)); + if (rv && flags & M_ZERO) + memset(rv, 0, size); + + return rv; +} + void nanotime(struct timespec *ts) { diff --git a/sys/rump/librump/rumpuser/Makefile b/sys/rump/librump/rumpuser/Makefile index cf800c13fd59..3c154fe4af6e 100644 --- a/sys/rump/librump/rumpuser/Makefile +++ b/sys/rump/librump/rumpuser/Makefile @@ -1,14 +1,13 @@ -# $NetBSD: Makefile,v 1.2 2007/08/07 20:39:54 pooka Exp $ +# $NetBSD: Makefile,v 1.3 2007/08/15 22:13:16 pooka Exp $ # +.include + LIB= rumpuser SRCS= rumpuser.c -NOPIC= # defined -MKLINT= no -MKPROFILE= no -WARNS= 4 -DBG= -O0 -g +RUMPKERNEL= no +.include "${NETBSDSRCDIR}/sys/rump/Makefile.rump" .include diff --git a/sys/rump/librump/rumpuser/rumpuser.c b/sys/rump/librump/rumpuser/rumpuser.c index b315fd2dd51c..c89b484a044f 100644 --- a/sys/rump/librump/rumpuser/rumpuser.c +++ b/sys/rump/librump/rumpuser/rumpuser.c @@ -1,4 +1,4 @@ -/* $NetBSD: rumpuser.c,v 1.4 2007/08/07 20:40:53 pooka Exp $ */ +/* $NetBSD: rumpuser.c,v 1.5 2007/08/15 22:13:16 pooka Exp $ */ /* * Copyright (c) 2007 Antti Kantee. All Rights Reserved. @@ -27,6 +27,8 @@ * SUCH DAMAGE. */ +#define malloc(a) __real_malloc(a) + #include #include #include @@ -36,6 +38,7 @@ #include #include #include +#include #include #include "rumpuser.h" @@ -76,6 +79,9 @@ _rumpuser_malloc(size_t howmuch, int canfail, const char *func, int line) abort(); } + if (rv) + memset(rv, 0, howmuch); + return rv; }