vm: allow split of mem_anon_contig region
[minix3.git] / minix / servers / vm / sanitycheck.h
blobf353d9b3acf03a8bdd91fac88d5f69feac156dfd
1 #ifndef _SANITYCHECK_H
2 #define _SANITYCHECK_H 1
4 #include <assert.h>
6 #include "vm.h"
8 #if SANITYCHECKS
10 #define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }
12 /* This macro is used in the sanity check functions, where file and
13 * line are function arguments.
15 #define MYASSERT(c) do { if(!(c)) { \
16 printf("VM:%s:%d: %s failed (last sanity check %s:%d)\n", file, line, #c, sc_lastfile, sc_lastline); \
17 panic("sanity check failed"); } } while(0)
19 #define SLABSANITYCHECK(l) if(_minix_kerninfo) { \
20 slab_sanitycheck(__FILE__, __LINE__); }
22 #define SANITYCHECK(l) if(!nocheck && _minix_kerninfo && 0) { \
23 struct vmproc *vmpr; \
24 assert(incheck == 0); \
25 incheck = 1; \
26 usedpages_reset(); \
27 slab_sanitycheck(__FILE__, __LINE__); \
28 for(vmpr = vmproc; vmpr < &vmproc[VMP_NR]; vmpr++) { \
29 if((vmpr->vm_flags & (VMF_INUSE))) { \
30 PT_SANE(&vmpr->vm_pt); \
31 } \
32 } \
33 map_sanitycheck(__FILE__, __LINE__); \
34 mem_sanitycheck(__FILE__, __LINE__); \
35 assert(incheck == 1); \
36 incheck = 0; \
37 /* printf("(%s:%d OK) ", __FILE__, __LINE__); */ \
38 sc_lastfile = __FILE__; sc_lastline = __LINE__; \
41 #define SLABSANE(ptr) { \
42 if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
43 printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
44 panic("SLABSANE failed"); \
45 } \
48 #else
49 #define SANITYCHECK(l)
50 #define SLABSANITYCHECK(l)
51 #define SLABSANE(ptr)
52 #define MYASSERT(c)
53 #define PT_SANE(p)
54 #endif
56 #if MEMPROTECT
57 #define USE(obj, code) do { \
58 slabunlock(obj, sizeof(*obj)); \
59 do { \
60 code \
61 } while(0); \
62 slablock(obj, sizeof(*obj)); \
63 } while(0)
64 #else
65 #define USE(obj, code) do { code } while(0)
66 #endif
68 #endif