Cygwin: mmap: allow remapping part of an existing anonymous mapping
[newlib-cygwin.git] / newlib / libc / misc / fini.c
blob5f201607061510625856413a94eac0e5e8476acf
1 /*
2 * Copyright (C) 2010 CodeSourcery, Inc.
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
17 extern void (*__fini_array_start []) (void) __attribute__((weak));
18 extern void (*__fini_array_end []) (void) __attribute__((weak));
20 #ifdef _HAVE_INIT_FINI
21 extern void _fini (void);
22 #endif
24 /* Run all the cleanup routines. */
25 void
26 __libc_fini_array (void)
28 size_t count;
29 size_t i;
31 count = __fini_array_end - __fini_array_start;
32 for (i = count; i > 0; i--)
33 __fini_array_start[i-1] ();
35 #ifdef _HAVE_INIT_FINI
36 _fini ();
37 #endif
39 #endif