summaryrefslogtreecommitdiff
path: root/macros.h
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-09-08 12:48:26 +0000
committertron <tron@openttd.org>2005-09-08 12:48:26 +0000
commitc20b5883bd7e917dee83367eeea9e795d16bfc63 (patch)
tree3f41cacc0471e60af369fc95349585751ff00335 /macros.h
parent0f08a1c69421f2d0ec718d8b53404c53fb65606a (diff)
downloadopenttd-c20b5883bd7e917dee83367eeea9e795d16bfc63.tar.xz
(svn r2924) Introduce the ALIGN() macro which aligns values to multiples of a power of 2, for exact semantics see the commment in macros.h
Diffstat (limited to 'macros.h')
-rw-r--r--macros.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/macros.h b/macros.h
index 1232005cd..26c4d9985 100644
--- a/macros.h
+++ b/macros.h
@@ -158,6 +158,12 @@ static inline void swap_tile(TileIndex *a, TileIndex *b) { TileIndex t = *a; *a
#define ROL(x, n) ((x) << (n) | (x) >> (sizeof(x) * 8 - (n)))
#define ROR(x, n) ((x) >> (n) | (x) << (sizeof(x) * 8 - (n)))
+/**
+ * Return the smallest multiple of n equal or greater than x
+ * @note n must be a power of 2
+ */
+#define ALIGN(x, n) (((x) + (n) - 1) & ~((n) - 1))
+
/* IS_INT_INSIDE = filter for ascii-function codes like BELL and so on [we need an special filter here later] */
static inline bool IsValidAsciiChar(byte key)
{