mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Get setcontext() and getcontext() working on Aarch64
This change also adds the missing code for getting and restoring the thread's signal mask, since that's explicitly listed by the man page
This commit is contained in:
parent
8b62bff364
commit
7ec84655b4
7 changed files with 182 additions and 13 deletions
|
@ -17,13 +17,13 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
#include "libc/calls/ucontext.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/sysv/consts/sig.h"
|
||||
#include "libc/testlib/ezbench.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
#ifdef __x86_64__
|
||||
|
||||
int x;
|
||||
bool ok1;
|
||||
bool ok2;
|
||||
|
@ -51,6 +51,25 @@ TEST(getcontext, test) {
|
|||
ASSERT_TRUE(ok2);
|
||||
}
|
||||
|
||||
TEST(getcontext, canReadAndWriteSignalMask) {
|
||||
sigset_t ss, old;
|
||||
volatile int n = 0;
|
||||
sigemptyset(&ss);
|
||||
sigaddset(&ss, SIGUSR1);
|
||||
sigprocmask(SIG_SETMASK, &ss, &old);
|
||||
ASSERT_EQ(0, getcontext(&context));
|
||||
if (!n) {
|
||||
n = 1;
|
||||
ASSERT_TRUE(sigismember(&context.uc_sigmask, SIGUSR1));
|
||||
sigaddset(&context.uc_sigmask, SIGUSR2);
|
||||
setcontext(&context);
|
||||
abort();
|
||||
}
|
||||
sigprocmask(SIG_SETMASK, 0, &ss);
|
||||
ASSERT_TRUE(sigismember(&ss, SIGUSR2));
|
||||
sigprocmask(SIG_SETMASK, &old, 0);
|
||||
}
|
||||
|
||||
void SetGetContext(void) {
|
||||
static int a;
|
||||
a = 0;
|
||||
|
@ -64,5 +83,3 @@ void SetGetContext(void) {
|
|||
BENCH(getcontext, bench) {
|
||||
EZBENCH2("get/setcontext", donothing, SetGetContext());
|
||||
}
|
||||
|
||||
#endif /* __x86_64__ */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue