OSDN Git Service

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