Make more improvements to threading support

- fix rare thread exit race condition on openbsd
- pthread_getattr_np() now supplies detached status
- child threads may now pthread_join() the main thread
- introduce sigandset(), sigorset(), and sigisemptyset()
- introduce pthread_cleanup_push() and pthread_cleanup_pop()
This commit is contained in:
Justine Tunney 2022-10-08 23:54:05 -07:00
parent 38df0a4186
commit 4a6fd3d910
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
52 changed files with 586 additions and 241 deletions

View file

@ -16,19 +16,24 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/intrin/strace.internal.h"
#include "libc/dce.h"
#include "libc/intrin/asmflag.h"
#include "libc/intrin/promises.internal.h"
#include "libc/intrin/strace.internal.h"
#include "libc/nt/thread.h"
#include "libc/runtime/runtime.h"
#include "libc/sysv/consts/nr.h"
#include "libc/thread/tls.h"
__msabi extern typeof(ExitThread) *const __imp_ExitThread;
/**
* Terminates thread with raw system call.
*
* The function you want is pthread_exit(). If you call this function
* whilst using the pthreads then your joiners might not get woken up
* on non-Linux platforms where we zero __get_tls()->tib_tid manually
*
* If this is the main thread, or an orphaned child thread, then this
* function is equivalent to exiting the process; however, `rc` shall
* only be reported to the parent process on Linux, FreeBSD & Windows