align.h: Implement ALIGN_FLOOR macro
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 5 Nov 2019 23:56:34 +0000 (18:56 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 19 Dec 2019 22:10:22 +0000 (17:10 -0500)
Implement the ALIGN_FLOOR macro which aligns the given value to the
previous alignment boundary, or keeps the value as-is if it is already
aligned.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I36d981e8fb705fafa3ff23ba2d82ec1babe73e45
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/align.h

index ed353206d1ad03e3d1286414f604041f80538037..c8d9d51766906e15cfe444258778872e0a5ad143 100644 (file)
 #define ALIGN(v, align)                __ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
 #endif
 
+#define __ALIGN_FLOOR_MASK(v, mask)    ((v) & ~(mask))
+
+#ifndef ALIGN_FLOOR
+#define ALIGN_FLOOR(v, align)  __ALIGN_FLOOR_MASK(v, (__typeof__(v)) (align) - 1)
+#endif
+
 #define PAGE_ALIGN(addr)       ALIGN(addr, PAGE_SIZE)
 
 /**
This page took 0.025242 seconds and 4 git commands to generate.