From e0c15418471f59f226de265187144ca2ddedd061 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 26 Feb 2019 14:05:28 +0100 Subject: [PATCH] Compat work towards making bash-5.0 build with less patches. Hacked implementations of sigsetjmp() and siglongjmp(). I didn't know about these APIs until just now, but I hope I got them right. --- Kernel/Process.cpp | 4 +++- LibC/locale.h | 4 +++- LibC/setjmp.h | 14 +++++++++++++- LibC/signal.cpp | 22 ++++++++++++++++++++++ LibC/stdbool.h | 3 +++ LibC/stdlib.h | 1 + LibC/unistd.h | 1 + 7 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 6ea20a9ce5..a160c43bf7 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -1968,7 +1968,9 @@ int Process::sys$select(const Syscall::SC_select_params* params) auto* timeout = params->timeout; // FIXME: Implement exceptfds support. - ASSERT(!exceptfds); + //ASSERT(!exceptfds); + if (exceptfds) + kprintf("%s(%u): FIXME: select() with exceptfds\n", name().characters(), pid()); if (timeout) { m_select_timeout = *timeout; diff --git a/LibC/locale.h b/LibC/locale.h index 50baff97b8..0bbe344e0f 100644 --- a/LibC/locale.h +++ b/LibC/locale.h @@ -13,7 +13,9 @@ enum { }; struct lconv { - char *decimal_point; + char* decimal_point; + char* thousands_sep; + char* grouping; }; struct lconv* localeconv(); diff --git a/LibC/setjmp.h b/LibC/setjmp.h index eef107ebb4..01980ac8b5 100644 --- a/LibC/setjmp.h +++ b/LibC/setjmp.h @@ -2,12 +2,24 @@ #include #include +#include +#include +#include __BEGIN_DECLS -typedef uint32_t jmp_buf[6]; +struct __jmp_buf { + uint32_t regs[6]; + bool did_save_signal_mask; + sigset_t saved_signal_mask; +}; + +typedef struct __jmp_buf jmp_buf[1]; int setjmp(jmp_buf); void longjmp(jmp_buf, int val); +int sigsetjmp(jmp_buf, int savesigs); +void siglongjmp(jmp_buf, int val); + __END_DECLS diff --git a/LibC/signal.cpp b/LibC/signal.cpp index 7e0c6c394e..248ac08556 100644 --- a/LibC/signal.cpp +++ b/LibC/signal.cpp @@ -2,6 +2,8 @@ #include #include #include +#include +#include #include extern "C" { @@ -106,4 +108,24 @@ const char* sys_siglist[NSIG] = { #undef __SIGNAL }; +int sigsetjmp(jmp_buf env, int savesigs) +{ + if (savesigs) { + int rc = sigprocmask(0, nullptr, &env->saved_signal_mask); + assert(rc == 0); + env->did_save_signal_mask = true; + } else { + env->did_save_signal_mask = false; + } + return setjmp(env); +} +void siglongjmp(jmp_buf env, int val) +{ + if (env->did_save_signal_mask) { + int rc = sigprocmask(SIG_SETMASK, &env->saved_signal_mask, nullptr); + assert(rc == 0); + } + longjmp(env, val); +} + } diff --git a/LibC/stdbool.h b/LibC/stdbool.h index aa00f3430a..96d0d4dd92 100644 --- a/LibC/stdbool.h +++ b/LibC/stdbool.h @@ -1,5 +1,7 @@ #pragma once +#ifndef __cplusplus + #include __BEGIN_DECLS @@ -11,3 +13,4 @@ __BEGIN_DECLS __END_DECLS +#endif diff --git a/LibC/stdlib.h b/LibC/stdlib.h index 0fe439eff0..007ef9ca68 100644 --- a/LibC/stdlib.h +++ b/LibC/stdlib.h @@ -2,6 +2,7 @@ #include #include +#include __BEGIN_DECLS diff --git a/LibC/unistd.h b/LibC/unistd.h index d8164d11b9..73b4db67a8 100644 --- a/LibC/unistd.h +++ b/LibC/unistd.h @@ -35,6 +35,7 @@ gid_t getegid(); uid_t getuid(); gid_t getgid(); pid_t getpid(); +pid_t getppid(); int getgroups(int size, gid_t list[]); int setgroups(size_t, const gid_t*); int setuid(uid_t);