7 * (C) Copyright 2010-2011 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Dual LGPL v2.1/GPL v2 license.
15 * Align pointer on natural object alignment.
17 #define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
18 #define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
21 * offset_align - Calculate the offset needed to align an object on its natural
22 * alignment towards higher addresses.
23 * @align_drift: object offset from an "alignment"-aligned address.
24 * @alignment: natural object alignment. Must be non-zero, power of 2.
26 * Returns the offset that must be added to align towards higher
29 #define offset_align(align_drift, alignment) \
31 BUILD_RUNTIME_BUG_ON((alignment) == 0 \
32 || ((alignment) & ((alignment) - 1))); \
33 (((alignment) - (align_drift)) & ((alignment) - 1)); \
37 * offset_align_floor - Calculate the offset needed to align an object
38 * on its natural alignment towards lower addresses.
39 * @align_drift: object offset from an "alignment"-aligned address.
40 * @alignment: natural object alignment. Must be non-zero, power of 2.
42 * Returns the offset that must be substracted to align towards lower addresses.
44 #define offset_align_floor(align_drift, alignment) \
46 BUILD_RUNTIME_BUG_ON((alignment) == 0 \
47 || ((alignment) & ((alignment) - 1))); \
48 (((align_drift) - (alignment)) & ((alignment) - 1); \
51 #endif /* _UST_ALIGN_H */
This page took 0.030617 seconds and 5 git commands to generate.