source: trunk/third/gcc/gbl-ctors.h @ 8834

Revision 8834, 3.1 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r8833, which included commits to RCS files with non-trunk default branches.
Line 
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   Copyright (C) 1991, 1995 Free Software Foundation, Inc.
6   Contributed by Ron Guilmette (rfg@segfault.us.com)
7
8This file is part of GNU CC.
9
10GNU CC is free software; you can redistribute it and/or modify
11it under the terms of the GNU General Public License as published by
12the Free Software Foundation; either version 2, or (at your option)
13any later version.
14
15GNU CC is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with GNU CC; see the file COPYING.  If not, write to
22the Free Software Foundation, 59 Temple Place - Suite 330,
23Boston, MA 02111-1307, USA.  */
24
25/*      This file contains definitions and declarations of things
26        relating to the normal start-up-time invocation of C++
27        file-scope static object constructors.  These declarations
28        and definitions are used by *both* libgcc2.c and by crtstuff.c.
29
30        Note that this file should only be compiled with GCC.
31*/
32
33#ifdef HAVE_ATEXIT
34#ifdef WINNT
35extern int atexit (void (*) (void));
36#else
37extern void atexit (void (*) (void));
38#endif
39#define ON_EXIT(FUNC,ARG) atexit ((FUNC))
40#else
41#ifdef sun
42extern void on_exit (void*, void*);
43#define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
44#endif
45#endif
46
47/*  Declare a pointer to void function type.  */
48
49typedef void (*func_ptr) (void);
50
51/* Declare the set of symbols use as begin and end markers for the lists
52   of global object constructors and global object destructors.  */
53
54extern func_ptr __CTOR_LIST__[];
55extern func_ptr __DTOR_LIST__[];
56
57/* Declare the routine which need to get invoked at program exit time.  */
58
59extern void __do_global_dtors ();
60
61/* Define a macro with the code which needs to be executed at program
62   start-up time.  This macro is used in two places in crtstuff.c (for
63   systems which support a .init section) and in one place in libgcc2.c
64   (for those system which do *not* support a .init section).  For all
65   three places where this code might appear, it must be identical, so
66   we define it once here as a macro to avoid various instances getting
67   out-of-sync with one another.  */
68
69/* Some systems place the number of pointers
70   in the first word of the table.
71   On other systems, that word is -1.
72   In all cases, the table is null-terminated.
73   If the length is not recorded, count up to the null.  */
74
75/* Some systems use a different strategy for finding the ctors.
76   For example, svr3.  */
77#ifndef DO_GLOBAL_CTORS_BODY
78#define DO_GLOBAL_CTORS_BODY                                            \
79do {                                                                    \
80  unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];               \
81  unsigned i;                                                           \
82  if (nptrs == -1)                                                      \
83    for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);            \
84  for (i = nptrs; i >= 1; i--)                                          \
85    __CTOR_LIST__[i] ();                                                \
86} while (0)
87#endif
88
Note: See TracBrowser for help on using the repository browser.