Merge branch 'setjmp' into 'master'

Move sigsetjmp and siglongjmp to setjmp.h

See merge request redox-os/relibc!1353
This commit is contained in:
Jeremy Soller
2026-05-19 06:02:09 -06:00
4 changed files with 15 additions and 13 deletions
+2
View File
@@ -25,6 +25,8 @@ extern "C" {
int setjmp(jmp_buf buf);
void longjmp(jmp_buf buf, int value);
int sigsetjmp(jmp_buf buf, int savemask);
int siglongjmp(jmp_buf buf, int savemask);
#ifdef __cplusplus
} // extern "C"
+12 -2
View File
@@ -4,6 +4,8 @@
use core::arch::global_asm;
use crate::platform::types::{c_int, c_ulonglong};
macro_rules! platform_specific {
($($rust_arch:expr,$c_arch:expr,$ext:expr;)+) => {
$(
@@ -27,7 +29,15 @@ platform_specific! {
//Each platform has different sizes for sigjmp_buf, currently only x86_64 is supported
unsafe extern "C" {
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/setjmp.html>.
pub fn setjmp(jb: *mut u64) -> i32;
pub unsafe fn setjmp(env: *mut c_ulonglong) -> c_int;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/sigsetjmp.html>.
pub unsafe fn sigsetjmp(env: *mut c_ulonglong, savemask: c_int) -> c_int;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/longjmp.html>.
pub fn longjmp(jb: *mut u64, ret: i32);
pub unsafe fn longjmp(env: *mut c_ulonglong, val: c_int);
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/siglongjmp.html>.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn siglongjmp(env: *mut c_ulonglong, val: c_int) {
unsafe { longjmp(env, val) };
}
+1 -10
View File
@@ -10,7 +10,7 @@ use cbitset::BitSet;
use crate::platform::types::pthread_attr_t;
use crate::{
error::{Errno, ResultExt},
header::{bits_sigset_t::sigset_t, errno, setjmp, time::timespec},
header::{bits_sigset_t::sigset_t, errno, time::timespec},
platform::{
self, ERRNO, Pal, PalSignal, Sys,
types::{c_char, c_int, c_ulonglong, c_void, pid_t, pthread_t, size_t, uid_t},
@@ -129,10 +129,6 @@ pub type siginfo_t = siginfo;
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/signal.h.html>
pub type stack_t = sigaltstack;
unsafe extern "C" {
pub fn sigsetjmp(jb: *mut c_ulonglong, savemask: c_int) -> c_int;
}
//NOTE for the following two functions, to see why they're implemented slightly differently from their intended behavior, read
// https://git.musl-libc.org/cgit/musl/commit/?id=583e55122e767b1586286a0d9c35e2a4027998ab
#[unsafe(no_mangle)]
@@ -146,11 +142,6 @@ unsafe extern "C" fn __sigsetjmp_tail(jb: *mut c_ulonglong, ret: c_int) -> c_int
ret
}
#[unsafe(no_mangle)]
pub unsafe extern "C" fn siglongjmp(jb: *mut c_ulonglong, ret: c_int) {
unsafe { setjmp::longjmp(jb, ret) };
}
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/kill.html>.
#[unsafe(no_mangle)]
pub extern "C" fn kill(pid: pid_t, sig: c_int) -> c_int {
-1
View File
@@ -1,6 +1,5 @@
#include <stdio.h>
#include <setjmp.h>
#include <signal.h>
int main() {
sigjmp_buf jb;