This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Writing a thread-safe library without pulling in pthreads
* Ian Lance Taylor:
>> But I'm hosed if a library is loaded later (via dlopen) that pulls in
>> threads, right? This looks unsupported, so it should be okay if I can't
>> deal with this situation.
>
> Yes, you are probably hosed in that case. Offhand I can't think of
> any reasonable way to make that work correctly, given that the dlopen
> might occur when a lock would nominally be held.
Hmm, but that could only happen if dlopen is called from a signal
handler. I suppose calling an signal-handler-safe function cannot
trigger arbitrary DSO loading (otherwise, this would be a bug).
I don't plan to hold the lock during callbacks or returns to the caller,
so I should be fine. I just want to protect the state of a PRNG.
Sorry for posting to the wrong mailing list, BTW. I intended to post to
libc-help. 8-)