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:
23
sources/stubs/misc/__initcpp.c
Normal file
23
sources/stubs/misc/__initcpp.c
Normal 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);
|
||||
Reference in New Issue
Block a user