7 * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
10 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
12 * Permission is hereby granted to use or copy this program
13 * for any purpose, provided the above notices are retained on all copies.
14 * Permission to modify the code and to distribute modified code is granted,
15 * provided the above notices are retained, and a notice that the code was
16 * modified is included with the above copyright notice.
19 #include <lttng/bug.h>
22 #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
23 #define PAGE_MASK (~(PAGE_SIZE - 1))
24 #define __ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
25 #define ALIGN(v, align) __ALIGN_MASK(v, (typeof(v)) (align) - 1)
26 #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
29 * offset_align - Calculate the offset needed to align an object on its natural
30 * alignment towards higher addresses.
31 * @align_drift: object offset from an "alignment"-aligned address.
32 * @alignment: natural object alignment. Must be non-zero, power of 2.
34 * Returns the offset that must be added to align towards higher
37 #define offset_align(align_drift, alignment) \
39 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
40 || ((alignment) & ((alignment) - 1))); \
41 (((alignment) - (align_drift)) & ((alignment) - 1)); \
45 * offset_align_floor - Calculate the offset needed to align an object
46 * on its natural alignment towards lower addresses.
47 * @align_drift: object offset from an "alignment"-aligned address.
48 * @alignment: natural object alignment. Must be non-zero, power of 2.
50 * Returns the offset that must be substracted to align towards lower addresses.
52 #define offset_align_floor(align_drift, alignment) \
54 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
55 || ((alignment) & ((alignment) - 1))); \
56 (((align_drift) - (alignment)) & ((alignment) - 1); \
59 #endif /* _UST_ALIGN_H */
This page took 0.029391 seconds and 4 git commands to generate.