Perhaps we've been coming at this from the wrong direction;
I'm not quite sure one would need two compiler instances to recompile a single function.
as far as i can tell "recompiling a function" is not a feature of libtcc. you get "error: 'foo' defined twice" as you would with other compilers. there's no way to delete a compiled function.
TCC allows you to allocate memory for an object/function/program yourself- you call tcc_relocate with NULL for the 'ptr' parameter, and it returns
the number of bytes needed to hold the object.
you can relocate, but you cannot allocate ahead of time. also, in my experience, the compiled function is still dependent on the tcc instance that compiled it even after a relocation. delete the instance that compiled foo and foo will sometimes crash.
This means that that memory is no longer bound to or managed by TCC.
not in my experience. look here:
I know when I've adapted TCC to cache function handlers, I just update the pointer to the handler function and then
free() the old pointer; but this was single-threaded use, and I was disposing of TCC in between (re)compilations.
For multi-threaded use, I believe you would just need a mutex to synchronize access the pointer.
Have you tried this? Or is there some other stuff your code is doing that needs two compiler instances?
i have no need of two compilers other than as a hack to recompile a function.
Tinycc-devel mailing list