Subject: MALLOC_JUSTDEFINE
To: None <tech-kern@netbsd.org>
From: Antti Kantee <pooka@cs.hut.fi>
List: tech-kern
Date: 03/27/2007 12:28:42
malloc(9) doesn't currently allow to define a type without adding it
to the link set for boot time kmem init. This creates an extra #ifdef
_LKM and a separate code path for those subsystems which run their own
init routine at attach-time anyway and could call malloc_type_attach()
un-#ifdef'd.
So I propose MALLOC_JUSTDEFINE, which defines the type but doesn't add
it to the link set. Any opposed?
Index: mallocvar.h
===================================================================
RCS file: /cvsroot/src/sys/sys/mallocvar.h,v
retrieving revision 1.5
diff -u -r1.5 mallocvar.h
--- mallocvar.h 27 Aug 2006 22:20:42 -0000 1.5
+++ mallocvar.h 27 Mar 2007 09:17:36 -0000
@@ -60,7 +60,7 @@
};
#ifdef _KERNEL
-#define MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, limit) \
+#define MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit) \
struct malloc_type type[1] = { \
{ NULL, M_MAGIC, shortdesc, \
0, /* ks_inuse */ \
@@ -72,8 +72,14 @@
limit, /* ks_limit */ \
0, /* ks_size */ \
0, /* ks_spare */ } \
-}; \
-__link_set_add_data(malloc_types, type)
+};
+
+#define MALLOC_JUSTDEFINE(type, shortdesc, longdesc) \
+ MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, 0)
+
+#define MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, limit) \
+ MALLOC_JUSTDEFINE_LIMIT(type, shortdesc, longdesc, limit) \
+ __link_set_add_data(malloc_types, type)
#define MALLOC_DEFINE(type, shortdesc, longdesc) \
MALLOC_DEFINE_LIMIT(type, shortdesc, longdesc, 0)
--
Antti Kantee <pooka@iki.fi> Of course he runs NetBSD
http://www.iki.fi/pooka/ http://www.NetBSD.org/
"la qualité la plus indispensable du cuisinier est l'exactitude"