diff mbox series

[RFC,lttng-tools,2/3] align.h: Implement ALIGN_FLOOR macro

Message ID 20191106005527.7584-2-mathieu.desnoyers@efficios.com
State New
Headers show
Series [RFC,lttng-tools,1/3] Fix: relayd: use packet sequence number for rotation position | expand

Commit Message

Mathieu Desnoyers Nov. 6, 2019, 12:55 a.m. UTC
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

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
 src/common/align.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series


diff --git a/src/common/align.h b/src/common/align.h
index ed353206..c8d9d517 100644
--- a/src/common/align.h
+++ b/src/common/align.h
@@ -35,6 +35,12 @@ 
 #define ALIGN(v, align)		__ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
+#define __ALIGN_FLOOR_MASK(v, mask)	((v) & ~(mask))
+#ifndef ALIGN_FLOOR
+#define ALIGN_FLOOR(v, align)	__ALIGN_FLOOR_MASK(v, (__typeof__(v)) (align) - 1)
 #define PAGE_ALIGN(addr)	ALIGN(addr, PAGE_SIZE)