LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
osal_mem_align.h
Go to the documentation of this file.
1#ifndef LEXLEO_OSAL_MEM_ALIGN_H
2#define LEXLEO_OSAL_MEM_ALIGN_H
3
5
6#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
7 #include <stdalign.h>
8 #define OSAL_ALIGNOF_MAX alignof(max_align_t)
9 #define OSAL_ALIGNED_MAX _Alignas(max_align_t)
10#else
11 #if defined(_MSC_VER)
12 #define OSAL_ALIGNOF_MAX 16
13 #define OSAL_ALIGNED_MAX __declspec(align(16))
14 #else
15 #define OSAL_ALIGNOF_MAX 16
16 #define OSAL_ALIGNED_MAX __attribute__((aligned(16)))
17 #endif
18#endif
19
20/* Return the smallest multiple of `a` greater than or equal to `x`.
21 * `a` must be a power of 2 (an alignment value).
22 */
23#ifndef OSAL_ALIGN_UP
24 #define OSAL_ALIGN_UP(x, a) (((x) + (a) - 1) & ~((a) - 1))
25#endif
26
27#endif // LEXLEO_OSAL_MEM_ALIGN_H