mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
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.
This commit is contained in:
parent
4a5b474f1d
commit
e0c1541847
7 changed files with 46 additions and 3 deletions
|
@ -1968,7 +1968,9 @@ int Process::sys$select(const Syscall::SC_select_params* params)
|
||||||
auto* timeout = params->timeout;
|
auto* timeout = params->timeout;
|
||||||
|
|
||||||
// FIXME: Implement exceptfds support.
|
// FIXME: Implement exceptfds support.
|
||||||
ASSERT(!exceptfds);
|
//ASSERT(!exceptfds);
|
||||||
|
if (exceptfds)
|
||||||
|
kprintf("%s(%u): FIXME: select() with exceptfds\n", name().characters(), pid());
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
m_select_timeout = *timeout;
|
m_select_timeout = *timeout;
|
||||||
|
|
|
@ -13,7 +13,9 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lconv {
|
struct lconv {
|
||||||
char *decimal_point;
|
char* decimal_point;
|
||||||
|
char* thousands_sep;
|
||||||
|
char* grouping;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct lconv* localeconv();
|
struct lconv* localeconv();
|
||||||
|
|
|
@ -2,12 +2,24 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__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);
|
int setjmp(jmp_buf);
|
||||||
void longjmp(jmp_buf, int val);
|
void longjmp(jmp_buf, int val);
|
||||||
|
|
||||||
|
int sigsetjmp(jmp_buf, int savesigs);
|
||||||
|
void siglongjmp(jmp_buf, int val);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <assert.h>
|
||||||
#include <Kernel/Syscall.h>
|
#include <Kernel/Syscall.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -106,4 +108,24 @@ const char* sys_siglist[NSIG] = {
|
||||||
#undef __SIGNAL
|
#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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
@ -11,3 +13,4 @@ __BEGIN_DECLS
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ gid_t getegid();
|
||||||
uid_t getuid();
|
uid_t getuid();
|
||||||
gid_t getgid();
|
gid_t getgid();
|
||||||
pid_t getpid();
|
pid_t getpid();
|
||||||
|
pid_t getppid();
|
||||||
int getgroups(int size, gid_t list[]);
|
int getgroups(int size, gid_t list[]);
|
||||||
int setgroups(size_t, const gid_t*);
|
int setgroups(size_t, const gid_t*);
|
||||||
int setuid(uid_t);
|
int setuid(uid_t);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue