OSDN Git Service

(fold_rtx, case PLUS): When seeing if negative of constant is around,
[pf3gnuchains/gcc-fork.git] / gcc / gbl-ctors.h
index 2e7f520..6393a90 100644 (file)
@@ -2,10 +2,8 @@
    for getting g++ file-scope static objects constructed.  This file
    will get included either by libgcc2.c (for systems that don't support
    a .init section) or by crtstuff.c (for those that do).
-
-   Written by Ron Guilmette (rfg@netcom.com)
-
-Copyright (C) 1991 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
+   Contributed by Ron Guilmette (rfg@segfault.us.com)
 
 This file is part of GNU CC.
 
@@ -21,7 +19,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 /*     This file contains definitions and declarations of things
        relating to the normal start-up-time invocation of C++
@@ -31,12 +30,22 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
        Note that this file should only be compiled with GCC.
 */
 
+#ifdef NEED_ATEXIT
+#ifndef HAVE_ATEXIT
+#define HAVE_ATEXIT    1       /* Take it from libgcc2.c */
+#endif
+#endif
+
 #ifdef HAVE_ATEXIT
+#if defined (WINNT) || defined (NEED_ATEXIT)
+extern int atexit (void (*) (void));
+#else
 extern void atexit (void (*) (void));
+#endif
 #define ON_EXIT(FUNC,ARG) atexit ((FUNC))
 #else
 #ifdef sun
-extern void on_exit (void*, void*);
+extern int on_exit (void *, void *);   /* The man page says it returns int. */
 #define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
 #endif
 #endif
@@ -63,18 +72,23 @@ extern void __do_global_dtors ();
    we define it once here as a macro to avoid various instances getting
    out-of-sync with one another.  */
 
-/* The first word may or may not contain the number of pointers in the table.
+/* Some systems place the number of pointers
+   in the first word of the table.
+   On other systems, that word is -1.
    In all cases, the table is null-terminated.
-   We ignore the first word and scan up to the null.  */
+   If the length is not recorded, count up to the null.  */
 
 /* Some systems use a different strategy for finding the ctors.
    For example, svr3.  */
 #ifndef DO_GLOBAL_CTORS_BODY
 #define DO_GLOBAL_CTORS_BODY                                           \
 do {                                                                   \
-  func_ptr *p;                                                         \
-  for (p = __CTOR_LIST__ + 1; *p; )                                    \
-    (*p++) ();                                                         \
-} while (0)
+  unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];              \
+  unsigned i;                                                          \
+  if (nptrs == -1)                                                     \
+    for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);           \
+  for (i = nptrs; i >= 1; i--)                                         \
+    __CTOR_LIST__[i] ();                                               \
+} while (0) 
 #endif