Make improvements

- Get threads working on NetBSD
- Get threads working on OpenBSD
- Fix Emacs config for Emacs v28
- Improve --strace logging of sigset_t
- Improve --strace logging of struct stat
- Improve memory safety of DescribeThing functions
- Refactor auto stack allocation into LIBC_RUNTIME
- Introduce shell.com example which works on Windows
- Refactor __strace_thing into DescribeThing functions
- Document the CHECK macros and improve them in NDEBUG mode
- Rewrite MAP_STACK so it uses FreeBSD behavior across platforms
- Deprecate and discourage the use of MAP_GROWSDOWN (it's weird)
This commit is contained in:
Justine Tunney 2022-05-12 06:43:59 -07:00
parent dd9ab01d25
commit e7611a8476
101 changed files with 967 additions and 464 deletions

View file

@ -20,6 +20,8 @@
#include "libc/dce.h"
#include "libc/intrin/spinlock.h"
#include "libc/sysv/consts/clone.h"
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/prot.h"
#include "libc/testlib/testlib.h"
int x, thechilde;
@ -41,17 +43,18 @@ int thread(void *arg) {
TEST(clone, test) {
if (IsXnu()) return;
if (IsOpenbsd()) return; // still flaky :'(
int me, tid;
char *stack;
me = gettid();
_spinlock(&lock);
stack = _gc(valloc(STACKSIZE));
ASSERT_NE(-1, (tid = clone(thread, stack, STACKSIZE,
stack = mmap(0, FRAMESIZE, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
ASSERT_NE(-1, (tid = clone(thread, stack, FRAMESIZE,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND,
(void *)23, 0, 0, 0, 0)));
_spinlock(&lock);
ASSERT_EQ(42, x);
ASSERT_NE(me, tid);
ASSERT_EQ(tid, thechilde);
EXPECT_SYS(0, 0, munmap(stack, FRAMESIZE));
}