summaryrefslogtreecommitdiff
path: root/minix/servers/vm/sanitycheck.h
blob: f353d9b3acf03a8bdd91fac88d5f69feac156dfd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef _SANITYCHECK_H
#define _SANITYCHECK_H 1

#include <assert.h>

#include "vm.h"

#if SANITYCHECKS

#define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }

/* 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(_minix_kerninfo) { \
	slab_sanitycheck(__FILE__, __LINE__); }

#define SANITYCHECK(l) if(!nocheck && _minix_kerninfo && 0) {  \
		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)
#define PT_SANE(p)
#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