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 * Align pointer on natural object alignment.
24 #define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj)))
25 #define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj)))
28 * offset_align - Calculate the offset needed to align an object on its natural
29 * alignment towards higher addresses.
30 * @align_drift: object offset from an "alignment"-aligned address.
31 * @alignment: natural object alignment. Must be non-zero, power of 2.
33 * Returns the offset that must be added to align towards higher
36 #define offset_align(align_drift, alignment) \
38 BUILD_RUNTIME_BUG_ON((alignment) == 0 \
39 || ((alignment) & ((alignment) - 1))); \
40 (((alignment) - (align_drift)) & ((alignment) - 1)); \
44 * offset_align_floor - Calculate the offset needed to align an object
45 * on its natural alignment towards lower addresses.
46 * @align_drift: object offset from an "alignment"-aligned address.
47 * @alignment: natural object alignment. Must be non-zero, power of 2.
49 * Returns the offset that must be substracted to align towards lower addresses.
51 #define offset_align_floor(align_drift, alignment) \
53 BUILD_RUNTIME_BUG_ON((alignment) == 0 \
54 || ((alignment) & ((alignment) - 1))); \
55 (((align_drift) - (alignment)) & ((alignment) - 1); \
58 #endif /* _UST_ALIGN_H */
This page took 0.030442 seconds and 4 git commands to generate.