allow libtcc states to be used concurrently
commit72729d8e360489416146d6d4fd6bc57c9c72c29b
authorgrischka <grischka>
Tue, 10 Dec 2019 23:37:18 +0000 (11 00:37 +0100)
committergrischka <grischka>
Wed, 11 Dec 2019 01:36:19 +0000 (11 02:36 +0100)
tree3426762499162c5fa7384f2758549cb426ed7324
parent6082dd62bb496ea4863f8a5501e480ffab775395
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.
29 files changed:
.gitignore
Makefile
arm-asm.c
arm-gen.c
arm-link.c
arm64-gen.c
arm64-link.c
c67-gen.c
c67-link.c
i386-asm.c
i386-gen.c
i386-link.c
libtcc.c
riscv64-gen.c
riscv64-link.c
tcc.c
tcc.h
tccasm.c
tcccoff.c
tccelf.c
tccgen.c
tccpe.c
tccpp.c
tccrun.c
tcctools.c
tests/Makefile
tests/libtcc_test_mt.c [new file with mode: 0644]
x86_64-gen.c
x86_64-link.c