Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
xfa.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
25
#ifndef XFA_H
26
#define XFA_H
27
28
#include <
inttypes.h
>
29
#include "
compiler_hints.h
"
30
31
/*
32
* Unfortunately, current gcc trips over accessing XFA's because of their
33
* zero-size start/end array that are used of symbol markers, with an "array
34
* index out of bounds" warning. So until a solution for that is found, we
35
* need to disable array bounds checks for files using XFAs.
36
*/
37
#ifndef DOXYGEN
38
_Pragma(
"GCC diagnostic ignored \"-Warray-bounds\""
)
39
#endif
40
46
#define _XFA(type, name, prio) \
47
NO_SANITIZE_ARRAY \
48
__attribute__((used, section(".xfa." #name "." #prio))) _Alignas(type) type
49
55
#define _XFA_CONST(type, name, prio) \
56
NO_SANITIZE_ARRAY \
57
__attribute__((used, section(".roxfa." #name "." #prio))) _Alignas(type) type
58
73
#define XFA_INIT_CONST(type, name) \
74
_Pragma("GCC diagnostic push") \
75
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
76
_XFA_CONST(type, name, 0_) name [0] = {}; \
77
_XFA_CONST(type, name, 9_) name ## _end [0] = {}; \
78
_Pragma("GCC diagnostic pop") \
79
extern const unsigned __xfa_dummy
80
95
#define XFA_INIT(type, name) \
96
_Pragma("GCC diagnostic push") \
97
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
98
_XFA(type, name, 0_) name [0] = {}; \
99
_XFA(type, name, 9_) name ## _end [0] = {}; \
100
_Pragma("GCC diagnostic pop") \
101
extern const unsigned __xfa_dummy
102
114
#define XFA_USE_CONST(type, name) \
115
XFA_USE(type, name)
116
128
#define XFA_USE(type, name) \
129
extern type name []; \
130
extern type name ## _end []
131
145
#define XFA(type, xfa_name, prio) _XFA(type, xfa_name, 5_ ## prio)
146
160
#define XFA_CONST(type, xfa_name, prio) _XFA_CONST(type, xfa_name, 5_ ## prio)
161
178
#define XFA_ADD_PTR(xfa_name, prio, name, entry) \
179
_XFA_CONST(__typeof__(entry), xfa_name, 5_ ## prio) \
180
xfa_name ## _ ## prio ## _ ## name = entry
181
185
#define XFA_LEN(type, \
186
name) (((uintptr_t)name ## _end - (uintptr_t)name) / \
187
sizeof(type))
188
189
#ifdef __cplusplus
190
extern
"C"
{
191
#endif
192
/* making externc happy */
193
#ifdef __cplusplus
194
}
195
#endif
196
197
#endif
/* XFA_H */
compiler_hints.h
Common macros and compiler attributes/pragmas configuration.
inttypes.h
Adds include for missing inttype definitions.
Generated on Sat Nov 23 2024 01:58:06 by
1.9.8