allow libtcc states to be used concurrently

This allows creation of TCCStates and operation with API
calls independently from each other, even from threads.

Frontend (option parsing/libtcc.c) and backend (linker/tccelf.c)
now depend only on the TCCState (s1) argument.

Compilation per se (tccpp.c, tccgen.c) is still using
globals for convenience.  There is only one entry point
to this section which is tcc_compile() which is protected
by a semaphore.

There are some hacks involved to avoid too many changes,
as well as some changes in order to avoid too many hacks ;)

The test libtcc_test_mt.c shows the feature.  Except this
new file the patch adds 87 lines overall.
This commit is contained in:
grischka
2019-12-11 00:37:18 +01:00
parent 6082dd62bb
commit 72729d8e36
29 changed files with 805 additions and 418 deletions

1
.gitignore vendored
View File

@@ -50,6 +50,7 @@ tests/*.gcc
tests/*-cc*
tests/*-tcc*
tests/libtcc_test
tests/libtcc_test_mt
tests/asm-c-connect
tests/asm-c-connect-sep
tests/vla_test