00001 /* Definitions relating to the special __do_global_init function used 00002 for getting g++ file-scope static objects constructed. This file 00003 will get included either by libgcc2.c (for systems that don't support 00004 a .init section) or by crtstuff.c (for those that do). 00005 Copyright (C) 1991, 1995, 1996, 1998, 1999, 2000, 2003 00006 Free Software Foundation, Inc. 00007 Contributed by Ron Guilmette (rfg@segfault.us.com) 00008 00009 This file is part of GCC. 00010 00011 GCC is free software; you can redistribute it and/or modify it under 00012 the terms of the GNU General Public License as published by the Free 00013 Software Foundation; either version 2, or (at your option) any later 00014 version. 00015 00016 GCC is distributed in the hope that it will be useful, but WITHOUT ANY 00017 WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with GCC; see the file COPYING. If not, write to the Free 00023 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 00024 02110-1301, USA. */ 00025 00026 /* As a special exception, if you link this library with other files, 00027 some of which are compiled with GCC, to produce an executable, 00028 this library does not by itself cause the resulting executable 00029 to be covered by the GNU General Public License. 00030 This exception does not however invalidate any other reasons why 00031 the executable file might be covered by the GNU General Public License. */ 00032 00033 /* This file contains definitions and declarations of things 00034 relating to the normal start-up-time invocation of C++ 00035 file-scope static object constructors. These declarations 00036 and definitions are used by *both* libgcc2.c and by crtstuff.c. 00037 00038 Note that this file should only be compiled with GCC. 00039 */ 00040 00041 /* Declare a pointer to void function type. */ 00042 00043 typedef void (*func_ptr) (void); 00044 00045 /* Declare the set of symbols use as begin and end markers for the lists 00046 of global object constructors and global object destructors. */ 00047 00048 extern func_ptr __CTOR_LIST__[]; 00049 extern func_ptr __DTOR_LIST__[]; 00050 00051 /* Declare the routine which needs to get invoked at program start time. */ 00052 00053 extern void __do_global_ctors (void); 00054 00055 /* Declare the routine which needs to get invoked at program exit time. */ 00056 00057 extern void __do_global_dtors (void); 00058 00059 /* Define a macro with the code which needs to be executed at program 00060 start-up time. This macro is used in two places in crtstuff.c (for 00061 systems which support a .init section) and in one place in libgcc2.c 00062 (for those system which do *not* support a .init section). For all 00063 three places where this code might appear, it must be identical, so 00064 we define it once here as a macro to avoid various instances getting 00065 out-of-sync with one another. */ 00066 00067 /* Some systems place the number of pointers 00068 in the first word of the table. 00069 On other systems, that word is -1. 00070 In all cases, the table is null-terminated. 00071 If the length is not recorded, count up to the null. */ 00072 00073 /* Some systems use a different strategy for finding the ctors. 00074 For example, svr3. */ 00075 #ifndef DO_GLOBAL_CTORS_BODY 00076 #define DO_GLOBAL_CTORS_BODY \ 00077 do { \ 00078 unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; \ 00079 unsigned i; \ 00080 if (nptrs == (unsigned long)-1) \ 00081 for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); \ 00082 for (i = nptrs; i >= 1; i--) \ 00083 __CTOR_LIST__[i] (); \ 00084 } while (0) 00085 #endif 00086
1.5.6