From bee18f45fd83bc2432a856b116e9b85b42c140d2 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Mon, 4 Aug 2008 15:55:32 +0000 Subject: [PATCH] Changes suggested by Dave Korn. * dcrt0.cc (cygwin_exit): Remove (hopefully) extraneous call to dll_global_dtors. * dll_init.cc (dll_global_dtors): Run destructors in reverse dependency/load order. * dll_init.h (dll_list): Add dll_global_dtors as a friend. --- winsup/cygwin/ChangeLog | 9 +++++++++ winsup/cygwin/dcrt0.cc | 1 - winsup/cygwin/dll_init.cc | 2 +- winsup/cygwin/dll_init.h | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e90724529..32e9590b2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2008-08-04 Christopher Faylor + + Changes suggested by Dave Korn. + * dcrt0.cc (cygwin_exit): Remove (hopefully) extraneous call to + dll_global_dtors. + * dll_init.cc (dll_global_dtors): Run destructors in reverse + dependency/load order. + * dll_init.h (dll_list): Add dll_global_dtors as a friend. + 2008-08-01 Christopher Faylor * dcrt0.cc (dll_crt0_1): Add a symbol denoting return from call to diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index e37cbec9b..dbdc61e2c 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -1112,7 +1112,6 @@ cygwin_atexit (void (*function)(void)) extern "C" void cygwin_exit (int n) { - dll_global_dtors (); if (atexit_lock) atexit_lock.acquire (); exit (n); diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 22c64e1e2..9a867b5d8 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -32,7 +32,7 @@ dll_global_dtors () int recorded = dll_global_dtors_recorded; dll_global_dtors_recorded = false; if (recorded) - for (dll *d = dlls.istart (DLL_ANY); d; d = dlls.inext ()) + for (dll *d = dlls.end; d != &dlls.start; d = d->prev) d->p.run_dtors (); } diff --git a/winsup/cygwin/dll_init.h b/winsup/cygwin/dll_init.h index 205123a2f..a7601e78b 100644 --- a/winsup/cygwin/dll_init.h +++ b/winsup/cygwin/dll_init.h @@ -86,6 +86,7 @@ public: hold = &start; return inext (); } + friend void dll_global_dtors (); }; extern dll_list dlls;