Files
hakmem/bench_mi_force.c

23 lines
608 B
C
Raw Normal View History

// bench_mi_force.c
// Force a reference to a mimalloc symbol so the dynamic linker
// retains libmimalloc as a NEEDED dependency even with --as-needed.
#include <stddef.h>
#if defined(__cplusplus)
extern "C" {
#endif
// Declaration; actual signature returns const char* in mimalloc.
const char* mi_version(void);
#if defined(__cplusplus)
}
#endif
// Keep a reachable reference so it isn't optimized out completely.
static const void* (*volatile mi_ver_ref)(void) = (const void*(*)(void))mi_version;
void hakmem_bench_mi_force_link(void) {
// Prevent whole-call optimization away
(void)mi_ver_ref;
}