1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the w64 mingw-runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 7 //#include <windows.h> 8 #include <stdlib.h> 9 #include <setjmp.h> 10 11 typedef void (*func_ptr) (void); 12 extern func_ptr __CTOR_LIST__[]; 13 extern func_ptr __DTOR_LIST__[]; 14 15 void __do_global_dtors (void); 16 void __do_global_ctors (void); 17 void __main (void); 18 19 void 20 __do_global_dtors (void) 21 { 22 static func_ptr *p = __DTOR_LIST__ + 1; 23 24 while (*p) 25 { 26 (*(p)) (); 27 p++; 28 } 29 } 30 31 void 32 __do_global_ctors (void) 33 { 34 unsigned long nptrs = (unsigned long) (ptrdiff_t) __CTOR_LIST__[0]; 35 unsigned long i; 36 37 if (nptrs == (unsigned long) -1) 38 { 39 for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++); 40 } 41 42 for (i = nptrs; i >= 1; i--) 43 { 44 __CTOR_LIST__[i] (); 45 } 46 } 47 48 static int initialized = 0; 49 50 void 51 __main (void) 52 { 53 if (!initialized) 54 { 55 initialized = 1; 56 __do_global_ctors (); 57 } 58 } 59