Move internal headers to 'src/' dir
[lttng-ust.git] / src / common / align.h
1 /*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (C) 2010-2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 */
6
7 #ifndef _UST_COMMON_ALIGN_H
8 #define _UST_COMMON_ALIGN_H
9
10 #include <unistd.h>
11 #include <limits.h>
12
13 #ifdef __FreeBSD__
14 #include <machine/param.h>
15 #endif
16
17 #ifdef _SC_PAGE_SIZE
18 #define LTTNG_UST_PAGE_SIZE sysconf(_SC_PAGE_SIZE)
19 #elif defined(PAGE_SIZE)
20 #define LTTNG_UST_PAGE_SIZE PAGE_SIZE
21 #else
22 #error "Please add page size detection for your OS."
23 #endif
24
25 #define LTTNG_UST_PAGE_MASK (~(LTTNG_UST_PAGE_SIZE - 1))
26
27 #define __LTTNG_UST_ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))
28 #define LTTNG_UST_ALIGN(v, align) __LTTNG_UST_ALIGN_MASK(v, (__typeof__(v)) (align) - 1)
29 #define LTTNG_UST_PAGE_ALIGN(addr) LTTNG_UST_ALIGN(addr, LTTNG_UST_PAGE_SIZE)
30
31 #endif /* _UST_COMMON_ALIGN_H */
This page took 0.039313 seconds and 5 git commands to generate.