Niels Sascha Reedijk 92b3138b83 Import GCC 13.1.0 and dependencies
Updated dependencies:
 * GMP 6.2.1
 * ISL 0.24
 * MPL 1.2.1
 * MPFR 4.1.0

The dependencies were pulled in by running the ./contrib/download_prerequisites script and then
manually removing the symbolic links and archives, and renaming the directories (i.e mv isl-0.24 to isl)
2023-06-18 01:43:18 +01:00

40 lines
993 B
D

import core.runtime;
import core.atomic;
import core.stdc.string;
import core.sys.posix.dlfcn;
shared uint tlsDtor, dtor;
void staticDtorHook() { atomicOp!"+="(tlsDtor, 1); }
void sharedStaticDtorHook() { atomicOp!"+="(dtor, 1); }
void runTest(string name)
{
auto h = Runtime.loadLibrary(name);
assert(h !is null);
*cast(void function()*).dlsym(h, "_D9lib_1341414staticDtorHookOPFZv") = &staticDtorHook;
*cast(void function()*).dlsym(h, "_D9lib_1341420sharedStaticDtorHookOPFZv") = &sharedStaticDtorHook;
Runtime.unloadLibrary(h);
version (CRuntime_Musl)
{
// On Musl, unloadLibrary is a no-op because dlclose is a no-op
assert(tlsDtor == 0);
assert(dtor == 0);
}
else
{
assert(tlsDtor == 1);
assert(dtor == 1);
}
}
void main(string[] args)
{
auto name = args[0] ~ '\0';
const pathlen = strrchr(name.ptr, '/') - name.ptr + 1;
name = name[0 .. pathlen] ~ "lib_13414.so";
runTest(name);
}