FIx sigjmp_buf and add tests

This commit is contained in:
Wildan M
2026-05-02 16:59:48 +07:00
parent 08fc95fce2
commit 043ec22076
5 changed files with 41 additions and 52 deletions
+4 -52
View File
@@ -2,67 +2,19 @@
#define _SETJMP_H
#ifdef __aarch64__
typedef unsigned long jmp_buf[22];
#endif
#ifdef __arm__
typedef unsigned long long jmp_buf[32];
typedef unsigned long long jmp_buf[22];
#endif
#ifdef __i386__
typedef unsigned long jmp_buf[6];
#endif
#ifdef __m68k__
typedef unsigned long jmp_buf[39];
#endif
#ifdef __microblaze__
typedef unsigned long jmp_buf[18];
#endif
#ifdef __mips__
typedef unsigned long long jmp_buf[13];
#endif
#ifdef __mips64__
typedef unsigned long long jmp_buf[23];
#endif
#ifdef __mipsn32__
typedef unsigned long long jmp_buf[23];
#endif
#ifdef __or1k__
typedef unsigned long jmp_buf[13];
#endif
#ifdef __powerpc__
typedef unsigned long long jmp_buf[56];
#endif
#ifdef __powerpc64__
typedef uint128_t jmp_buf[32];
#endif
#ifdef __s390x__
typedef unsigned long jmp_buf[18];
#endif
#ifdef __sh__
typedef unsigned long jmp_buf[15];
#endif
#ifdef __x32__
typedef unsigned long long jmp_buf[8];
typedef unsigned long long jmp_buf[6];
#endif
#ifdef __x86_64__
typedef unsigned long jmp_buf[16];
typedef unsigned long long jmp_buf[16];
#endif
#ifdef __riscv
typedef unsigned long jmp_buf[26];
typedef unsigned long long jmp_buf[26];
#endif
typedef jmp_buf sigjmp_buf;
+2
View File
@@ -75,6 +75,7 @@ EXPECT_NAMES=\
sigaction \
sigaltstack \
signal \
sigsetjmp \
stdio/all \
stdio/buffer \
stdio/dprintf \
@@ -161,6 +162,7 @@ EXPECT_NAMES=\
time/tzset \
unistd/access \
unistd/alarm \
unistd/alarm_fn \
unistd/constants \
unistd/confstr \
unistd/dup \
@@ -0,0 +1 @@
SIGALRM interrupted the process.
@@ -0,0 +1 @@
SIGALRM interrupted the process.
+33
View File
@@ -0,0 +1,33 @@
#include <assert.h>
#include <signal.h>
#include <setjmp.h>
#include <unistd.h>
#include <stdio.h>
#include "test_helpers.h"
static sigjmp_buf jmpenv;
void alarm_handler(int sig) {
(void)sig;
siglongjmp(jmpenv, 1);
}
int main() {
struct sigaction sa;
sa.sa_handler = alarm_handler;
sigemptyset(&sa.sa_mask);
int sa_status = sigaction(SIGALRM, &sa, NULL);
ERROR_IF(sigaction, sa_status, == -1);
if (sigsetjmp(jmpenv, 1)) {
printf("SIGALRM interrupted the process.\n");
return 0;
}
alarm(1);
sleep(5);
assert(0); // unreachable
}