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
This commit is contained in:
parent
428b0ec800
commit
e59b4587b7
2 changed files with 14 additions and 2 deletions
|
@ -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])))
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue