5 extern void (*__preinit_array_start []) (void)
__attribute__((weak));
6 extern void (*__preinit_array_end []) (void)
__attribute__((weak));
7 extern void (*__init_array_start []) (void)
__attribute__((weak));
8 extern void (*__init_array_end []) (void)
__attribute__((weak));
9 extern void (*__fini_array_start []) (void)
__attribute__((weak));
10 extern void (*__fini_array_end []) (void)
__attribute__((weak));
17 static void __libc_init_array() {
21 for (i = 0; i < count; i++)
22 __preinit_array_start[i]();
26 count = __init_array_end - __init_array_start;
27 for (i = 0; i < count; i++)
28 __init_array_start[i]();
31 static void __libc_fini_array() {
34 count = __preinit_array_end - __preinit_array_start;
35 for (i = count - 1; i >= 0; i--)
36 __fini_array_start[i]();
43 static volatile uint8_t atexit_count = 0;
47 uint8_t pos = __sync_fetch_and_add(&atexit_count, 1);
54 atexit_funcs[pos] = func;
58 void exit(
int return_code) {
61 for (i = 0; i < atexit_count; i++) {