Move the CTASSERT macro from MD code to systm.h alongside KASSERT so other
code can use it. This takes a single constant argument and fails to compile if it is 0 (false). The main application of this is to make assertions about structure sizes at compile time, in order to validate assumptions made in other code. Examples: CTASSERT(sizeof(struct foo) == FOO_SIZEOF); CTASSERT(sizeof(struct foo) == (1 << FOO_SHIFT)); Requested by: jhb, phk
This commit is contained in:
parent
657544fc48
commit
d86b2422b9
@ -176,9 +176,5 @@
|
||||
|
||||
#define pgtok(x) ((unsigned long)(x) * (PAGE_SIZE / 1024))
|
||||
|
||||
#define CTASSERT(x) _CTASSERT(x, __LINE__)
|
||||
#define _CTASSERT(x, y) __CTASSERT(x, y)
|
||||
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
|
||||
|
||||
#endif /* !_MACHINE_PARAM_H_ */
|
||||
#endif /* !_NO_NAMESPACE_POLLUTION */
|
||||
|
@ -78,6 +78,10 @@ extern int maxusers; /* system tune hint */
|
||||
#define KASSERT(exp,msg)
|
||||
#endif
|
||||
|
||||
#define CTASSERT(x) _CTASSERT(x, __LINE__)
|
||||
#define _CTASSERT(x, y) __CTASSERT(x, y)
|
||||
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
|
||||
|
||||
/*
|
||||
* XXX the hints declarations are even more misplaced than most declarations
|
||||
* in this file, since they are needed in one file (per arch) and only used
|
||||
|
Loading…
x
Reference in New Issue
Block a user