diff options
Diffstat (limited to 'src/magic.h')
-rw-r--r-- | src/magic.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/magic.h b/src/magic.h new file mode 100644 index 0000000..15eacee --- /dev/null +++ b/src/magic.h @@ -0,0 +1,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 |