Safeishly use non-reentrant libraries with POSIX threads
12 points by runxiyu
12 points by runxiyu
Nice demo, but I hope I never have to use this.
typeof
is a GNU extension. It could be avoided by using macros.
Not any more! It’s in C23.
This is a good demo. I think a world where we were using linker namespaces much more would be a better world. Sadly most people and languages don’t bother to know about them, and instead just hack up their own solution, and this will probably never change. So I don’t think about them too much, since it will just make me annoyed.
The other thing limiting the utility of linker namespaces (at least in glibc, maybe SunOs lineage is better) is that it maxes out at 16 namespaces. Every time I’ve wanted to use it in anger this has been a dealbreaker.
Unfortunately, this will not work on… basically all non-glibc systems, so a hacky solution would be required (perhaps I’ll make one based on hax_loader sometime)
:(
dlmopen(3C) is available on illumos as well, FWIW, despite not being a glibc-based system.
Also, it’s not actually a GNU extension, it came from SunOS as far as I know.
I’m not sure where the original version came from, but even on Linux, bionic has this facility (I thought it came from there before glibc, but I could be wrong) and uses it to put the system libraries and NDK code in different namespaces so bumping libc++ in system code doesn’t impact NDK code.