]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/i386/netware-crt0.c
host-hpux.c: Change copyright header to refer to version 3 of the GNU General Public...
[thirdparty/gcc.git] / gcc / config / i386 / netware-crt0.c
CommitLineData
61fec9ff
JB
1/* Startup routines for NetWare.
2 Contributed by Jan Beulich (jbeulich@novell.com)
2f83c7d6 3 Copyright (C) 2004, 2007 Free Software Foundation, Inc.
61fec9ff
JB
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
2f83c7d6 9the Free Software Foundation; either version 3, or (at your option)
61fec9ff
JB
10any later version.
11
12GCC is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
2f83c7d6
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
61fec9ff
JB
20
21#include <stddef.h>
22#include <stdint.h>
23#include "unwind-dw2-fde.h"
24
f199d860
JB
25int __init_environment (void *);
26int __deinit_environment (void *);
27
61fec9ff
JB
28
29#define SECTION_DECL(name, decl) decl __attribute__((__section__(name)))
30
31SECTION_DECL(".ctors", void(*const __CTOR_LIST__)(void))
32 = (void(*)(void))(intptr_t)-1;
33SECTION_DECL(".ctors$_", void(*const __CTOR_END__)(void)) = NULL;
34
35SECTION_DECL(".dtors", void(*const __DTOR_LIST__)(void))
36 = (void(*)(void))(intptr_t)-1;
37SECTION_DECL(".dtors$_", void(*const __DTOR_END__)(void)) = NULL;
38
39/* No need to use the __[de]register_frame_info_bases functions since
40 for us the bases are NULL always anyway. */
41void __register_frame_info (const void *, struct object *)
42 __attribute__((__weak__));
43void *__deregister_frame_info (const void *) __attribute__((__weak__));
44
45SECTION_DECL(".eh_frame", /*const*/ uint32_t __EH_FRAME_BEGIN__[]) = { };
46SECTION_DECL(".eh_frame$_", /*const*/ uint32_t __EH_FRAME_END__[]) = {0};
47
48int
49__init_environment (void *unused __attribute__((__unused__)))
50{
51 void (* const * pctor)(void);
52 static struct object object;
53
54 if (__register_frame_info)
55 __register_frame_info (__EH_FRAME_BEGIN__, &object);
56
57 for (pctor = &__CTOR_END__ - 1; pctor > &__CTOR_LIST__; --pctor)
58 if (*pctor != NULL)
f199d860 59 (*pctor)();
61fec9ff
JB
60
61 return 0;
62}
63
64int
65__deinit_environment (void *unused __attribute__((__unused__)))
66{
67 /* This should be static to prevent calling the same destructor
68 twice (just in case where we get here multiple times). */
69 static void (* const * pdtor)(void) = &__DTOR_LIST__ + 1;
70
71 while (pdtor < &__DTOR_END__)
72 if (*pdtor++ != NULL)
73 pdtor[-1] ();
74
75 if (__deregister_frame_info)
76 __deregister_frame_info(__EH_FRAME_BEGIN__);
77
78 return 0;
79}