2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 #ifndef _LTTNG_UST_ALIGN_H
8 #define _LTTNG_UST_ALIGN_H
10 #include <lttng/ust-bug.h>
13 * lttng_ust_offset_align - Calculate the offset needed to align an object on
14 * its natural alignment towards higher addresses.
15 * @align_drift: object offset from an "alignment"-aligned address.
16 * @alignment: natural object alignment. Must be non-zero, power of 2.
18 * Returns the offset that must be added to align towards higher
21 #define lttng_ust_offset_align(align_drift, alignment) \
23 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
24 || ((alignment) & ((alignment) - 1))); \
25 (((alignment) - (align_drift)) & ((alignment) - 1)); \
29 * lttng_ust_offset_align_floor - Calculate the offset needed to align an
30 * object on its natural alignment towards lower 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 substracted to align towards lower addresses.
36 #define lttng_ust_offset_align_floor(align_drift, alignment) \
38 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
39 || ((alignment) & ((alignment) - 1))); \
40 (((align_drift) - (alignment)) & ((alignment) - 1)); \
43 #endif /* _LTTNG_UST_ALIGN_H */
This page took 0.032887 seconds and 4 git commands to generate.