mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
Workaround WSL not supporting x87 in ucontext_t
This commit is contained in:
parent
d6ff4c754e
commit
fae0c0286f
8 changed files with 13 additions and 11 deletions
2
Makefile
2
Makefile
|
@ -60,7 +60,7 @@
|
|||
# build/config.mk
|
||||
|
||||
SHELL = build/bootstrap/cocmd.com
|
||||
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 win10 xnu
|
||||
HOSTS ?= freebsd openbsd netbsd rhel7 rhel5 xnu win10 win10:31338
|
||||
MAKEFLAGS += -j --no-builtin-rules
|
||||
|
||||
.SUFFIXES:
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
|
||||
privileged void _ntcontext2linux(ucontext_t *ctx, const struct NtContext *cr) {
|
||||
if (!cr) return;
|
||||
ctx->uc_flags = cr->EFlags;
|
||||
ctx->uc_mcontext.eflags = cr->EFlags;
|
||||
ctx->uc_mcontext.rax = cr->Rax;
|
||||
ctx->uc_mcontext.rbx = cr->Rbx;
|
||||
|
@ -51,7 +50,6 @@ privileged void _ntcontext2linux(ucontext_t *ctx, const struct NtContext *cr) {
|
|||
|
||||
privileged void _ntlinux2context(struct NtContext *cr, const ucontext_t *ctx) {
|
||||
if (!cr) return;
|
||||
cr->EFlags = ctx->uc_flags;
|
||||
cr->EFlags = ctx->uc_mcontext.eflags;
|
||||
cr->Rax = ctx->uc_mcontext.rax;
|
||||
cr->Rbx = ctx->uc_mcontext.rbx;
|
||||
|
|
|
@ -51,7 +51,6 @@ privileged void __sigenter_freebsd(int sig, struct siginfo_freebsd *freebsdinfo,
|
|||
g.uc.uc_stack.ss_sp = ctx->uc_stack.ss_sp;
|
||||
g.uc.uc_stack.ss_size = ctx->uc_stack.ss_size;
|
||||
g.uc.uc_stack.ss_flags = ctx->uc_stack.ss_flags;
|
||||
g.uc.uc_flags = ctx->uc_flags;
|
||||
__repmovsb(&g.uc.uc_sigmask, &ctx->uc_sigmask,
|
||||
MIN(sizeof(g.uc.uc_sigmask), sizeof(ctx->uc_sigmask)));
|
||||
g.uc.uc_mcontext.r8 = ctx->uc_mcontext.mc_r8;
|
||||
|
|
|
@ -47,7 +47,6 @@ privileged void __sigenter_netbsd(int sig, struct siginfo_netbsd *si,
|
|||
__repstosb(&uc, 0, sizeof(uc));
|
||||
__siginfo2cosmo(&si2, (void *)si);
|
||||
uc.uc_mcontext.fpregs = &uc.__fpustate;
|
||||
uc.uc_flags = ctx->uc_flags;
|
||||
uc.uc_stack.ss_sp = ctx->uc_stack.ss_sp;
|
||||
uc.uc_stack.ss_size = ctx->uc_stack.ss_size;
|
||||
uc.uc_stack.ss_flags = ctx->uc_stack.ss_flags;
|
||||
|
|
|
@ -471,7 +471,6 @@ privileged void __sigenter_xnu(void *fn, int infostyle, int sig,
|
|||
} else {
|
||||
__repstosb(&g, 0, sizeof(g));
|
||||
if (xnuctx) {
|
||||
g.uc.uc_flags = xnuctx->uc_onstack ? SA_ONSTACK : 0;
|
||||
g.uc.uc_sigmask.__bits[0] = xnuctx->uc_sigmask;
|
||||
g.uc.uc_sigmask.__bits[1] = 0;
|
||||
g.uc.uc_stack.ss_sp = xnuctx->uc_stack.ss_sp;
|
||||
|
|
|
@ -72,7 +72,7 @@ struct MachineContext {
|
|||
typedef struct MachineContext mcontext_t;
|
||||
|
||||
struct ucontext {
|
||||
uint64_t uc_flags;
|
||||
uint64_t uc_flags; /* don't use this */
|
||||
struct ucontext *uc_link;
|
||||
stack_t uc_stack;
|
||||
mcontext_t uc_mcontext; /* use this */
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
#include "libc/dce.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/nexgen32e/nexgen32e.h"
|
||||
#include "libc/runtime/internal.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/sa.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/sysv/consts/uc.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
#include "third_party/xed/x86.h"
|
||||
|
||||
|
@ -196,6 +198,8 @@ TEST(sigaction, autoZombieSlayer) {
|
|||
// verify it works
|
||||
ASSERT_NE(-1, (pid = fork()));
|
||||
if (!pid) _Exit(0);
|
||||
// XXX: WSL does the wrong thing here.
|
||||
if (__is_wsl()) usleep(10);
|
||||
ASSERT_SYS(ECHILD, -1, wait(0));
|
||||
// clean up
|
||||
ASSERT_SYS(0, 0, sigaction(SIGCHLD, &sa, 0));
|
||||
|
|
|
@ -325,10 +325,13 @@ TEST(ShowCrashReports, testDivideByZero) {
|
|||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
if (!strstr(output, "3.141")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have fpu register\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
// XXX: WSL doesn't save and restore x87 registers to ucontext_t
|
||||
if (!__is_wsl()) {
|
||||
if (!strstr(output, "3.141")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have fpu register\n%s\n",
|
||||
_gc(IndentLines(output, -1, 0, 4)));
|
||||
__die();
|
||||
}
|
||||
}
|
||||
if (!strstr(output, "0f0e0d0c0b0a09080706050403020100")) {
|
||||
fprintf(stderr, "ERROR: crash report didn't have sse register\n%s\n",
|
||||
|
|
Loading…
Reference in a new issue