]> git.pond.sub.org Git - empserver/blobdiff - include/misc.h
Update copyright notice
[empserver] / include / misc.h
index 06157f16a19fd5c1cfb9bb55d01f8fcdbb011f15..dd18006b7049175f19ce07d5344d988c54f23584 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2014, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2016, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                Ken Stevens, Steve McClure, Markus Armbruster
  *
  *  Empire is free software: you can redistribute it and/or modify
@@ -52,7 +52,7 @@
 #endif
 
 #ifndef bit
-#define bit(x)         (1<<(x))
+#define bit(x)         (1U<<(x))
 #endif
 
 #define minutes(x)     (60*(x))
@@ -60,8 +60,8 @@
 #define days(x)                (60*60*24*(x))
 
 /*
- * If EXPR is true, an internal error occured.
- * Return EXPR != 0.
+ * If @expr is true, an internal error occured.
+ * Return @expr != 0.
  * Usage: if (CANT_HAPPEN(...)) <recovery code>;
  */
 #define CANT_HAPPEN(expr) ((expr) ? oops(#expr, __FILE__, __LINE__), 1 : 0)
 extern void oops(char *, char *, int);
 extern void (*oops_handler)(void);
 
+/*
+ * Assert constant expression @cond, return 1.
+ * If @cond is zero, force a compilation error.
+ */
+#define BUILD_ASSERT_ONE(cond) \
+    (sizeof(char[1 - 2 * !(cond)]))
+
+/*
+ * Assert constant expression @cond.
+ * If @cond is zero, force a compilation error.
+ */
+#define BUILD_ASSERT(cond) \
+    ((void)BUILD_ASSERT_ONE(cond))
+
 void exit_nomem(void) ATTRIBUTE((noreturn));
 
        /* return codes from command routines */