Loading...
Searching...
No Matches
auto_init_utils.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 Otto-von-Guericke-Universität Magdebug
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
27#ifndef AUTO_INIT_UTILS_H
28#define AUTO_INIT_UTILS_H
29
30#include <stdint.h>
31#include "xfa.h"
32#include "macros/xtstr.h"
33#include "modules.h"
34#if IS_USED(MODULE_PREPROCESSOR_SUCCESSOR)
35#include "preprocessor_successor.h"
36#endif
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#ifndef CONFIG_AUTO_INIT_ENABLE_DEBUG
46#define CONFIG_AUTO_INIT_ENABLE_DEBUG 0
47#endif
48
52typedef void (*auto_init_fn_t)(void);
53
57typedef uint16_t auto_init_prio_t;
58
62typedef struct {
64#if IS_ACTIVE(CONFIG_AUTO_INIT_ENABLE_DEBUG) || defined(DOXYGEN)
66 const char *name;
67#endif
69
70#if IS_ACTIVE(CONFIG_AUTO_INIT_ENABLE_DEBUG) || defined(DOXYGEN)
77#define AUTO_INIT(function, priority) \
78 XFA_CONST(auto_init_module_t, auto_init_xfa, priority) \
79 auto_init_xfa_ ## function \
80 = { .init = (auto_init_fn_t)function, \
81 .prio = priority, \
82 .name = XTSTR(function) }
83#else
84#define AUTO_INIT(function, priority) \
85 XFA_CONST(auto_init_module_t, auto_init_xfa, priority) \
86 auto_init_xfa_ ## function \
87 = { .init = (auto_init_fn_t)function }
88#endif
89
94#define AUTO_INIT_PRIORITY_AFTER(priority) RIOT_PP_SUCCESSOR(priority)
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* AUTO_INIT_UTILS_H */
void(* auto_init_fn_t)(void)
Auto-init function type.
uint16_t auto_init_prio_t
Data type to store the priority of a module.
Common macros and compiler attributes/pragmas configuration.
Type to represent a module to be auto-initialized.
auto_init_prio_t prio
Module priority.
const char * name
Module auto-init function name.
auto_init_fn_t init
Function to initialize the module.
Cross File Arrays.
Macro to return string representation of x.