]> git.ipfire.org Git - thirdparty/gcc.git/blame - libgcc/gbl-ctors.h
Update copyright years.
[thirdparty/gcc.git] / libgcc / gbl-ctors.h
CommitLineData
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).
8d9254fc 5 Copyright (C) 1991-2020 Free Software Foundation, Inc.
3709124d 6 Contributed by Ron Guilmette (rfg@segfault.us.com)
014cfee8 7
1322177d 8This file is part of GCC.
014cfee8 9
1322177d
LB
10GCC is free software; you can redistribute it and/or modify it under
11the terms of the GNU General Public License as published by the Free
748086b7 12Software Foundation; either version 3, or (at your option) any later
1322177d 13version.
014cfee8 14
1322177d
LB
15GCC is distributed in the hope that it will be useful, but WITHOUT ANY
16WARRANTY; without even the implied warranty of MERCHANTABILITY or
17FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18for more details.
014cfee8 19
748086b7
JJ
20Under Section 7 of GPL version 3, you are granted additional
21permissions described in the GCC Runtime Library Exception, version
223.1, as published by the Free Software Foundation.
23
24You should have received a copy of the GNU General Public License and
25a copy of the GCC Runtime Library Exception along with this program;
26see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
27<http://www.gnu.org/licenses/>. */
77c915d8 28
014cfee8
RS
29/* This file contains definitions and declarations of things
30 relating to the normal start-up-time invocation of C++
31 file-scope static object constructors. These declarations
32 and definitions are used by *both* libgcc2.c and by crtstuff.c.
33
34 Note that this file should only be compiled with GCC.
35*/
36
69952c1d
BRF
37#ifndef GCC_GBL_CTORS_H
38#define GCC_GBL_CTORS_H
39
014cfee8
RS
40/* Declare a pointer to void function type. */
41
42typedef void (*func_ptr) (void);
43
44/* Declare the set of symbols use as begin and end markers for the lists
c415fa05 45 of global object constructors and global object destructors. */
014cfee8
RS
46
47extern func_ptr __CTOR_LIST__[];
48extern func_ptr __DTOR_LIST__[];
49
63bc1d05
KG
50/* Declare the routine which needs to get invoked at program start time. */
51
52extern void __do_global_ctors (void);
53
54/* Declare the routine which needs to get invoked at program exit time. */
014cfee8 55
a24da858 56extern void __do_global_dtors (void);
014cfee8
RS
57
58/* Define a macro with the code which needs to be executed at program
59 start-up time. This macro is used in two places in crtstuff.c (for
60 systems which support a .init section) and in one place in libgcc2.c
61 (for those system which do *not* support a .init section). For all
62 three places where this code might appear, it must be identical, so
63 we define it once here as a macro to avoid various instances getting
64 out-of-sync with one another. */
65
e5952538
JM
66/* Some systems place the number of pointers
67 in the first word of the table.
68 On other systems, that word is -1.
014cfee8 69 In all cases, the table is null-terminated.
e5952538 70 If the length is not recorded, count up to the null. */
014cfee8
RS
71
72/* Some systems use a different strategy for finding the ctors.
73 For example, svr3. */
74#ifndef DO_GLOBAL_CTORS_BODY
75#define DO_GLOBAL_CTORS_BODY \
76do { \
59a1171f 77 __SIZE_TYPE__ nptrs = (__SIZE_TYPE__) __CTOR_LIST__[0]; \
e5952538 78 unsigned i; \
59a1171f 79 if (nptrs == (__SIZE_TYPE__)-1) \
e5952538
JM
80 for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
81 for (i = nptrs; i >= 1; i--) \
82 __CTOR_LIST__[i] (); \
589005ff 83} while (0)
014cfee8
RS
84#endif
85
69952c1d 86#endif /* GCC_GBL_CTORS_H */