Skip to content

Commit

Permalink
Auto merge of #2157 - devnexen:netbsd_ucontext, r=JohnTitor
Browse files Browse the repository at this point in the history
Add `ucontext_t` and `mcontext_t` on NetBSD/x86_64

ucontext_t/mcontext_t exposure on x86_64 architecture.
  • Loading branch information
bors committed May 24, 2021
2 parents 5d3421e + 890ac7d commit 34ddde5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ fn test_netbsd(target: &str) {
"grp.h",
"ifaddrs.h",
"langinfo.h",
"net/bpf.h",
"net/if.h",
"net/if_arp.h",
"net/if_dl.h",
Expand Down Expand Up @@ -944,6 +945,7 @@ fn test_netbsd(target: &str) {
"sys/time.h",
"sys/times.h",
"sys/timex.h",
"sys/ucontext.h",
"sys/uio.h",
"sys/un.h",
"sys/utsname.h",
Expand Down
6 changes: 6 additions & 0 deletions src/unix/bsd/netbsdlike/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,14 @@ s! {
pub uid: ::uid_t,
pub gid: ::gid_t,
pub mode: ::mode_t,
#[cfg(target_os = "openbsd")]
pub seq: ::c_ushort,
#[cfg(target_os = "netbsd")]
pub _seq: ::c_ushort,
#[cfg(target_os = "openbsd")]
pub key: ::key_t,
#[cfg(target_os = "netbsd")]
pub _key: ::key_t,
}

pub struct ptrace_io_desc {
Expand Down
4 changes: 2 additions & 2 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub type fsfilcnt_t = u64;
pub type idtype_t = ::c_int;
pub type mqd_t = ::c_int;
type __pthread_spin_t = __cpu_simple_lock_nv_t;
pub type vm_size_t = ::uintptr_t;
pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time
pub type lwpid_t = ::c_uint;
pub type shmatt_t = ::c_uint;

Expand Down Expand Up @@ -437,7 +437,7 @@ s_no_extra_traits! {
pub ut_session: u16,
pub ut_type: u16,
pub ut_pid: ::pid_t,
pub ut_exit: __exit_status,
pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported
pub ut_ss: sockaddr_storage,
pub ut_tv: ::timeval,
pub ut_pad: [u8; _UTX_PADSIZE],
Expand Down
17 changes: 17 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,25 @@ use PT_FIRSTMACH;
pub type c_long = i64;
pub type c_ulong = u64;
pub type c_char = i8;
pub type c___greg_t = u64;
pub type __cpu_simple_lock_nv_t = ::c_uchar;

s! {
pub struct mcontext_t {
pub __gregs: [c___greg_t; 26],
pub _mc_tlsbase: c___greg_t,
pub __fpregs: [[::c_char;32]; 16],
}

pub struct ucontext_t {
pub uc_flags: ::c_uint,
pub uc_link: *mut ::ucontext_t,
pub uc_sigmask: ::sigset_t,
pub uc_stack: ::stack_t,
pub uc_mcontext: ::mcontext_t,
}
}

// should be pub(crate), but that requires Rust 1.18.0
cfg_if! {
if #[cfg(libc_const_size_of)] {
Expand Down

0 comments on commit 34ddde5

Please sign in to comment.