blob: b8be7f93819b6d68dce7e1b218874c58e555fbc2 (
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) 2018-2018, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/**
* @file
*
* ODP miscellaneous macros
*/
#ifndef ODP_MACROS_INTERNAL_H_
#define ODP_MACROS_INTERNAL_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <odp/api/debug.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MIN(a, b) \
__extension__ ({ \
__typeof__(a) tmp_a = (a); \
__typeof__(b) tmp_b = (b); \
tmp_a < tmp_b ? tmp_a : tmp_b; \
})
#define MAX(a, b) \
__extension__ ({ \
__typeof__(a) tmp_a = (a); \
__typeof__(b) tmp_b = (b); \
tmp_a > tmp_b ? tmp_a : tmp_b; \
})
#define MAX3(a, b, c) (MAX(MAX((a), (b)), (c)))
#define odp_container_of(pointer, type, member) \
((type *)(void *)(((char *)pointer) - offsetof(type, member)))
#define DIV_ROUND_UP(a, b) \
__extension__ ({ \
__typeof__(a) tmp_a = (a); \
__typeof__(b) tmp_b = (b); \
ODP_STATIC_ASSERT(__builtin_constant_p(b), ""); \
ODP_STATIC_ASSERT((((b) - 1) & (b)) == 0, ""); \
(tmp_a + tmp_b - 1) >> __builtin_ctz(tmp_b); \
})
#ifdef __cplusplus
}
#endif
#endif
|