1
0
mirror of https://github.com/cahirwpz/libnix.git synced 2025-12-08 14:58:56 +00:00

Handle __CTOR_LIST__ and __DTOR_LIST__ initialization.

This commit is contained in:
Krystian Bacławski
2016-10-15 09:53:00 +02:00
parent b1c9ff1a73
commit 7ab6f71804
12 changed files with 37 additions and 7 deletions

View File

@ -0,0 +1,23 @@
#include "stabs.h"
typedef void (*func_ptr) (void);
extern func_ptr __CTOR_LIST__[];
extern func_ptr __DTOR_LIST__[];
void __initcpp() {
func_ptr *p0 = __CTOR_LIST__ + 1;
func_ptr *p;
for (p = p0; *p; p++);
while (p > p0)
(*--p)();
}
void __exitcpp() {
func_ptr *p = __DTOR_LIST__ + 1;
while (*p)
(*p++)();
}
ADD2INIT(__initcpp,100);
ADD2EXIT(__exitcpp,100);