Make VM fix up memory for kernel that crosses region boundaries
[minix.git] / servers / vm / sanitycheck.h
bloba0a67729e90a2bc0a551c750983b20a2d97b8a6b
1 #ifndef _SANITYCHECK_H
2 #define _SANITYCHECK_H 1
4 #include "vm.h"
5 #include "glo.h"
7 #if SANITYCHECKS
9 /* This macro is used in the sanity check functions, where file and
10 * line are function arguments.
12 #define MYASSERT(c) do { if(!(c)) { \
13 printf("VM:%s:%d: %s failed\n", file, line, #c); \
14 vm_panic("sanity check failed", NO_NUM); } } while(0)
16 #define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
17 slab_sanitycheck(__FILE__, __LINE__); }
19 #define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
20 struct vmproc *vmp; \
21 vm_assert(incheck == 0); \
22 incheck = 1; \
23 usedpages_reset(); \
24 slab_sanitycheck(__FILE__, __LINE__); \
25 for(vmp = vmproc; vmp < &vmproc[VMP_NR]; vmp++) { \
26 if((vmp->vm_flags & (VMF_INUSE | VMF_HASPT)) == \
27 (VMF_INUSE | VMF_HASPT)) { \
28 PT_SANE(&vmp->vm_pt); \
29 } \
30 } \
31 map_sanitycheck(__FILE__, __LINE__); \
32 vm_assert(incheck == 1); \
33 incheck = 0; \
36 #include "../../kernel/proc.h"
38 #define USE(obj, code) do { \
39 slabunlock(obj, sizeof(*obj)); \
40 do { \
41 code \
42 } while(0); \
43 slablock(obj, sizeof(*obj)); \
44 } while(0)
46 #define SLABSANE(ptr) { \
47 if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
48 printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
49 vm_panic("SLABSANE failed", NO_NUM); \
50 } \
53 #define NOTRUNNABLE(ep) { \
54 struct proc pr; \
55 if(sys_getproc(&pr, ep) != OK) { \
56 vm_panic("VM: sys_getproc failed", ep); \
57 } \
58 if(!pr.p_rts_flags) { \
59 vm_panic("VM: runnable", ep); \
60 } \
63 #else
64 #define SANITYCHECK
65 #define SLABSANITYCHECK(l)
66 #define USE(obj, code) do { code } while(0)
67 #define SLABSANE(ptr)
68 #define NOTRUNNABLE(ep)
69 #endif
71 #endif