minix/servers/vm/sanitycheck.h
Ben Gras c78250332d let vm use physically fragmented memory for allocations.
map_copy_ph_block is replaced by map_clone_ph_block, which can
replace a single physical block by multiple physical blocks.

also,
 . merge map_mem.c with region.c, as they manipulate the same
   data structures
 . NOTRUNNABLE removed as sanity check
 . use direct functions for ALLOC_MEM and FREE_MEM again
 . add some checks to shared memory mapping code
 . fix for data structure integrity when using shared memory
 . fix sanity checks
2010-04-12 11:25:24 +00:00

63 lines
1.4 KiB
C

#ifndef _SANITYCHECK_H
#define _SANITYCHECK_H 1
#include <assert.h>
#include "vm.h"
#include "glo.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\n", file, line, #c); \
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; \
vm_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 | VMF_HASPT)) == \
(VMF_INUSE | VMF_HASPT)) { \
PT_SANE(&vmpr->vm_pt); \
} \
} \
map_sanitycheck(__FILE__, __LINE__); \
vm_assert(incheck == 1); \
incheck = 0; \
}
#include "kernel/proc.h"
#define USE(obj, code) do { \
slabunlock(obj, sizeof(*obj)); \
do { \
code \
} while(0); \
slablock(obj, sizeof(*obj)); \
} while(0)
#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
#define SLABSANITYCHECK(l)
#define USE(obj, code) do { code } while(0)
#define SLABSANE(ptr)
#endif
#endif