Remove some legacy cruft

Function trace logs will report stack usage accurately. It won't include
the argv/environ block. Our clone() polyfill is now simpler and does not
use as much stack memory. Function call tracing on x86 is now faster too
This commit is contained in:
Justine Tunney 2025-01-02 18:44:07 -08:00
parent 8db646f6b2
commit a15958edc6
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
21 changed files with 291 additions and 467 deletions

View file

@ -89,14 +89,14 @@ __msabi extern typeof(WriteFile) *const __imp_WriteFile;
extern pthread_mutex_t __sig_worker_lock;
HAIRY static bool __sig_ignored_by_default(int sig) {
textwindows static bool __sig_ignored_by_default(int sig) {
return sig == SIGURG || //
sig == SIGCONT || //
sig == SIGCHLD || //
sig == SIGWINCH;
}
HAIRY bool __sig_ignored(int sig) {
textwindows bool __sig_ignored(int sig) {
return __sighandrvas[sig] == (intptr_t)SIG_IGN ||
(__sighandrvas[sig] == (intptr_t)SIG_DFL &&
__sig_ignored_by_default(sig));
@ -532,14 +532,14 @@ textwindows void __sig_generate(int sig, int sic) {
}
}
HAIRY static char *__sig_stpcpy(char *d, const char *s) {
textwindows static char *__sig_stpcpy(char *d, const char *s) {
size_t i;
for (i = 0;; ++i)
if (!(d[i] = s[i]))
return d + i;
}
HAIRY wontreturn static void __sig_death(int sig, const char *thing) {
textwindows wontreturn static void __sig_death(int sig, const char *thing) {
#ifndef TINY
intptr_t hStderr;
char sigbuf[21], s[128], *p;
@ -810,7 +810,7 @@ HAIRY static uint32_t __sig_worker(void *arg) {
_pthread_mutex_unlock(&__sig_worker_lock);
Sleep(POLL_INTERVAL_MS);
}
return 0;
__builtin_unreachable();
}
__attribute__((__constructor__(10))) textstartup void __sig_init(void) {

View file

@ -34,6 +34,8 @@
#include "libc/nt/thunk/msabi.h"
#ifdef __x86_64__
#define ABI __msabi textwindows dontinstrument
// cut back on code size and avoid setting errno
// this code is a mandatory dependency of winmain
__msabi extern typeof(CloseHandle) *const __imp_CloseHandle;
@ -47,8 +49,8 @@ __msabi extern typeof(GetEnvironmentVariable)
*const __imp_GetEnvironmentVariableW;
// Generates C:\ProgramData\cosmo\sig\x\y.pid like path
__msabi textwindows dontinstrument char16_t *__sig_process_path(
char16_t *path, uint32_t pid, int create_directories) {
ABI char16_t *__sig_process_path(char16_t *path, uint32_t pid,
int create_directories) {
char16_t buf[3];
char16_t *p = path;
uint32_t vlen = __imp_GetEnvironmentVariableW(u"SYSTEMDRIVE", buf, 3);
@ -100,7 +102,7 @@ __msabi textwindows dontinstrument char16_t *__sig_process_path(
return path;
}
__msabi textwindows atomic_ulong *__sig_map_process(int pid, int disposition) {
ABI atomic_ulong *__sig_map_process(int pid, int disposition) {
char16_t path[128];
__sig_process_path(path, pid, disposition == kNtOpenAlways);
intptr_t hand = __imp_CreateFileW(path, kNtGenericRead | kNtGenericWrite,

View file

@ -32,8 +32,7 @@ int sys_sigprocmask(int how, const sigset_t *opt_set,
how, opt_set ? (sigset_t *)(intptr_t)(uint32_t)*opt_set : 0, 0, 0);
rc = 0;
}
if (rc != -1 && opt_out_oldset) {
if (rc != -1 && opt_out_oldset)
*opt_out_oldset = old[0];
}
return rc;
}

View file

@ -36,12 +36,10 @@
privileged const char *strsignal_r(int sig, char buf[21]) {
char *p;
const char *s;
if (!sig) {
if (!sig)
return "0";
}
if ((s = GetMagnumStr(kSignalNames, sig))) {
if ((s = GetMagnumStr(kSignalNames, sig)))
return s;
}
if (SIGRTMIN <= sig && sig <= SIGRTMAX) {
sig -= SIGRTMIN;
buf[0] = 'S';

View file

@ -79,7 +79,11 @@ int ulock_wait(uint32_t operation, void *addr, uint64_t value,
// it could also mean another thread calling ulock on this address was
// configured (via operation) in an inconsistent way.
//
int ulock_wake(uint32_t operation, void *addr, uint64_t wake_value) {
// should be dontinstrument because SiliconThreadMain() calls this from
// a stack managed by apple libc.
//
dontinstrument int ulock_wake(uint32_t operation, void *addr,
uint64_t wake_value) {
int rc;
rc = __syscall3i(operation, (long)addr, wake_value, 0x2000000 | 516);
LOCKTRACE("ulock_wake(%#x, %p, %lx) → %s", operation, addr, wake_value,