]> mj.ucw.cz Git - libucw.git/blobdiff - lib/lib.h
Allow locked dirty pages. Better debugging. Simplified and cleaned up
[libucw.git] / lib / lib.h
index 9b169d7a6255718c02ed518d2a5ae2f0388cb060..72337d93ea93b5118cd0aa180ce06ab174b1540d 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -9,6 +9,12 @@
 
 #include <lib/config.h>
 
+/* 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);