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@ncd.com)
+ Written by Ron Guilmette (rfg@netcom.com)
Copyright (C) 1991 Free Software Foundation, Inc.
Note that this file should only be compiled with GCC.
*/
-#ifdef sun
-extern void on_exit (void*, void*);
-#define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
-#else
#ifdef HAVE_ATEXIT
extern void atexit (void (*) (void));
#define ON_EXIT(FUNC,ARG) atexit ((FUNC))
+#else
+#ifdef sun
+extern void on_exit (void*, void*);
+#define ON_EXIT(FUNC,ARG) on_exit ((FUNC), (ARG))
#endif
#endif
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