libthread_xu - Fix rtld and refactor locks
* Add a separate atfork facility for internal pthread atfork entities
(sem and rtld) which must execute after all user atfork entities
pre-fork and before all user atfork entities post-fork.
* Install an atfork handler for rtld-elf (also requires rtld-elf to
be updated). The handler will ensure that RTLD locks are in a sane
state prior to fork (by acquiring them), and will then release the
locks post-fork. This is the primary fix for lang/rust and cargo.
Also do not issue _thr_rtld_fini() when threading drops to 0.
Once threading has been set, rtld's pthread locks remain installed.
* Refactor thr_cond.c. Refactor condition variables to perform
according to the spec. Use a TAILQ to make pthread_cond_signal()
work exactly as described in the manual (that is, waking up only
one waiter at a time).
* Refactor thr_mutex.c. Primary instrument for debugging and
clean up. Also deal with improper EINTR handling.
* Refactor thr_fork.c. Implement the new atfork facility for
internal atfork handlers.
* Refactor thr_rwlock.c. Add debugging, cleanup.
* thr_sem.c now uses the internal atfork handler to ensure proper
ordering.
* thr_sig.c implements debugging features.
* Refactor thr_umtx.c... the low level mutex code. Store the id
for additonal verification and use an atomic lock to clear the
lock instead of an assignment. Properly ignore EINTR.
* Cleanup init_private() a bit.
* Add PTHREADS_DEBUGGING=TRUE and PTHREADS_DEBUGGING2=TRUE make
flags. The first writes out a garbage file in /tmp for all
locking operations as they occur. The second is used for
point debugging and writes out a file when signal 63 is sent
to the program.
* Add cpu_ccfence() in various places that might need it (a hack
for the moment, userland cannot currently #include
"machine/cpufunc.h").
* Should fix lang/rust and 'cargo'
- [DB] lib/libthread_xu/thread/thr_sig.c