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 <anuj.phogat@gmail.com>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
#define INTEL_UPLOAD_SIZE (64*1024)
-/**
- * Like ALIGN(), but works with a non-power-of-two alignment.
- */
-#define ALIGN_NPOT(value, alignment) \
- (((value) + (alignment) - 1) / (alignment) * (alignment))
-
void
intel_upload_finish(struct brw_context *brw)
{
return (((value) + (alignment) - 1) & ~((alignment) - 1));
}
+/**
+ * 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
*