vm, kernel, top: report memory usage of vm, kernel
[minix.git] / servers / vm / sanitycheck.h
blob14162030b09300cf66fcb0671254a5fe8164ee1c
1 #ifndef _SANITYCHECK_H
2 #define _SANITYCHECK_H 1
4 #include <assert.h>
6 #include "vm.h"
8 #if SANITYCHECKS
10 /* This macro is used in the sanity check functions, where file and
11 * line are function arguments.
13 #define MYASSERT(c) do { if(!(c)) { \
14 printf("VM:%s:%d: %s failed (last sanity check %s:%d)\n", file, line, #c, sc_lastfile, sc_lastline); \
15 panic("sanity check failed"); } } while(0)
17 #define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
18 slab_sanitycheck(__FILE__, __LINE__); }
20 #define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
21 struct vmproc *vmpr; \
22 assert(incheck == 0); \
23 incheck = 1; \
24 usedpages_reset(); \
25 slab_sanitycheck(__FILE__, __LINE__); \
26 for(vmpr = vmproc; vmpr < &vmproc[VMP_NR]; vmpr++) { \
27 if((vmpr->vm_flags & (VMF_INUSE))) { \
28 PT_SANE(&vmpr->vm_pt); \
29 } \
30 } \
31 map_sanitycheck(__FILE__, __LINE__); \
32 mem_sanitycheck(__FILE__, __LINE__); \
33 assert(incheck == 1); \
34 incheck = 0; \
35 /* printf("(%s:%d OK) ", __FILE__, __LINE__); */ \
36 sc_lastfile = __FILE__; sc_lastline = __LINE__; \
39 #define SLABSANE(ptr) { \
40 if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
41 printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
42 panic("SLABSANE failed"); \
43 } \
46 #else
47 #define SANITYCHECK(l)
48 #define SLABSANITYCHECK(l)
49 #define SLABSANE(ptr)
50 #endif
52 #if MEMPROTECT
53 #define USE(obj, code) do { \
54 slabunlock(obj, sizeof(*obj)); \
55 do { \
56 code \
57 } while(0); \
58 slablock(obj, sizeof(*obj)); \
59 } while(0)
60 #else
61 #define USE(obj, code) do { code } while(0)
62 #endif
64 #endif