minix/servers/vm/sanitycheck.h
Ben Gras 2dd02cc560 mark pages whose refcount were >1 and drop to 1 and are
read/write writable in the pagetable right away instead of waiting for
a pagefault. minor optimization.

some a sanity check of SLAB-allocated pointers.

vm gets its own _exit and __exit like PM, so the stock (library) panic works.
2009-04-22 12:39:29 +00:00

46 lines
1.3 KiB
C

#ifndef _SANITYCHECK_H
#define _SANITYCHECK_H 1
#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); \
vm_panic("sanity check failed", NO_NUM); } } while(0)
#define SANITYCHECK(l) if(!nocheck && ((l) <= vm_sanitychecklevel)) { \
int failflag = 0; \
u32_t *origptr = CHECKADDR;\
int _sanep; \
struct vmproc *vmp; \
\
for(_sanep = 0; _sanep < sizeof(data1) / sizeof(*origptr); \
_sanep++) { \
if(origptr[_sanep] != data1[_sanep]) { \
printf("%d: %08lx != %08lx ", \
_sanep, origptr[_sanep], data1[_sanep]); failflag = 1; \
} \
} \
if(failflag) { \
printf("%s:%d: memory corruption test failed\n", \
__FILE__, __LINE__); \
vm_panic("memory corruption", NO_NUM); \
} \
for(vmp = vmproc; vmp <= &vmproc[_NR_PROCS]; vmp++) { \
if((vmp->vm_flags & (VMF_INUSE | VMF_HASPT)) == \
(VMF_INUSE | VMF_HASPT)) { \
pt_sanitycheck(&vmp->vm_pt, __FILE__, __LINE__); \
} \
} \
map_sanitycheck(__FILE__, __LINE__); \
}
#else
#define SANITYCHECK
#endif
#endif