@@ -49,43 +49,6 @@ extern "C" {
49
49
50
50
struct device ;
51
51
52
- /**
53
- * @brief Initialization function for init entries.
54
- *
55
- * Init entries support both the system initialization and the device
56
- * APIs. Each API has its own init function signature; hence, we have a
57
- * union to cover both.
58
- */
59
- union init_function {
60
- /**
61
- * System initialization function.
62
- *
63
- * @retval 0 On success
64
- * @retval -errno If init fails.
65
- */
66
- int (* sys )(void );
67
- /**
68
- * Device initialization function.
69
- *
70
- * @param dev Device instance.
71
- *
72
- * @retval 0 On success
73
- * @retval -errno If device initialization fails.
74
- */
75
- int (* dev )(const struct device * dev );
76
- #ifdef CONFIG_DEVICE_MUTABLE
77
- /**
78
- * Device initialization function (rw).
79
- *
80
- * @param dev Device instance.
81
- *
82
- * @retval 0 On success
83
- * @retval -errno If device initialization fails.
84
- */
85
- int (* dev_rw )(struct device * dev );
86
- #endif
87
- };
88
-
89
52
/**
90
53
* @brief Structure to store initialization entry information.
91
54
*
@@ -101,8 +64,11 @@ union init_function {
101
64
* @endinternal
102
65
*/
103
66
struct init_entry {
104
- /** Initialization function. */
105
- union init_function init_fn ;
67
+ /**
68
+ * If the init function belongs to a SYS_INIT, this field stored the
69
+ * initialization function, otherwise it is set to NULL.
70
+ */
71
+ int (* init_fn )(void );
106
72
/**
107
73
* If the init entry belongs to a device, this fields stores a
108
74
* reference to it, otherwise it is set to NULL.
@@ -151,39 +117,6 @@ struct init_entry {
151
117
__attribute__((__section__( \
152
118
".z_init_" #level STRINGIFY(prio)"_" STRINGIFY(sub_prio)"_")))
153
119
154
-
155
- /* Designated initializers where added to C in C99. There were added to
156
- * C++ 20 years later in a much more restricted form. C99 allows many
157
- * variations: out of order, mix of designated and not, overlap,
158
- * override,... but C++ allows none of these. See differences detailed
159
- * in the P0329R0.pdf C++ proposal.
160
- * Note __STDC_VERSION__ is undefined when compiling C++.
161
- */
162
- #if defined(__STDC_VERSION__ ) && (__STDC_VERSION__ ) < 201100
163
-
164
- /* Anonymous unions require C11. Some pre-C11 gcc versions have early
165
- * support for anonymous unions but they require these braces when
166
- * combined with C99 designated initializers, see longer discussion in
167
- * #69411.
168
- * These braces are compatible with any C version but not with C++20.
169
- */
170
- # define Z_INIT_SYS_INIT_DEV_NULL { .dev = NULL }
171
-
172
- #else
173
-
174
- /* When using -std=c++20 or higher, g++ (v12.2.0) reject braces for
175
- * initializing anonymous unions because it is technically a mix of
176
- * designated and not designated initializers which is not allowed in
177
- * C++. Interestingly, the _same_ g++ version does accept the braces above
178
- * when using -std=c++17 or lower!
179
- * The tests/lib/cpp/cxx/ added by commit 3d9c428d57bf invoke the C++
180
- * compiler with a range of different `-std=...` parameters without needing
181
- * any manual configuration.
182
- */
183
- # define Z_INIT_SYS_INIT_DEV_NULL .dev = NULL
184
-
185
- #endif
186
-
187
120
/** @endcond */
188
121
189
122
/**
@@ -238,8 +171,7 @@ struct init_entry {
238
171
#define SYS_INIT_NAMED (name , init_fn_ , level , prio ) \
239
172
static const Z_DECL_ALIGN(struct init_entry) \
240
173
Z_INIT_ENTRY_SECTION(level, prio, 0) __used __noasan \
241
- Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)}, \
242
- Z_INIT_SYS_INIT_DEV_NULL}
174
+ Z_INIT_ENTRY_NAME(name) = {.init_fn = (init_fn_)} \
243
175
244
176
/** @} */
245
177
0 commit comments