We use vdso version of getcpu(...) for example; and its signature is
using Func = int (*)(unsigned* cpu, unsigned* node, void* unused);
Func resolveVdsoFunc() {
#if !defined(FOLLY_HAVE_LINUX_VDSO) || defined(FOLLY_SANITIZE_MEMORY)
return nullptr;
#else
void* h = dlopen("linux-vdso.so.1", RTLD_LAZY | RTLD_LOCAL | RTLD_NOLOAD);
if (h == nullptr) {
return nullptr;
}
auto func = Func(dlsym(h, "__vdso_getcpu"));
if (func == nullptr) {
// technically a null result could either be a failure or a successful
// lookup of a symbol with the null value, but the second can't actually
// happen for this symbol. No point holding the handle forever if
// we don't need the code
dlclose(h);
}
return func;
#endif
}
We could find this usage in Folly lib:
https://github.com/facebook/folly/blob/535d0313371b1c8d313ec8a1cd09b940fa992397/folly/concurrency/CacheLocality.cpp#L310
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.