Skip to content

Commit 34ddde5

Browse files
committed
Auto merge of #2157 - devnexen:netbsd_ucontext, r=JohnTitor
Add `ucontext_t` and `mcontext_t` on NetBSD/x86_64 ucontext_t/mcontext_t exposure on x86_64 architecture.
2 parents 5d3421e + 890ac7d commit 34ddde5

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -912,6 +912,7 @@ fn test_netbsd(target: &str) {
912912
"grp.h",
913913
"ifaddrs.h",
914914
"langinfo.h",
915+
"net/bpf.h",
915916
"net/if.h",
916917
"net/if_arp.h",
917918
"net/if_dl.h",
@@ -944,6 +945,7 @@ fn test_netbsd(target: &str) {
944945
"sys/time.h",
945946
"sys/times.h",
946947
"sys/timex.h",
948+
"sys/ucontext.h",
947949
"sys/uio.h",
948950
"sys/un.h",
949951
"sys/utsname.h",

src/unix/bsd/netbsdlike/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,14 @@ s! {
7272
pub uid: ::uid_t,
7373
pub gid: ::gid_t,
7474
pub mode: ::mode_t,
75+
#[cfg(target_os = "openbsd")]
7576
pub seq: ::c_ushort,
77+
#[cfg(target_os = "netbsd")]
78+
pub _seq: ::c_ushort,
79+
#[cfg(target_os = "openbsd")]
7680
pub key: ::key_t,
81+
#[cfg(target_os = "netbsd")]
82+
pub _key: ::key_t,
7783
}
7884

7985
pub struct ptrace_io_desc {

src/unix/bsd/netbsdlike/netbsd/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub type fsfilcnt_t = u64;
77
pub type idtype_t = ::c_int;
88
pub type mqd_t = ::c_int;
99
type __pthread_spin_t = __cpu_simple_lock_nv_t;
10-
pub type vm_size_t = ::uintptr_t;
10+
pub type vm_size_t = ::uintptr_t; // FIXME: deprecated since long time
1111
pub type lwpid_t = ::c_uint;
1212
pub type shmatt_t = ::c_uint;
1313

@@ -437,7 +437,7 @@ s_no_extra_traits! {
437437
pub ut_session: u16,
438438
pub ut_type: u16,
439439
pub ut_pid: ::pid_t,
440-
pub ut_exit: __exit_status,
440+
pub ut_exit: __exit_status, // FIXME: when anonymous struct are supported
441441
pub ut_ss: sockaddr_storage,
442442
pub ut_tv: ::timeval,
443443
pub ut_pad: [u8; _UTX_PADSIZE],

src/unix/bsd/netbsdlike/netbsd/x86_64.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,25 @@ use PT_FIRSTMACH;
33
pub type c_long = i64;
44
pub type c_ulong = u64;
55
pub type c_char = i8;
6+
pub type c___greg_t = u64;
67
pub type __cpu_simple_lock_nv_t = ::c_uchar;
78

9+
s! {
10+
pub struct mcontext_t {
11+
pub __gregs: [c___greg_t; 26],
12+
pub _mc_tlsbase: c___greg_t,
13+
pub __fpregs: [[::c_char;32]; 16],
14+
}
15+
16+
pub struct ucontext_t {
17+
pub uc_flags: ::c_uint,
18+
pub uc_link: *mut ::ucontext_t,
19+
pub uc_sigmask: ::sigset_t,
20+
pub uc_stack: ::stack_t,
21+
pub uc_mcontext: ::mcontext_t,
22+
}
23+
}
24+
825
// should be pub(crate), but that requires Rust 1.18.0
926
cfg_if! {
1027
if #[cfg(libc_const_size_of)] {

0 commit comments

Comments
 (0)