Tidy up the threading implementation

The organization of the source files is now much more rational.
Old experiments that didn't work out are now deleted. Naming of
things like files is now more intuitive.
This commit is contained in:
Justine Tunney 2022-09-10 02:56:25 -07:00
parent e9272f03fb
commit 155b378a39
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
199 changed files with 526 additions and 685 deletions

View file

@ -37,8 +37,6 @@
#include "libc/mem/alg.h"
#include "libc/mem/bisectcarleft.internal.h"
#include "libc/nexgen32e/gc.internal.h"
#include "libc/nexgen32e/gettls.h"
#include "libc/nexgen32e/threaded.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/stack.h"
@ -49,7 +47,7 @@
#include "libc/sysv/consts/fileno.h"
#include "libc/sysv/consts/o.h"
#include "libc/sysv/consts/sig.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
#include "libc/x/x.h"
#define kBacktraceMaxFrames 128
@ -109,7 +107,7 @@ static int PrintBacktraceUsingAddr2line(int fd, const struct StackFrame *bp) {
argv[i++] = "-a"; /* filter out w/ shell script wrapper for old versions */
argv[i++] = "-pCife";
argv[i++] = debugbin;
garbage = __tls_enabled ? ((cthread_t)__get_tls())->garbages : 0;
garbage = __tls_enabled ? __get_tls()->tib_garbages : 0;
gi = garbage ? garbage->i : 0;
for (frame = bp; frame && i < kBacktraceMaxFrames - 1; frame = frame->next) {
addr = frame->addr;

View file

@ -26,14 +26,12 @@
#include "libc/macros.internal.h"
#include "libc/mem/bisectcarleft.internal.h"
#include "libc/nexgen32e/gc.internal.h"
#include "libc/nexgen32e/gettls.h"
#include "libc/nexgen32e/stackframe.h"
#include "libc/nexgen32e/threaded.h"
#include "libc/runtime/memtrack.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/symbols.internal.h"
#include "libc/str/str.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
#define LIMIT 100
@ -57,7 +55,7 @@ noinstrument noasan int PrintBacktraceUsingSymbols(int fd,
struct Garbages *garbage;
const struct StackFrame *frame;
if (!bp) bp = __builtin_frame_address(0);
garbage = __tls_enabled ? ((cthread_t)__get_tls())->garbages : 0;
garbage = __tls_enabled ? __get_tls()->tib_garbages : 0;
gi = garbage ? garbage->i : 0;
for (i = 0, frame = bp; frame; frame = frame->next) {
if (++i == LIMIT) {

View file

@ -35,7 +35,7 @@
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/nexgen32e/stackframe.h"
#include "libc/nexgen32e/threaded.h"
#include "libc/thread/tls.h"
#include "libc/runtime/internal.h"
#include "libc/runtime/pc.internal.h"
#include "libc/runtime/runtime.h"

View file

@ -20,10 +20,8 @@
#include "libc/intrin/kprintf.h"
#include "libc/log/log.h"
#include "libc/nexgen32e/gc.internal.h"
#include "libc/nexgen32e/gettls.h"
#include "libc/nexgen32e/threaded.h"
#include "libc/stdio/stdio.h"
#include "libc/thread/thread.h"
#include "libc/thread/tls.h"
// clang-format off
/**
@ -38,7 +36,7 @@ void PrintGarbage(void) {
kprintf(" SHADOW STACK @ %p\n", __builtin_frame_address(0));
kprintf("garbage ent. parent frame original ret callback arg \n");
kprintf("------------ ------------ ------------------ ------------------ ------------------\n");
if ((g = __tls_enabled ? ((cthread_t)__get_tls())->garbages:0) && g->i) {
if ((g = __tls_enabled ? __get_tls()->tib_garbages:0) && g->i) {
for (i = g->i; i--;) {
symbol = __get_symbol_by_addr(g->p[i].ret);
if (symbol) {