Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / misc / init.c
blob3aef7ad069da7e2c0057af51c529f8d1e7b497f2
1 /*
2 * Copyright (C) 2004 CodeSourcery, LLC
4 * Permission to use, copy, modify, and distribute this file
5 * for any purpose is hereby granted without fee, provided that
6 * the above copyright notice and this notice appears in all
7 * copies.
9 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 /* Handle ELF .{pre_init,init,fini}_array sections. */
14 #include <sys/types.h>
16 #ifdef _HAVE_INITFINI_ARRAY
18 /* These magic symbols are provided by the linker. */
19 extern void (*__preinit_array_start []) (void) __attribute__((weak));
20 extern void (*__preinit_array_end []) (void) __attribute__((weak));
21 extern void (*__init_array_start []) (void) __attribute__((weak));
22 extern void (*__init_array_end []) (void) __attribute__((weak));
24 #ifdef _HAVE_INIT_FINI
25 extern void _init (void);
26 #endif
28 /* Iterate over all the init routines. */
29 void
30 __libc_init_array (void)
32 size_t count;
33 size_t i;
35 count = __preinit_array_end - __preinit_array_start;
36 for (i = 0; i < count; i++)
37 __preinit_array_start[i] ();
39 #ifdef _HAVE_INIT_FINI
40 _init ();
41 #endif
43 count = __init_array_end - __init_array_start;
44 for (i = 0; i < count; i++)
45 __init_array_start[i] ();
47 #endif