aboutsummaryrefslogtreecommitdiff
path: root/gcc/gbl-ctors.h
diff options
context:
space:
mode:
authorJason Merrill <merrill@gnu.org>1994-07-29 19:03:37 +0000
committerJason Merrill <merrill@gnu.org>1994-07-29 19:03:37 +0000
commite5952538c4196ee92064db9cbff88e1ca2eeb5ce (patch)
treeff09d4aec59c8c85b0a8490344f534acaa2bfdc9 /gcc/gbl-ctors.h
parent566b213ab1d920957c39fd8e4ba5b78f517a68fa (diff)
downloadgcc-e5952538c4196ee92064db9cbff88e1ca2eeb5ce.zip
gcc-e5952538c4196ee92064db9cbff88e1ca2eeb5ce.tar.gz
gcc-e5952538c4196ee92064db9cbff88e1ca2eeb5ce.tar.bz2
(DO_GLOBAL_CTORS_BODY): Reverse order of execution
of constuctor lists. From-SVN: r7818
Diffstat (limited to 'gcc/gbl-ctors.h')
-rw-r--r--gcc/gbl-ctors.h17
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/gbl-ctors.h b/gcc/gbl-ctors.h
index 2e7f520..32ff033 100644
--- a/gcc/gbl-ctors.h
+++ b/gcc/gbl-ctors.h
@@ -63,18 +63,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 nptrs = (unsigned HOST_WIDE_INT) __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