summaryrefslogtreecommitdiff
path: root/src/magic.h
blob: 15eaceef430f03573ac29fdd195e5b1ca246dcf8 (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
/**
 * @file magic.h  Interface to magic macros
 *
 * Copyright (C) 2010 Creytiv.com
 */


#ifndef RELEASE

#ifndef MAGIC
#error "macro MAGIC must be defined"
#endif

/** Check magic number */
#define MAGIC_DECL uint32_t magic;
#define MAGIC_INIT(s) (s)->magic = MAGIC
#define MAGIC_CHECK(s) \
	if (MAGIC != s->magic) {					\
		warning("%s: wrong magic struct=%p (magic=0x%08x)\n",	\
			__FUNCTION__, s, s->magic);			\
		BREAKPOINT;						\
	}
#else
#define MAGIC_DECL
#define MAGIC_INIT(s)
#define MAGIC_CHECK(s) do {(void)(s);} while (0);
#endif