| 5 | #include "smoke_api/smoke_api.hpp" |
| 6 | |
| 7 | extern "C" void __attribute__((constructor)) init() { |
| 8 | // On linux we don't automatically get current module handle, |
| 9 | // hence we find it manually |
| 10 | Dl_info info; |
| 11 | if(dladdr(reinterpret_cast<void*>(&init), &info) && info.dli_fname) { |
| 12 | void* handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD); |
| 13 | smoke_api::init(handle); |
| 14 | } else { |
| 15 | koalabox::util::panic("Initialization error: failed to get own module handle."); |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | extern "C" void __attribute__((destructor)) fini() { |
| 20 | smoke_api::shutdown(); |