From: Martin Mares Date: Mon, 8 Nov 1999 23:29:40 +0000 (+0000) Subject: Moved OFFSETOF etc. here. Added ASSERT. X-Git-Tag: holmes-import~1660 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=6d7178ea1076853600a368596ad8505d438f7251;p=libucw.git Moved OFFSETOF etc. here. Added ASSERT. --- diff --git a/lib/lib.h b/lib/lib.h index 9b169d7a..72337d93 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -9,6 +9,12 @@ #include +/* Ugly structure handling macros */ + +#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i) +#define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) +#define ALIGN(s, a) (((s)+a-1)&~(a-1)) + /* Temporary Files */ #define TMP_DIR "tmp" @@ -61,6 +67,12 @@ void die(byte *, ...) NONRET; void initlog(byte *); void open_log_file(byte *); +#ifdef DEBUG +#define ASSERT(x) do { if (!(x)) die("Assertion `%s' failed at %s:%d", #x, __FILE__, __LINE__); } while(0) +#else +#define ASSERT(x) do { } while(0) +#endif + /* Allocation */ void *xmalloc(uns);