mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Fix some todos
This commit is contained in:
parent
9d372f48dd
commit
9cc4f33c76
13 changed files with 261 additions and 139 deletions
|
@ -100,7 +100,7 @@ static int cosmo_clock_nanosleep(int clock, int flags,
|
|||
if (timespec_cmp(remain, quantum) > 0) {
|
||||
waitfor = timespec_sub(remain, quantum);
|
||||
if (sys_clock_nanosleep(sleep_clock, 0, &waitfor, rem) == -1) {
|
||||
if (rem && errno == EINTR) {
|
||||
if (!flags && rem && errno == EINTR) {
|
||||
*rem = timespec_add(*rem, quantum);
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
.privileged
|
||||
|
||||
diagnose_syscall:
|
||||
push %rbp
|
||||
mov %rsp,%rbp
|
||||
push %rbx
|
||||
push %r12
|
||||
push %r13
|
||||
push %r14
|
||||
push %r15
|
||||
|
||||
mov $0x7fffffff,%eax
|
||||
add $4,%eax # set sf/of/pf
|
||||
|
||||
mov %rdi,%rax # nr
|
||||
mov %rsi,%rdi # arg 1
|
||||
mov %rdx,%rsi # arg 2
|
||||
mov %rcx,%rdx # arg 3
|
||||
mov %r8,%r10 # arg 4
|
||||
mov %r9,%r8 # arg 5
|
||||
mov 16(%rbp),%r9 # arg 6
|
||||
push 24(%rbp) # arg 7
|
||||
push %rax # fake ret addr
|
||||
mov 32(%rbp),%r12 # ucontext before
|
||||
mov 40(%rbp),%r13 # ucontext after
|
||||
xor %ecx,%ecx
|
||||
xor %r11d,%r11d
|
||||
mov $0x5555555555555555,%r11
|
||||
mov $0x5555555555555555,%r14
|
||||
mov $0x5555555555555555,%r15
|
||||
mov $0x5555555555555555,%rbx
|
||||
|
||||
// save machine state before system call
|
||||
pushf
|
||||
pop 176(%r12)
|
||||
mov %r8,40(%r12)
|
||||
mov %r9,48(%r12)
|
||||
mov %r10,56(%r12)
|
||||
mov %r11,64(%r12)
|
||||
mov %r12,72(%r12)
|
||||
mov %r13,80(%r12)
|
||||
mov %r14,88(%r12)
|
||||
mov %r15,96(%r12)
|
||||
mov %rdi,104(%r12)
|
||||
mov %rsi,112(%r12)
|
||||
mov %rbp,120(%r12)
|
||||
mov %rbx,128(%r12)
|
||||
mov %rdx,136(%r12)
|
||||
mov %rax,144(%r12)
|
||||
mov %rcx,152(%r12)
|
||||
push %rbx
|
||||
lea 320(%r12),%rbx
|
||||
mov %rbx,224(%r12) # set fpregs ptr
|
||||
pop %rbx
|
||||
|
||||
syscall
|
||||
|
||||
// save machine state after system call
|
||||
pushf
|
||||
pop 176(%r13)
|
||||
mov %r8,40(%r13)
|
||||
mov %r9,48(%r13)
|
||||
mov %r10,56(%r13)
|
||||
mov %r11,64(%r13)
|
||||
mov %r12,72(%r13)
|
||||
mov %r13,80(%r13)
|
||||
mov %r14,88(%r13)
|
||||
mov %r15,96(%r13)
|
||||
mov %rdi,104(%r13)
|
||||
mov %rsi,112(%r13)
|
||||
mov %rbp,120(%r13)
|
||||
mov %rbx,128(%r13)
|
||||
mov %rdx,136(%r13)
|
||||
mov %rax,144(%r13)
|
||||
mov %rcx,152(%r13)
|
||||
push %rbx
|
||||
lea 320(%r13),%rbx
|
||||
mov %rbx,224(%r13) # set fpregs ptr
|
||||
pop %rbx
|
||||
|
||||
pop %r13
|
||||
pop %r13
|
||||
|
||||
pop %r15
|
||||
pop %r14
|
||||
pop %r13
|
||||
pop %r12
|
||||
pop %rbx
|
||||
pop %rbp
|
||||
ret
|
||||
.endfn diagnose_syscall,globl
|
|
@ -18,11 +18,13 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rlimit.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/runtime/stack.h"
|
||||
#include "libc/runtime/syslib.internal.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
@ -40,6 +42,8 @@ int getrlimit(int resource, struct rlimit *rlim) {
|
|||
rc = einval();
|
||||
} else if (!rlim || (IsAsan() && !__asan_is_valid(rlim, sizeof(*rlim)))) {
|
||||
rc = efault();
|
||||
} else if (IsXnuSilicon()) {
|
||||
rc = _sysret(__syslib->__getrlimit(resource, rlim));
|
||||
} else if (!IsWindows()) {
|
||||
rc = sys_getrlimit(resource, rlim);
|
||||
} else if (resource == RLIMIT_STACK) {
|
||||
|
|
|
@ -342,23 +342,26 @@ static textwindows int ProcessMouseEvent(const struct NtInputRecord *r,
|
|||
bs &= kNtFromLeft1stButtonPressed | kNtRightmostButtonPressed;
|
||||
if (ev & kNtMouseWheeled) {
|
||||
// scroll wheel (unnatural mode)
|
||||
if (!(r->Event.MouseEvent.dwControlKeyState &
|
||||
(kNtShiftPressed | kNtLeftCtrlPressed | kNtRightCtrlPressed |
|
||||
kNtLeftAltPressed | kNtRightAltPressed))) {
|
||||
bool isup = ((int)r->Event.MouseEvent.dwButtonState >> 16) > 0;
|
||||
if (__ttyconf.magic & kTtyXtMouse) {
|
||||
bool isup = ((int)r->Event.MouseEvent.dwButtonState >> 16) > 0;
|
||||
if (__ttyconf.magic & kTtyXtMouse) {
|
||||
if (r->Event.MouseEvent.dwControlKeyState &
|
||||
(kNtLeftCtrlPressed | kNtRightCtrlPressed)) {
|
||||
e = isup ? 80 : 81;
|
||||
goto OutputXtermMouseEvent;
|
||||
} else {
|
||||
// we disable mouse highlighting when the tty is put in raw mode
|
||||
// to mouse wheel events with widely understood vt100 arrow keys
|
||||
*p++ = 033;
|
||||
*p++ = !__keystroke.ohno_decckm ? '[' : 'O';
|
||||
if (isup) {
|
||||
*p++ = 'A';
|
||||
} else {
|
||||
*p++ = 'B';
|
||||
}
|
||||
e = isup ? 64 : 65;
|
||||
}
|
||||
goto OutputXtermMouseEvent;
|
||||
} else if (!(r->Event.MouseEvent.dwControlKeyState &
|
||||
(kNtShiftPressed | kNtLeftCtrlPressed | kNtRightCtrlPressed |
|
||||
kNtLeftAltPressed | kNtRightAltPressed))) {
|
||||
// we disable mouse highlighting when the tty is put in raw mode
|
||||
// to mouse wheel events with widely understood vt100 arrow keys
|
||||
*p++ = 033;
|
||||
*p++ = !__keystroke.ohno_decckm ? '[' : 'O';
|
||||
if (isup) {
|
||||
*p++ = 'A';
|
||||
} else {
|
||||
*p++ = 'B';
|
||||
}
|
||||
}
|
||||
} else if ((bs || currentbs) && (__ttyconf.magic & kTtyXtMouse)) {
|
||||
|
|
|
@ -19,11 +19,13 @@
|
|||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/rlimit.internal.h"
|
||||
#include "libc/calls/syscall-sysv.internal.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/intrin/asan.internal.h"
|
||||
#include "libc/intrin/describeflags.internal.h"
|
||||
#include "libc/intrin/strace.internal.h"
|
||||
#include "libc/macros.internal.h"
|
||||
#include "libc/runtime/syslib.internal.h"
|
||||
#include "libc/sysv/consts/rlimit.h"
|
||||
#include "libc/sysv/errfuns.h"
|
||||
|
||||
|
@ -79,6 +81,8 @@ int setrlimit(int resource, const struct rlimit *rlim) {
|
|||
rc = einval();
|
||||
} else if (!rlim || (IsAsan() && !__asan_is_valid(rlim, sizeof(*rlim)))) {
|
||||
rc = efault();
|
||||
} else if (IsXnuSilicon()) {
|
||||
rc = _sysret(__syslib->__setrlimit(resource, rlim));
|
||||
} else if (!IsWindows()) {
|
||||
rc = sys_setrlimit(resource, rlim);
|
||||
if (IsXnu() && !rc && resource == RLIMIT_AS) {
|
||||
|
|
|
@ -68,6 +68,8 @@ struct Syslib {
|
|||
long (*__sem_post)(int *);
|
||||
long (*__sem_wait)(int *);
|
||||
long (*__sem_trywait)(int *);
|
||||
long (*__getrlimit)(int, void *);
|
||||
long (*__setrlimit)(int, const void *);
|
||||
};
|
||||
|
||||
extern struct Syslib *__syslib;
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#define TLS_ALIGNMENT 64
|
||||
|
||||
#define TIB_FLAG_VFORKED 1
|
||||
#define TIB_FLAG_WINCRASHING 2
|
||||
#define TIB_FLAG_VFORKED 1
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue