| /* ---------------------------------------------------------------------------- | |
| Copyright (c) 2018-2023, Microsoft Research, Daan Leijen | |
| This is free software; you can redistribute it and/or modify it under the | |
| terms of the MIT license. A copy of the license can be found in the file | |
| "LICENSE" at the root of this distribution. | |
| -----------------------------------------------------------------------------*/ | |
| // Select the implementation of the primitives | |
| // depending on the OS. | |
| // Generic process initialization | |
| // gcc,clang: use the constructor/destructor attribute | |
| // which for both seem to run before regular constructors/destructors | |
| static void mi_attr_constructor mi_process_attach(void) { | |
| _mi_auto_process_init(); | |
| } | |
| static void mi_attr_destructor mi_process_detach(void) { | |
| _mi_auto_process_done(); | |
| } | |
| // C++: use static initialization to detect process start/end | |
| // This is not guaranteed to be first/last but the best we can generally do? | |
| struct mi_init_done_t { | |
| mi_init_done_t() { | |
| _mi_auto_process_init(); | |
| } | |
| ~mi_init_done_t() { | |
| _mi_auto_process_done(); | |
| } | |
| }; | |
| static mi_init_done_t mi_init_done; | |
| // Generic allocator init/done callback | |
| bool _mi_is_redirected(void) { | |
| return false; | |
| } | |
| bool _mi_allocator_init(const char** message) { | |
| if (message != NULL) { *message = NULL; } | |
| return true; | |
| } | |
| void _mi_allocator_done(void) { | |
| // nothing to do | |
| } | |