Clean up some of the threading code

This commit is contained in:
Justine Tunney 2022-09-08 11:54:56 -07:00
parent 0547eabcd6
commit 9f963dc597
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
62 changed files with 175 additions and 582 deletions

View file

@ -29,7 +29,7 @@
#include "libc/fmt/itoa.h"
#include "libc/intrin/atomic.h"
#include "libc/intrin/kprintf.h"
#include "libc/intrin/spinlock.h"
#include "libc/intrin/pthread.h"
#include "libc/intrin/weaken.h"
#include "libc/log/check.h"
#include "libc/log/internal.h"
@ -52,7 +52,7 @@ static int x;
char g_testlib_olddir[PATH_MAX];
char g_testlib_tmpdir[PATH_MAX];
struct sigaction wanthandlers[31];
static char testlib_error_lock;
static pthread_spinlock_t testlib_error_lock;
void testlib_finish(void) {
if (g_testlib_failed) {
@ -64,7 +64,7 @@ void testlib_finish(void) {
void testlib_error_enter(const char *file, const char *func) {
atomic_fetch_sub_explicit(&__ftrace, 1, memory_order_relaxed);
atomic_fetch_sub_explicit(&__strace, 1, memory_order_relaxed);
if (!__vforked) _spinlock(&testlib_error_lock);
if (!__vforked) pthread_spin_lock(&testlib_error_lock);
if (!IsWindows()) sys_getpid(); /* make strace easier to read */
if (!IsWindows()) sys_getpid();
if (g_testlib_shoulddebugbreak) {
@ -77,7 +77,7 @@ void testlib_error_enter(const char *file, const char *func) {
void testlib_error_leave(void) {
atomic_fetch_add_explicit(&__ftrace, 1, memory_order_relaxed);
atomic_fetch_add_explicit(&__strace, 1, memory_order_relaxed);
_spunlock(&testlib_error_lock);
pthread_spin_unlock(&testlib_error_lock);
}
wontreturn void testlib_abort(void) {