Small fixes for snmalloc used in FreeBSD libc. (#454)

- Mark the hook that we're exporting for the threading library to call
   to clean up per-thread malloc state as 'used'.  It was changed to
   `inline` to allow duplicate copies of it to be merged but this also
   means that it isn't emitted at all in compilation units that don't
   use it (and it isn't used internally at all).
 - Fix the `__je_bootstrap_*` functions, which are used to bootstrap TLS
   allocation, for the changes to `ScopedAllocator`.

The `__je_bootstrap*` functions weren't being built in CI.  They now are
for non-PIE targets with a smoke test.
This commit is contained in:
David Chisnall
2022-01-21 14:19:26 +00:00
committed by GitHub
parent ef64f6c31b
commit f1be609cdb
4 changed files with 15 additions and 3 deletions

View File

@@ -4,6 +4,7 @@
#define SNMALLOC_NAME_MANGLE(a) our_##a
#undef SNMALLOC_NO_REALLOCARRAY
#undef SNMALLOC_NO_REALLOCARR
#define SNMALLOC_BOOTSTRAP_ALLOCATOR
#include "../../../override/malloc.cc"
using namespace snmalloc;
@@ -338,6 +339,14 @@ int main(int argc, char** argv)
abort();
}
#ifndef __PIC__
snmalloc::debug_check_empty<snmalloc::Globals>();
void* bootstrap = __je_bootstrap_malloc(42);
if (bootstrap == nullptr)
{
printf("Failed to allocate from bootstrap malloc\n");
}
__je_bootstrap_free(bootstrap);
#endif
return 0;
}