1 #include "HalideRuntime.h" 2 3 #ifdef BITS_64 4 typedef uint64_t addr_t; 5 #else 6 typedef uint32_t addr_t; 7 #endif 8 9 extern addr_t __DTOR_LIST__; 10 extern addr_t __CTOR_END__; 11 extern "C" { run_dtors()12__attribute__((section(".fini.halide"))) void run_dtors() { 13 typedef void (*dtor_func)(); 14 addr_t *dtor_p = &__DTOR_LIST__; 15 while (1) { 16 dtor_func dtor = (dtor_func)*dtor_p; 17 if (!dtor) { 18 break; 19 } else { 20 dtor(); 21 } 22 dtor_p++; 23 } 24 } run_ctors()25__attribute__((section(".init.halide"))) void run_ctors() { 26 typedef void (*ctor_func)(); 27 addr_t *ctor_p = &__CTOR_END__; 28 while (1) { 29 ctor_func ctor = (ctor_func) * (--ctor_p); 30 if (!ctor) { 31 break; 32 } else { 33 ctor(); 34 } 35 } 36 } 37 } // extern "C" 38