]> git.draconx.ca Git - cdecl99.git/commit
libcdecl: Fix TLS cleanup on Windows.
authorNick Bowler <nbowler@draconx.ca>
Sat, 27 Jan 2024 04:50:19 +0000 (23:50 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sat, 27 Jan 2024 21:02:09 +0000 (16:02 -0500)
commit898aa30bfb038ffeca54d6dea95f0f80fbc08f7f
tree36d7502cae2bc8de96cc877038fd3d61ed8fd6fe
parent9786185611c072036751fdfcc1731158a0c2d20c
libcdecl: Fix TLS cleanup on Windows.

The DllMain entry point is pretty much designed for this purpose and
works in all versions of Windows that support threads.  This is the
technique used by pthreads-win32.  But it only works for DLLs.

For static linking into executables, there is a special table of
function pointers that are called by the runtime in pretty much the
same situations as DllMain.  This apparently works starting around
Windows XP timeframe, and is the technique used by libwinpthread.

We combine both techniques so at least the DLL cleanup works even
on very old versions of Windows.  The static library cleanup will
work on contemporary versions.

To test this, we need to restructure the thread test program to link
against a real (uninstalled) DLL with the test entry points.
Makefile.am
src/thread-w32.h
t/errmemwrap.c [moved from t/memwrap.c with 88% similarity]
t/errthread.c
tests/internal.at