2 * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 * SPDX-License-Identifier: MIT
15 #ifndef PAGE_SIZE /* Cygwin limits.h defines its own PAGE_SIZE. */
16 #define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
21 * Align value to the next multiple of align. Returns val if it already is a
22 * multiple of align. Align must be a power of two.
24 #define __lttng_align_ceil_mask(v, mask) (((v) + (mask)) & ~(mask))
26 #define lttng_align_ceil(v, align) \
27 __lttng_align_ceil_mask(v, (__typeof__(v)) (align) - 1)
30 * Align value to the previous multiple of align. Returns val if it already is a
31 * multiple of align. Align must be a power of two.
33 #define __lttng_align_floor_mask(v, mask) ((v) & ~(mask))
35 #define lttng_align_floor(v, align) \
36 __lttng_align_floor_mask(v, (__typeof__(v)) (align) - 1)
39 * lttng_offset_align - Calculate the offset needed to align an object on its natural
40 * alignment towards higher addresses.
41 * @align_drift: object offset from an "alignment"-aligned address.
42 * @alignment: natural object alignment. Must be non-zero, power of 2.
44 * Returns the offset that must be added to align towards higher
47 #define lttng_offset_align(align_drift, alignment) \
49 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
50 || ((alignment) & ((alignment) - 1))); \
51 (((alignment) - (align_drift)) & ((alignment) - 1)); \
55 * lttng_offset_align_floor - Calculate the offset needed to align an object
56 * on its natural alignment towards lower addresses.
57 * @align_drift: object offset from an "alignment"-aligned address.
58 * @alignment: natural object alignment. Must be non-zero, power of 2.
60 * Returns the offset that must be substracted to align towards lower addresses.
62 #define lttng_offset_align_floor(align_drift, alignment) \
64 LTTNG_BUILD_RUNTIME_BUG_ON((alignment) == 0 \
65 || ((alignment) & ((alignment) - 1))); \
66 (((align_drift) - (alignment)) & ((alignment) - 1)); \
69 #endif /* _LTTNG_ALIGN_H */
This page took 0.048813 seconds and 5 git commands to generate.