]> gcc.gnu.org Git - gcc.git/blob - gcc/gbl-ctors.h
Edit comment.
[gcc.git] / gcc / gbl-ctors.h
1 /* Definitions relating to the special __do_global_init function used
2 for getting g++ file-scope static objects constructed. This file
3 will get included either by libgcc2.c (for systems that don't support
4 a .init section) or by crtstuff.c (for those that do).
5
6 Written by Ron Guilmette (rfg@ncd.com)
7
8 Copyright (C) 1991 Free Software Foundation, Inc.
9
10 This file is part of GNU CC.
11
12 GNU CC is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2, or (at your option)
15 any later version.
16
17 GNU CC is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with GNU CC; see the file COPYING. If not, write to
24 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
25
26 /* This file contains definitions and declarations of things
27 relating to the normal start-up-time invocation of C++
28 file-scope static object constructors. These declarations
29 and definitions are used by *both* libgcc2.c and by crtstuff.c.
30
31 Note that this file should only be compiled with GCC.
32 */
33
34 #ifdef HAVE_ATEXIT
35 extern void atexit (void (*) (void));
36 #define ON_EXIT(FUNC,ARG) atexit ((FUNC))
37 #else
38 #ifdef sun
39 extern void on_exit (void*, void*);
40 #define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
41 #endif
42 #endif
43
44 /* Declare a pointer to void function type. */
45
46 typedef void (*func_ptr) (void);
47
48 /* Declare the set of symbols use as begin and end markers for the lists
49 of global object constructors and global object destructors. */
50
51 extern func_ptr __CTOR_LIST__[];
52 extern func_ptr __DTOR_LIST__[];
53
54 /* Declare the routine which need to get invoked at program exit time. */
55
56 extern void __do_global_dtors ();
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
66 /* The first word may or may not contain the number of pointers in the table.
67 In all cases, the table is null-terminated.
68 We ignore the first word and scan up to the null. */
69
70 /* Some systems use a different strategy for finding the ctors.
71 For example, svr3. */
72 #ifndef DO_GLOBAL_CTORS_BODY
73 #define DO_GLOBAL_CTORS_BODY \
74 do { \
75 func_ptr *p; \
76 for (p = __CTOR_LIST__ + 1; *p; ) \
77 (*p++) (); \
78 } while (0)
79 #endif
80
This page took 0.041002 seconds and 5 git commands to generate.