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 #ifndef _RF__RF_GENERAL_H_
38 #define _RF__RF_GENERAL_H_
39
40
41
42 #ifdef _KERNEL
43 #include <sys/systm.h>
44 #endif
45
46 #define RF_ERRORMSG(s) printf((s))
47 #define RF_ERRORMSG1(s,a) printf((s), (a))
48 #define RF_ERRORMSG2(s,a,b) printf((s), (a), (b))
49 #define RF_ERRORMSG3(s,a,b,c) printf((s), (a), (b), (c))
50
51 extern char rf_panicbuf[2048];
52 #define RF_PANIC() \
53 do { \
54 snprintf(rf_panicbuf, sizeof rf_panicbuf, \
55 "RAIDframe error at line %d file %s", \
56 __LINE__, __FILE__); \
57 panic(rf_panicbuf); \
58 } while (0)
59
60 #ifdef _KERNEL
61 #ifdef RF_ASSERT
62 #undef RF_ASSERT
63 #endif
64 #ifndef NOASSERT
65 #define RF_ASSERT(_x_) \
66 do { \
67 if (!(_x_)) { \
68 snprintf(rf_panicbuf, sizeof rf_panicbuf, \
69 "RAIDframe error at line %d" \
70 " file %s (failed asserting %s)\n", __LINE__, \
71 __FILE__, #_x_); \
72 panic(rf_panicbuf); \
73 } \
74 } while (0)
75 #else
76 #define RF_ASSERT(x) {}
77 #endif
78 #else
79 #define RF_ASSERT(x) {}
80 #endif
81
82
83 #define RF_MAX(a,b) (((a) > (b)) ? (a) : (b))
84 #define RF_MIN(a,b) (((a) < (b)) ? (a) : (b))
85
86
87 #define RF_DB0_CHECK(a,b) (((b)==0) ? 0 : (a)/(b))
88
89
90 #define RF_GETTIME(_t) microtime(&(_t))
91
92
93
94
95
96
97 #define RF_BZERO(_bp,_b,_l) bzero(_b, _l)
98
99
100
101
102 #define RF_UL(x) ((unsigned long)(x))
103 #define RF_PGMASK RF_UL(NBPG-1)
104 #define RF_BLIP(x) (NBPG - (RF_UL(x) & RF_PGMASK))
105
106
107
108 #define RF_PAGE_ALIGNED(x) ((RF_UL(x) & RF_PGMASK) == 0)
109
110 #ifdef __STDC__
111 #define RF_STRING(_str_) #_str_
112 #else
113 #define RF_STRING(_str_) "_str_"
114 #endif
115
116 #endif