delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/10/29/14:09:37

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Patch to fix CTOR/DTOR invocation order
29 Oct 1998 14:09:37 -0800 :
Message-ID: <9810292145.AA00580.cygnus.cygwin32.developers@modi.xraylith.wisc.edu>
To: cygwin32-developers AT cygnus DOT com

This was sitting quietly waiting to jump up and bite ... eventually we
should try and merge the common functionalities of do_global_{c,d}tors
and this set.

Thu Oct 29 15:40:01 1998  Mumit Khan  <khan AT xraylith DOT wisc DOT edu>

	* dll_init.cc (doGlobalCTORS): Fix invocation order.
	(doGlobalDTORS): Likewise.

--- dll_init.cc.~1	Thu Oct 29 15:35:55 1998
+++ dll_init.cc		Thu Oct 29 15:37:09 1998
@@ -65,19 +65,9 @@ __dll_global_dtors()
 static void
 doGlobalCTORS (per_process *p)
 {
-  void (**pfunc) () = p->ctors;
-  for (int i = 1; pfunc[i]; i++)
-    (pfunc[i]) ();
-}
-
-static void
-doGlobalDTORS (per_process *p)
-{
-  if (!p)
-    return;
-  void (**pfunc)() = p->dtors;
+  void (**pfunc)() = p->ctors;
 
-  /* Run dtors backwards, so skip the first entry and find how many
+  /* Run ctors backwards, so skip the first entry and find how many
     there are, then run them.  */
 
   if (pfunc)
@@ -88,6 +78,16 @@ doGlobalDTORS (per_process *p)
       for (int j = i - 1; j > 0; j-- )
 	(pfunc[j]) ();
     }
+}
+
+static void
+doGlobalDTORS (per_process *p)
+{
+  if (!p)
+    return;
+  void (**pfunc)() = p->dtors;
+  for (int i = 1; pfunc[i]; i++)
+    (pfunc[i]) ();
 }
 
 #define INC 500

Regards,
Mumit

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019