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

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Tue Nov 5 19:55:26 EST 2019


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 at efficios.com>
---
 src/common/align.h | 6 ++++++
 1 file changed, 6 insertions(+)

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)
 #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)
 
 /**
-- 
2.17.1



More information about the lttng-dev mailing list