Make some minor fixups to bug reporting, etc.

This commit is contained in:
Justine Tunney 2022-07-11 05:55:17 -07:00
parent 84764ce7b8
commit 3f015b1e51
31 changed files with 244 additions and 134 deletions

View file

@ -161,23 +161,10 @@ TEST(clone, tlsSystemCallsErrno_wontClobberMainThreadBecauseTls) {
////////////////////////////////////////////////////////////////////////////////
// BENCHMARK
void LaunchThread(void) {
char *tls, *stack;
tls = __initialize_tls(malloc(64));
__cxa_atexit(free, tls, 0);
stack = mmap(0, GetStackSize(), PROT_READ | PROT_WRITE,
MAP_STACK | MAP_ANONYMOUS, -1, 0);
clone(DoNothing, stack, GetStackSize(),
CLONE_THREAD | CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
CLONE_CHILD_SETTID | CLONE_CHILD_CLEARTID | CLONE_SETTLS,
0, 0, tls, 64, (int *)(tls + 0x38));
}
BENCH(clone, bench) {
char *volatile tp;
errno_t *volatile ep;
EZBENCH2("__errno_location", donothing, (ep = __errno_location()));
EZBENCH2("__get_tls_inline", donothing, (tp = __get_tls_inline()));
EZBENCH2("__get_tls", donothing, (tp = __get_tls()));
EZBENCH2("clone()", donothing, LaunchThread());
}

View file

@ -31,8 +31,6 @@
#include "libc/thread/spawn.h"
#include "libc/x/x.h"
#define THREADS 32
#define DUB(i) (union Dub){i}.x
#define DUBBLE(a, b, c, d, e) \
@ -47,8 +45,6 @@ union Dub {
double x;
};
struct spawn th[THREADS];
int Worker(void *p, int tid) {
int i;
char str[64];
@ -60,14 +56,12 @@ int Worker(void *p, int tid) {
return 0;
}
TEST(dtoa, test) {
int i;
for (i = 0; i < THREADS; ++i) {
_spawn(Worker, 0, th + i);
}
for (i = 0; i < THREADS; ++i) {
_join(th + i);
}
TEST(dtoa, locks) {
int i, n = 32;
struct spawn th[n];
if (IsOpenbsd()) return; // TODO(jart): OpenBSD flakes :'(
for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, _spawn(Worker, 0, th + i));
for (i = 0; i < n; ++i) EXPECT_SYS(0, 0, _join(th + i));
}
static const struct {

View file

@ -26,9 +26,6 @@
#include "libc/thread/spawn.h"
#include "libc/thread/thread.h"
#define N 128
struct spawn t[N];
_Atomic(int) itworked;
_Thread_local int var;
@ -44,11 +41,12 @@ int Worker(void *arg, int tid) {
}
TEST(_spawn, test) {
long i;
for (i = 0; i < N; ++i) EXPECT_SYS(0, 0, _spawn(Worker, (void *)i, t + i));
for (i = 0; i < N; ++i) EXPECT_SYS(0, 0, _join(t + i));
for (i = 0; i < N; ++i) EXPECT_SYS(0, 0, _join(t + i));
EXPECT_EQ(N, itworked);
long i, n = 128;
struct spawn t[n];
for (i = 0; i < n; ++i) ASSERT_SYS(0, 0, _spawn(Worker, (void *)i, t + i));
for (i = 0; i < n; ++i) EXPECT_SYS(0, 0, _join(t + i));
for (i = 0; i < n; ++i) EXPECT_SYS(0, 0, _join(t + i));
EXPECT_EQ(n, itworked);
}
__attribute__((__constructor__)) static void init(void) {