minix/servers/vm/sanitycheck.h
Ben Gras d343041caa VM: make mapping types explicit
Introduce explicit abstractions for different mapping types,
handling the instantiation, forking, pagefaults and freeing of
anonymous memory, direct physical mappings, shared memory and
physically contiguous anonymous memory as separate types, making
region.c more generic.

Also some other genericification like merging the 3 munmap cases
into one.

COW and SMAP safemap code is still implicit in region.c.
2012-10-12 14:52:01 +02:00

66 lines
1.6 KiB
C

#ifndef _SANITYCHECK_H
#define _SANITYCHECK_H 1
#include <assert.h>
#include "vm.h"
#if SANITYCHECKS
/* This macro is used in the sanity check functions, where file and
* line are function arguments.
*/
#define MYASSERT(c) do { if(!(c)) { \
printf("VM:%s:%d: %s failed (last sanity check %s:%d)\n", file, line, #c, sc_lastfile, sc_lastline); \
panic("sanity check failed"); } } while(0)
#define SLABSANITYCHECK(l) if((l) <= vm_sanitychecklevel) { \
slab_sanitycheck(__FILE__, __LINE__); }
#define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
struct vmproc *vmpr; \
assert(incheck == 0); \
incheck = 1; \
usedpages_reset(); \
slab_sanitycheck(__FILE__, __LINE__); \
for(vmpr = vmproc; vmpr < &vmproc[VMP_NR]; vmpr++) { \
if((vmpr->vm_flags & (VMF_INUSE))) { \
PT_SANE(&vmpr->vm_pt); \
} \
} \
map_sanitycheck(__FILE__, __LINE__); \
mem_sanitycheck(__FILE__, __LINE__); \
assert(incheck == 1); \
incheck = 0; \
/* printf("(%s:%d OK) ", __FILE__, __LINE__); */ \
sc_lastfile = __FILE__; sc_lastline = __LINE__; \
}
#define SLABSANE(ptr) { \
if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
panic("SLABSANE failed"); \
} \
}
#else
#define SANITYCHECK(l)
#define SLABSANITYCHECK(l)
#define SLABSANE(ptr)
#define MYASSERT(c)
#endif
#if MEMPROTECT
#define USE(obj, code) do { \
slabunlock(obj, sizeof(*obj)); \
do { \
code \
} while(0); \
slablock(obj, sizeof(*obj)); \
} while(0)
#else
#define USE(obj, code) do { code } while(0)
#endif
#endif