aboutsummaryrefslogtreecommitdiff
path: root/common/util.h
diff options
context:
space:
mode:
authorMax Horn2009-03-19 21:43:27 +0000
committerMax Horn2009-03-19 21:43:27 +0000
commite59b4587b706bb91b7875b4675cfdcdf68ae493c (patch)
tree1a77d3e46c254f9e6298dfaac1768b21093ed3f8 /common/util.h
parent428b0ec80023361b7079759b5767647d1024be57 (diff)
downloadscummvm-rg350-e59b4587b706bb91b7875b4675cfdcdf68ae493c.tar.gz
scummvm-rg350-e59b4587b706bb91b7875b4675cfdcdf68ae493c.tar.bz2
scummvm-rg350-e59b4587b706bb91b7875b4675cfdcdf68ae493c.zip
COMMON: Added a new IS_ALIGNED macro (for now using size_t, we can change it if this turns out to be not portable enough. Also added a doxygen comment to the ARRAYSIZE macro
svn-id: r39542
Diffstat (limited to 'common/util.h')
-rw-r--r--common/util.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/common/util.h b/common/util.h
index 18f1b70c52..3b2a705d6c 100644
--- a/common/util.h
+++ b/common/util.h
@@ -28,6 +28,15 @@
#include "common/scummsys.h"
#include "common/str.h"
+
+/**
+ * Check whether a given pointer is aligned correctly.
+ * Note that 'alignment' must be a power of two!
+ */
+#define IS_ALIGNED(value, alignment) \
+ ((((size_t)value) & ((alignment) - 1)) == 0)
+
+
#ifdef MIN
#undef MIN
#endif
@@ -47,6 +56,9 @@ template<typename T> inline T CLIP (T v, T amin, T amax)
*/
template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
+/**
+ * Macro which determines the number of entries in a fixed size array.
+ */
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))