From 284f51b47e5cf4a7ce26e3cbf38b3e2320eaeddb Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 4 Jul 2024 11:31:45 +0200 Subject: [PATCH] Fix struct sigaction defintion. --- include/bits/signal.h | 14 ++++++++++++++ src/header/signal/cbindgen.toml | 3 ++- src/header/signal/mod.rs | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/bits/signal.h b/include/bits/signal.h index 46cc2553..57832b5e 100644 --- a/include/bits/signal.h +++ b/include/bits/signal.h @@ -5,4 +5,18 @@ #define SIG_IGN ((void (*)(int))1) #define SIG_ERR ((void (*)(int))-1) +struct siginfo; +typedef struct siginfo siginfo_t; +typedef unsigned long long sigset_t; + +struct sigaction { + union { + void (*sa_handler)(int); + void (*sa_sigaction)(int, siginfo_t *, void *); + }; + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; +}; + #endif // _BITS_SIGNAL_H diff --git a/src/header/signal/cbindgen.toml b/src/header/signal/cbindgen.toml index a7055988..3c79a660 100644 --- a/src/header/signal/cbindgen.toml +++ b/src/header/signal/cbindgen.toml @@ -1,4 +1,4 @@ -sys_includes = ["stdint.h", "sys/types.h", "time.h", "bits/pthread.h"] +sys_includes = ["bits/signal.h", "stdint.h", "sys/types.h", "time.h", "bits/pthread.h"] include_guard = "_RELIBC_SIGNAL_H" trailer = "#include <bits/signal.h>" language = "C" @@ -15,3 +15,4 @@ prefix_with_name = true [export.rename] "timespec" = "struct timespec" +"sigaction" = "struct sigaction" diff --git a/src/header/signal/mod.rs b/src/header/signal/mod.rs index ec6241de..01cd57d7 100644 --- a/src/header/signal/mod.rs +++ b/src/header/signal/mod.rs @@ -35,6 +35,7 @@ pub const SIG_SETMASK: c_int = 2; #[repr(C)] #[derive(Clone, Debug)] +/// cbindgen:ignore pub struct sigaction { pub sa_handler: Option<extern "C" fn(c_int)>, pub sa_flags: c_ulong, @@ -52,7 +53,7 @@ pub struct sigaltstack { #[repr(C)] #[derive(Clone, Debug)] -pub struct siginfo_t { +pub struct siginfo { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, @@ -60,7 +61,10 @@ pub struct siginfo_t { _si_align: [usize; 0], } +/// cbindgen:ignore pub type sigset_t = c_ulonglong; +/// cbindgen:ignore +pub type siginfo_t = siginfo; pub type stack_t = sigaltstack; -- GitLab