https://github.com/halide/Halide
Raw File
Tip revision: a21837ff1e085f22ef380c65847202d7917950e7 authored by Steven Johnson on 06 February 2021, 00:10:51 UTC
Merge branch 'master' into srj/msan-dtf
Tip revision: a21837f
qurt_init_fini.cpp
#include "HalideRuntime.h"

#ifdef BITS_64
typedef uint64_t addr_t;
#else
typedef uint32_t addr_t;
#endif

extern addr_t __DTOR_LIST__;
extern addr_t __CTOR_END__;
extern "C" {
__attribute__((section(".fini.halide"))) void run_dtors() {
    typedef void (*dtor_func)();
    addr_t *dtor_p = &__DTOR_LIST__;
    while (1) {
        dtor_func dtor = (dtor_func)*dtor_p;
        if (!dtor) {
            break;
        } else {
            dtor();
        }
        dtor_p++;
    }
}
__attribute__((section(".init.halide"))) void run_ctors() {
    typedef void (*ctor_func)();
    addr_t *ctor_p = &__CTOR_END__;
    while (1) {
        ctor_func ctor = (ctor_func) * (--ctor_p);
        if (!ctor) {
            break;
        } else {
            ctor();
        }
    }
}
}  // extern "C"
back to top