]>
Commit | Line | Data |
---|---|---|
014cfee8 RS |
1 | /* Definitions relating to the special __do_global_init function used |
2 | for getting g++ file-scope static objects constructed. This file | |
5b879759 | 3 | will get included either by libgcc2.c (for systems that don't support |
014cfee8 | 4 | a .init section) or by crtstuff.c (for those that do). |
5145a02e | 5 | Copyright (C) 1991, 1995, 1996, 1998, 1999, 2000, 2003 |
63bc1d05 | 6 | Free Software Foundation, Inc. |
3709124d | 7 | Contributed by Ron Guilmette (rfg@segfault.us.com) |
014cfee8 | 8 | |
1322177d | 9 | This file is part of GCC. |
014cfee8 | 10 | |
1322177d LB |
11 | GCC is free software; you can redistribute it and/or modify it under |
12 | the terms of the GNU General Public License as published by the Free | |
13 | Software Foundation; either version 2, or (at your option) any later | |
14 | version. | |
014cfee8 | 15 | |
1322177d LB |
16 | GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
17 | WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
18 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
19 | for more details. | |
014cfee8 RS |
20 | |
21 | You should have received a copy of the GNU General Public License | |
1322177d | 22 | along with GCC; see the file COPYING. If not, write to the Free |
366ccddb KC |
23 | Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA |
24 | 02110-1301, USA. */ | |
014cfee8 | 25 | |
77c915d8 DT |
26 | /* As a special exception, if you link this library with other files, |
27 | some of which are compiled with GCC, to produce an executable, | |
28 | this library does not by itself cause the resulting executable | |
29 | to be covered by the GNU General Public License. | |
30 | This exception does not however invalidate any other reasons why | |
31 | the executable file might be covered by the GNU General Public License. */ | |
32 | ||
014cfee8 RS |
33 | /* This file contains definitions and declarations of things |
34 | relating to the normal start-up-time invocation of C++ | |
35 | file-scope static object constructors. These declarations | |
36 | and definitions are used by *both* libgcc2.c and by crtstuff.c. | |
37 | ||
38 | Note that this file should only be compiled with GCC. | |
39 | */ | |
40 | ||
014cfee8 RS |
41 | /* Declare a pointer to void function type. */ |
42 | ||
43 | typedef void (*func_ptr) (void); | |
44 | ||
45 | /* Declare the set of symbols use as begin and end markers for the lists | |
c415fa05 | 46 | of global object constructors and global object destructors. */ |
014cfee8 RS |
47 | |
48 | extern func_ptr __CTOR_LIST__[]; | |
49 | extern func_ptr __DTOR_LIST__[]; | |
50 | ||
63bc1d05 KG |
51 | /* Declare the routine which needs to get invoked at program start time. */ |
52 | ||
53 | extern void __do_global_ctors (void); | |
54 | ||
55 | /* Declare the routine which needs to get invoked at program exit time. */ | |
014cfee8 | 56 | |
a24da858 | 57 | extern void __do_global_dtors (void); |
014cfee8 RS |
58 | |
59 | /* Define a macro with the code which needs to be executed at program | |
60 | start-up time. This macro is used in two places in crtstuff.c (for | |
61 | systems which support a .init section) and in one place in libgcc2.c | |
62 | (for those system which do *not* support a .init section). For all | |
63 | three places where this code might appear, it must be identical, so | |
64 | we define it once here as a macro to avoid various instances getting | |
65 | out-of-sync with one another. */ | |
66 | ||
e5952538 JM |
67 | /* Some systems place the number of pointers |
68 | in the first word of the table. | |
69 | On other systems, that word is -1. | |
014cfee8 | 70 | In all cases, the table is null-terminated. |
e5952538 | 71 | If the length is not recorded, count up to the null. */ |
014cfee8 RS |
72 | |
73 | /* Some systems use a different strategy for finding the ctors. | |
74 | For example, svr3. */ | |
75 | #ifndef DO_GLOBAL_CTORS_BODY | |
76 | #define DO_GLOBAL_CTORS_BODY \ | |
77 | do { \ | |
976ef4f7 | 78 | unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; \ |
e5952538 | 79 | unsigned i; \ |
4f70758f | 80 | if (nptrs == (unsigned long)-1) \ |
e5952538 JM |
81 | for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \ |
82 | for (i = nptrs; i >= 1; i--) \ | |
83 | __CTOR_LIST__[i] (); \ | |
589005ff | 84 | } while (0) |
014cfee8 RS |
85 | #endif |
86 |