source: trunk/libs/newlib/src/newlib/libc/misc/fini.c

Last change on this file was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 895 bytes
Line 
1/*
2 * Copyright (C) 2010 CodeSourcery, Inc.
3 *
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.
8 *
9 * This file is distributed WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 */
12
13/* Handle ELF .{pre_init,init,fini}_array sections.  */
14#include <sys/types.h>
15
16#ifdef HAVE_INITFINI_ARRAY
17extern void (*__fini_array_start []) (void) __attribute__((weak));
18extern void (*__fini_array_end []) (void) __attribute__((weak));
19
20extern void _fini (void);
21
22/* Run all the cleanup routines.  */
23void
24__libc_fini_array (void)
25{
26  size_t count;
27  size_t i;
28 
29  count = __fini_array_end - __fini_array_start;
30  for (i = count; i > 0; i--)
31    __fini_array_start[i-1] ();
32
33  _fini ();
34}
35#endif
Note: See TracBrowser for help on using the repository browser.