OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [misc/] [init.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (C) 2004 CodeSourcery, LLC
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
17
 
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));
23
extern void (*__fini_array_start []) (void) __attribute__((weak));
24
extern void (*__fini_array_end []) (void) __attribute__((weak));
25
 
26
extern void _init (void);
27
extern void _fini (void);
28
 
29
/* Iterate over all the init routines.  */
30
void
31
__libc_init_array (void)
32
{
33
  size_t count;
34
  size_t i;
35
 
36
  count = __preinit_array_end - __preinit_array_start;
37
  for (i = 0; i < count; i++)
38
    __preinit_array_start[i] ();
39
 
40
  _init ();
41
 
42
  count = __init_array_end - __init_array_start;
43
  for (i = 0; i < count; i++)
44
    __init_array_start[i] ();
45
}
46
 
47
/* Run all the cleanup routines.  */
48
void
49
__libc_fini_array (void)
50
{
51
  size_t count;
52
  size_t i;
53
 
54
  count = __fini_array_end - __fini_array_start;
55
  for (i = count; i > 0; i--)
56
    __fini_array_start[i-1] ();
57
 
58
  _fini ();
59
}
60
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.