@@ -43,18 +43,18 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
4343 *
4444 * @internal
4545 */
46- #define _XFA (name , prio ) \
46+ #define _XFA (type , name , prio ) \
4747 NO_SANITIZE_ARRAY \
48- __attribute__((used, section(".xfa." #name "." #prio)))
48+ __attribute__((used, section(".xfa." #name "." #prio))) _Alignas(type) type
4949
5050/**
5151 * @brief helper macro for other XFA_* macros
5252 *
5353 * @internal
5454 */
55- #define _XFA_CONST (name , prio ) \
55+ #define _XFA_CONST (type , name , prio ) \
5656 NO_SANITIZE_ARRAY \
57- __attribute__((used, section(".roxfa." #name "." #prio)))
57+ __attribute__((used, section(".roxfa." #name "." #prio))) _Alignas(type) type
5858
5959/**
6060 * @brief Define a read-only cross-file array
@@ -73,8 +73,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
7373#define XFA_INIT_CONST (type , name ) \
7474 _Pragma("GCC diagnostic push") \
7575 _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
76- _XFA_CONST(name, 0_) type name [0] = {}; \
77- _XFA_CONST(name, 9_) type name ## _end [0] = {}; \
76+ _XFA_CONST(type, name, 0_) name [0] = {}; \
77+ _XFA_CONST(type, name, 9_) name ## _end [0] = {}; \
7878 _Pragma("GCC diagnostic pop") \
7979 extern const unsigned __xfa_dummy
8080
@@ -95,8 +95,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
9595#define XFA_INIT (type , name ) \
9696 _Pragma("GCC diagnostic push") \
9797 _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
98- _XFA(name, 0_) type name [0] = {}; \
99- _XFA(name, 9_) type name ## _end [0] = {}; \
98+ _XFA(type, name, 0_) name [0] = {}; \
99+ _XFA(type, name, 9_) name ## _end [0] = {}; \
100100 _Pragma("GCC diagnostic pop") \
101101 extern const unsigned __xfa_dummy
102102
@@ -136,12 +136,13 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
136136 *
137137 * Add this to the type in a variable definition, e.g.:
138138 *
139- * XFA(driver_params, 0) driver_params_t _onboard = { .pin=42 };
139+ * XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
140140 *
141+ * @param[in] type type of the xfa elements
141142 * @param[in] xfa_name name of the xfa
142143 * @param[in] prio priority within the xfa
143144 */
144- #define XFA (xfa_name , prio ) _XFA(xfa_name, 5_ ## prio)
145+ #define XFA (type , xfa_name , prio ) _XFA(type, xfa_name, 5_ ## prio)
145146
146147/**
147148 * @brief Define variable in read-only cross-file array
@@ -150,12 +151,13 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
150151 *
151152 * Add this to the type in a variable definition, e.g.:
152153 *
153- * XFA(driver_params, 0) driver_params_t _onboard = { .pin=42 };
154+ * XFA(driver_params_t, driver_params, 0) _onboard = { .pin=42 };
154155 *
156+ * @param[in] type type of the xfa elements
155157 * @param[in] xfa_name name of the xfa
156158 * @param[in] prio priority within the xfa
157159 */
158- #define XFA_CONST (xfa_name , prio ) _XFA_CONST(xfa_name, 5_ ## prio)
160+ #define XFA_CONST (type , xfa_name , prio ) _XFA_CONST(type, xfa_name, 5_ ## prio)
159161
160162/**
161163 * @brief Add a pointer to cross-file array
@@ -174,8 +176,8 @@ _Pragma("GCC diagnostic ignored \"-Warray-bounds\"")
174176 * @param[in] entry pointer variable to add to xfa
175177 */
176178#define XFA_ADD_PTR (xfa_name , prio , name , entry ) \
177- _XFA_CONST(xfa_name, 5_ ## prio) \
178- __typeof__(entry) xfa_name ## _ ## prio ## _ ## name = entry
179+ _XFA_CONST(__typeof__(entry), xfa_name, 5_ ## prio) \
180+ xfa_name ## _ ## prio ## _ ## name = entry
179181
180182/**
181183 * @brief Calculate number of entries in cross-file array
0 commit comments