annotate libgcc/gbl-ctors.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Definitions relating to the special __do_global_init function used
kono
parents:
diff changeset
2 for getting g++ file-scope static objects constructed. This file
kono
parents:
diff changeset
3 will get included either by libgcc2.c (for systems that don't support
kono
parents:
diff changeset
4 a .init section) or by crtstuff.c (for those that do).
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
5 Copyright (C) 1991-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
6 Contributed by Ron Guilmette (rfg@segfault.us.com)
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 This file is part of GCC.
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 GCC is free software; you can redistribute it and/or modify it under
kono
parents:
diff changeset
11 the terms of the GNU General Public License as published by the Free
kono
parents:
diff changeset
12 Software Foundation; either version 3, or (at your option) any later
kono
parents:
diff changeset
13 version.
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
kono
parents:
diff changeset
16 WARRANTY; without even the implied warranty of MERCHANTABILITY or
kono
parents:
diff changeset
17 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
kono
parents:
diff changeset
18 for more details.
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 Under Section 7 of GPL version 3, you are granted additional
kono
parents:
diff changeset
21 permissions described in the GCC Runtime Library Exception, version
kono
parents:
diff changeset
22 3.1, as published by the Free Software Foundation.
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 You should have received a copy of the GNU General Public License and
kono
parents:
diff changeset
25 a copy of the GCC Runtime Library Exception along with this program;
kono
parents:
diff changeset
26 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
kono
parents:
diff changeset
27 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 /* This file contains definitions and declarations of things
kono
parents:
diff changeset
30 relating to the normal start-up-time invocation of C++
kono
parents:
diff changeset
31 file-scope static object constructors. These declarations
kono
parents:
diff changeset
32 and definitions are used by *both* libgcc2.c and by crtstuff.c.
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 Note that this file should only be compiled with GCC.
kono
parents:
diff changeset
35 */
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 #ifndef GCC_GBL_CTORS_H
kono
parents:
diff changeset
38 #define GCC_GBL_CTORS_H
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 /* Declare a pointer to void function type. */
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 typedef void (*func_ptr) (void);
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 /* Declare the set of symbols use as begin and end markers for the lists
kono
parents:
diff changeset
45 of global object constructors and global object destructors. */
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 extern func_ptr __CTOR_LIST__[];
kono
parents:
diff changeset
48 extern func_ptr __DTOR_LIST__[];
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 /* Declare the routine which needs to get invoked at program start time. */
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 extern void __do_global_ctors (void);
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 /* Declare the routine which needs to get invoked at program exit time. */
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 extern void __do_global_dtors (void);
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 /* Define a macro with the code which needs to be executed at program
kono
parents:
diff changeset
59 start-up time. This macro is used in two places in crtstuff.c (for
kono
parents:
diff changeset
60 systems which support a .init section) and in one place in libgcc2.c
kono
parents:
diff changeset
61 (for those system which do *not* support a .init section). For all
kono
parents:
diff changeset
62 three places where this code might appear, it must be identical, so
kono
parents:
diff changeset
63 we define it once here as a macro to avoid various instances getting
kono
parents:
diff changeset
64 out-of-sync with one another. */
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 /* Some systems place the number of pointers
kono
parents:
diff changeset
67 in the first word of the table.
kono
parents:
diff changeset
68 On other systems, that word is -1.
kono
parents:
diff changeset
69 In all cases, the table is null-terminated.
kono
parents:
diff changeset
70 If the length is not recorded, count up to the null. */
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 /* Some systems use a different strategy for finding the ctors.
kono
parents:
diff changeset
73 For example, svr3. */
kono
parents:
diff changeset
74 #ifndef DO_GLOBAL_CTORS_BODY
kono
parents:
diff changeset
75 #define DO_GLOBAL_CTORS_BODY \
kono
parents:
diff changeset
76 do { \
kono
parents:
diff changeset
77 __SIZE_TYPE__ nptrs = (__SIZE_TYPE__) __CTOR_LIST__[0]; \
kono
parents:
diff changeset
78 unsigned i; \
kono
parents:
diff changeset
79 if (nptrs == (__SIZE_TYPE__)-1) \
kono
parents:
diff changeset
80 for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \
kono
parents:
diff changeset
81 for (i = nptrs; i >= 1; i--) \
kono
parents:
diff changeset
82 __CTOR_LIST__[i] (); \
kono
parents:
diff changeset
83 } while (0)
kono
parents:
diff changeset
84 #endif
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 #endif /* GCC_GBL_CTORS_H */