From: Mathieu Desnoyers Date: Tue, 5 Nov 2019 23:56:34 +0000 (-0500) Subject: align.h: Implement ALIGN_FLOOR macro X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=d4ad24a314cea1020c7cd08b27670f5da495e38d align.h: Implement ALIGN_FLOOR macro 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 Change-Id: I36d981e8fb705fafa3ff23ba2d82ec1babe73e45 Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/align.h b/src/common/align.h index ed353206d..c8d9d5176 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) /**