Skip to content

Commit

Permalink
Auto merge of #3400 - devnexen:nbsd_obsd_siginfo_upd, r=JohnTitor
Browse files Browse the repository at this point in the history
netbsd/openbsd adding more accessors to siginfo_t.

close #3397
  • Loading branch information
bors committed Nov 2, 2023
2 parents 68f46d3 + ed7c9e8 commit 240de1f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
33 changes: 33 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Expand Up @@ -60,6 +60,39 @@ impl siginfo_t {
self.si_addr
}

pub unsafe fn si_code(&self) -> ::c_int {
self.si_code
}

pub unsafe fn si_errno(&self) -> ::c_int {
self.si_errno
}

pub unsafe fn si_pid(&self) -> ::pid_t {
#[repr(C)]
struct siginfo_timer {
_si_signo: ::c_int,
_si_errno: ::c_int,
_si_code: ::c_int,
__pad1: ::c_int,
_pid: ::pid_t,
}
(*(self as *const siginfo_t as *const siginfo_timer))._pid
}

pub unsafe fn si_uid(&self) -> ::uid_t {
#[repr(C)]
struct siginfo_timer {
_si_signo: ::c_int,
_si_errno: ::c_int,
_si_code: ::c_int,
__pad1: ::c_int,
_pid: ::pid_t,
_uid: ::uid_t,
}
(*(self as *const siginfo_t as *const siginfo_timer))._uid
}

pub unsafe fn si_value(&self) -> ::sigval {
#[repr(C)]
struct siginfo_timer {
Expand Down
39 changes: 38 additions & 1 deletion src/unix/bsd/netbsdlike/openbsd/mod.rs
Expand Up @@ -548,12 +548,46 @@ impl siginfo_t {
self.si_addr
}

pub unsafe fn si_value(&self) -> ::sigval {
pub unsafe fn si_code(&self) -> ::c_int {
self.si_code
}

pub unsafe fn si_errno(&self) -> ::c_int {
self.si_errno
}

pub unsafe fn si_pid(&self) -> ::pid_t {
#[repr(C)]
struct siginfo_timer {
_si_signo: ::c_int,
_si_code: ::c_int,
_si_errno: ::c_int,
_pad: [::c_int; SI_PAD],
_pid: ::pid_t,
}
(*(self as *const siginfo_t as *const siginfo_timer))._pid
}

pub unsafe fn si_uid(&self) -> ::uid_t {
#[repr(C)]
struct siginfo_timer {
_si_signo: ::c_int,
_si_code: ::c_int,
_si_errno: ::c_int,
_pad: [::c_int; SI_PAD],
_pid: ::pid_t,
_uid: ::uid_t,
}
(*(self as *const siginfo_t as *const siginfo_timer))._uid
}

pub unsafe fn si_value(&self) -> ::sigval {
#[repr(C)]
struct siginfo_timer {
_si_signo: ::c_int,
_si_code: ::c_int,
_si_errno: ::c_int,
_pad: [::c_int; SI_PAD],
_pid: ::pid_t,
_uid: ::uid_t,
value: ::sigval,
Expand Down Expand Up @@ -1652,6 +1686,9 @@ pub const NTFS_MFLAG_ALLNAMES: ::c_int = 0x2;

pub const TMPFS_ARGS_VERSION: ::c_int = 1;

const SI_MAXSZ: ::size_t = 128;
const SI_PAD: ::size_t = (SI_MAXSZ / ::mem::size_of::<::c_int>()) - 3;

pub const MAP_STACK: ::c_int = 0x4000;
pub const MAP_CONCEAL: ::c_int = 0x8000;

Expand Down

0 comments on commit 240de1f

Please sign in to comment.