A few related changes here. Make pool flags the same as malloc flags with
the same behavior. Give every flag a real value, so nobody screws up
trying to test for a 0 flag. Assert that one of the wait ok or not flags
is specified.
Index: kern/kern_malloc.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/kern/kern_malloc.c,v
retrieving revision 1.84
diff -u -r1.84 kern_malloc.c
--- kern/kern_malloc.c 22 Jul 2010 06:30:13 -0000 1.84
+++ kern/kern_malloc.c 9 Sep 2010 23:36:20 -0000
@@ -191,6 +191,8 @@
panic("malloc - bogus type");
#endif
+ KASSERT(flags & (M_WAITOK | M_NOWAIT));
+
#ifdef MALLOC_DEBUG
if (debug_malloc(size, type, flags, (void **)&va)) {
if ((flags & M_ZERO) && va != NULL)
Index: kern/subr_pool.c
===================================================================
RCS file: /home/tedu/cvs/src/sys/kern/subr_pool.c,v
retrieving revision 1.96
diff -u -r1.96 subr_pool.c
--- kern/subr_pool.c 3 Jul 2010 03:04:55 -0000 1.96
+++ kern/subr_pool.c 9 Sep 2010 23:36:20 -0000
@@ -453,6 +453,8 @@
{
void *v;
+ KASSERT(flags & (PR_WAITOK | PR_NOWAIT));
+
#ifdef DIAGNOSTIC
if ((flags & PR_WAITOK) != 0)
splassert(IPL_NONE);
Index: sys/malloc.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/sys/malloc.h,v
retrieving revision 1.97
diff -u -r1.97 malloc.h
--- sys/malloc.h 14 Jul 2010 10:31:54 -0000 1.97
+++ sys/malloc.h 9 Sep 2010 23:36:20 -0000
@@ -52,10 +52,10 @@
/*
* flags to malloc
*/
-#define M_WAITOK 0x0000
-#define M_NOWAIT 0x0001
-#define M_CANFAIL 0x0002
-#define M_ZERO 0x0004
+#define M_WAITOK 0x0001
+#define M_NOWAIT 0x0002
+#define M_CANFAIL 0x0004
+#define M_ZERO 0x0008
/*
* Types of memory to be allocated
Index: sys/pool.h
===================================================================
RCS file: /home/tedu/cvs/src/sys/sys/pool.h,v
retrieving revision 1.35
diff -u -r1.35 pool.h
--- sys/pool.h 13 Jul 2010 16:47:02 -0000 1.35
+++ sys/pool.h 9 Sep 2010 23:40:53 -0000
@@ -91,15 +91,14 @@
const char *pr_wchan; /* tsleep(9) identifier */
unsigned int pr_flags; /* r/w flags */
unsigned int pr_roflags; /* r/o flags */
-#define PR_MALLOCOK 0x01
-#define PR_NOWAIT 0x00 /* for symmetry */
-#define PR_WAITOK 0x02
-#define PR_WANTED 0x04
-#define PR_PHINPAGE 0x08
-#define PR_LOGGING 0x10
-#define PR_LIMITFAIL 0x20 /* even if waiting, fail if we hit limit */
-#define PR_DEBUG 0x40
-#define PR_ZERO 0x100
+#define PR_WAITOK 0x0001 /* M_WAITOK */
+#define PR_NOWAIT 0x0002 /* M_NOWAIT */
+#define PR_LIMITFAIL 0x0004 /* M_CANFAIL */
+#define PR_ZERO 0x0008 /* M_ZERO */
+#define PR_WANTED 0x0100
+#define PR_PHINPAGE 0x0200
+#define PR_LOGGING 0x0400
+#define PR_DEBUG 0x0800
int pr_ipl;