Revert "Remove harmful attempts to be helpful in pthread_mutex functions."

This reverts commit 471c4e5b5611910ab1c28348b1c345eeaf4eaef8.
Revert "Clean up the pthread-only atomic stuff a little."

This reverts commit f4acaad4263b1796ec1ab51e43443ddfaf125960.