1 /*
2  * Copyright (c) 2012-2014 Wind River Systems, Inc.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file - Constructor module
9  * @brief
10  * The ctors section contains a list of function pointers that execute the
11  * C++ constructors of static global objects. These must be executed before
12  * the application's main() routine.
13  *
14  * NOTE: Not all compilers put those function pointers into the ctors section;
15  * some put them into the init_array section instead.
16  */
17 
18 /* What a constructor function pointer looks like */
19 
20 typedef void (*CtorFuncPtr)(void);
21 
22 /* Constructor function pointer list is generated by the linker script. */
23 
24 extern CtorFuncPtr __ZEPHYR_CTOR_LIST__[];
25 extern CtorFuncPtr __ZEPHYR_CTOR_END__[];
26 
27 /**
28  *
29  * @brief Invoke all C++ style global object constructors
30  *
31  * This routine is invoked by the kernel prior to the execution of the
32  * application's main().
33  */
__do_global_ctors_aux(void)34 void __do_global_ctors_aux(void)
35 {
36 	unsigned int nCtors;
37 
38 	nCtors = (unsigned long)__ZEPHYR_CTOR_LIST__[0];
39 
40 	while (nCtors >= 1U) {
41 		__ZEPHYR_CTOR_LIST__[nCtors--]();
42 	}
43 }
44