diff options
author | Nanley Chery <[email protected]> | 2015-06-02 11:03:22 -0700 |
---|---|---|
committer | Nanley Chery <[email protected]> | 2015-08-26 14:36:43 -0700 |
commit | 54d2aa4258f0bfcc669b2bc4e82332f7ff4876dd (patch) | |
tree | 45ee7c091d883ade5eb2359f10cba70602de7228 /src/mesa/main | |
parent | 97f4efd573aed7ffc0ea9395f4e69ccdeb5041f6 (diff) |
mesa/macros: move ALIGN_NPOT to macros.h
Aligning with a non-power-of-two number is a general task that can be used in
various places. This commit is required for the next one.
v2: add greater than 0 assertion (Anuj).
convert the macro to a static inline function.
Reviewed-by: Anuj Phogat <[email protected]>
Signed-off-by: Nanley Chery <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/macros.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index c3ef42a4282..ed207d44a64 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -698,6 +698,16 @@ ALIGN(uintptr_t value, int32_t alignment) } /** + * Like ALIGN(), but works with a non-power-of-two alignment. + */ +static inline uintptr_t +ALIGN_NPOT(uintptr_t value, int32_t alignment) +{ + assert(alignment > 0); + return (value + alignment - 1) / alignment * alignment; +} + +/** * Align a value down to an alignment value * * If \c value is not already aligned to the requested alignment value, it |