From e59b4587b706bb91b7875b4675cfdcdf68ae493c Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 19 Mar 2009 21:43:27 +0000 Subject: 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 --- common/util.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'common/util.h') 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 inline T CLIP (T v, T amin, T amax) */ template 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]))) -- cgit v1.2.3