File: init.c

package info (click to toggle)
picolibc 1.8.11-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 50,064 kB
  • sloc: ansic: 404,031; asm: 24,984; sh: 2,585; python: 2,289; perl: 680; pascal: 329; exp: 287; makefile: 222; cpp: 71; xml: 40
file content (50 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 * Copyright (C) 2004 CodeSourcery, LLC
 *
 * Permission to use, copy, modify, and distribute this file
 * for any purpose is hereby granted without fee, provided that
 * the above copyright notice and this notice appears in all
 * copies.
 *
 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 */

/* Handle ELF .{pre_init,init,fini}_array sections.  */
#include <sys/types.h>
#include <sys/_initfini.h>

#ifdef __INIT_FINI_ARRAY

/* Iterate over all the init routines.  */
void
__libc_init_array(void)
{
    void (**fn)(void);
    void (**fn_end)(void);

#ifdef __INIT_FINI_FUNCS
    fn = __preinit_array_start;
    fn_end = __preinit_array_end;
    while (fn != fn_end)
        (*fn++)();

    if (_init)
        _init();

    fn = __init_array_start;
    fn_end = __init_array_end;
    while (fn != fn_end)
        (*fn++)();
#else
    /*
     * The init array immediately follows the preinit array,
     * so we can just run both in one loop
     */
    fn = __bothinit_array_start;
    fn_end = __bothinit_array_end;
    while (fn != fn_end)
        (*fn++)();
#endif
}
#endif