aboutsummaryrefslogtreecommitdiff
path: root/include/odp/api/abi-default/align.h
blob: c1150febe5820fee1d5e3481f32deab111cc2215 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Copyright (c) 2015-2018, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier:     BSD-3-Clause
 */

/**
 * @file
 *
 * ODP alignments
 */

#ifndef ODP_ABI_ALIGN_H_
#define ODP_ABI_ALIGN_H_

#ifdef __cplusplus
extern "C" {
#endif

#include <odp/api/abi/cpu.h>

/** @ingroup odp_compiler_optim
 *  @{
 */

#ifdef __GNUC__

#define ODP_ALIGNED(x) __attribute__((__aligned__(x)))

#define ODP_PACKED __attribute__((__packed__))

#define ODP_OFFSETOF(type, member) __builtin_offsetof(type, member)

#define ODP_FIELD_SIZEOF(type, member) sizeof(((type *)0)->member)

#else
#error Non-gcc compatible compiler
#endif

/* ODP_CACHE_LINE_SIZE is defined in odp/api/abi/cpu.h */

#define ODP_PAGE_SIZE       4096

#define ODP_ALIGNED_CACHE   ODP_ALIGNED(ODP_CACHE_LINE_SIZE)

#define ODP_ALIGNED_PAGE    ODP_ALIGNED(ODP_PAGE_SIZE)

/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif