Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,8 @@ fn test_netbsd(target: &str) {
("ifreq", "ifr_ifru") => true,
("utmpx", "ut_exit") => true,
("posix_spawn_file_actions_entry_t", "fae_data") => true,
("kinfo_pcb", "ki_s") => true,
("kinfo_pcb", "ki_d") => true,

_ => false,
}
Expand Down
19 changes: 18 additions & 1 deletion libc-test/semver/netbsd.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@ DCCP_TYPE_RESET
DCCP_TYPE_RESPONSE
DEAD_PROCESS
DOWN_TIME
DTYPE_CRYPTO
DTYPE_EVENTFD
DTYPE_KQUEUE
DTYPE_MISC
DTYPE_MQUEUE
DTYPE_PIPE
DTYPE_SEM
DTYPE_SOCKET
DTYPE_TIMERFD
DTYPE_VNODE
DT_UNKNOWN
D_FMT
D_T_FMT
Expand Down Expand Up @@ -499,6 +509,9 @@ KERN_DUMP_ON_PANIC
KERN_EVCNT
KERN_FILE
KERN_FILE2
KERN_FILESLOP
KERN_FILE_BYFILE
KERN_FILE_BYPID
KERN_FORKFSLEEP
KERN_FSCALE
KERN_FSYNC
Expand Down Expand Up @@ -767,6 +780,8 @@ O_RSYNC
O_SEARCH
O_SHLOCK
O_SYNC
PCB_ALL
PCB_SLOP
PENDIN
PF_APPLETALK
PF_ARP
Expand Down Expand Up @@ -1381,8 +1396,10 @@ jrand48
kevent
key_t
killpg
kinfo_file
kinfo_getvmmap
kinfo_lwp
kinfo_pcb
kinfo_proc2
kinfo_vmentry
kqueue
Expand Down Expand Up @@ -1629,4 +1646,4 @@ utmpxname
utrace
uucred
wait4
waitid
waitid
2 changes: 2 additions & 0 deletions src/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ cfg_if! {
pub use signal::*;
} else if #[cfg(target_os = "netbsd")] {
pub use net::if_::*;
pub use sys::file::*;
pub use sys::ipc::*;
pub use sys::socket::*;
pub use sys::statvfs::*;
pub use sys::time::*;
pub use sys::timex::*;
Expand Down
16 changes: 16 additions & 0 deletions src/new/netbsd/sys/file.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! Header: `sys/file.h`
//!
//! <https://github.com/NetBSD/src/blob/trunk/sys/sys/file.h>

use crate::prelude::*;

pub const DTYPE_VNODE: c_int = 1;
pub const DTYPE_SOCKET: c_int = 2;
pub const DTYPE_PIPE: c_int = 3;
pub const DTYPE_KQUEUE: c_int = 4;
pub const DTYPE_MISC: c_int = 5;
pub const DTYPE_CRYPTO: c_int = 6;
pub const DTYPE_MQUEUE: c_int = 7;
pub const DTYPE_SEM: c_int = 8;
pub const DTYPE_EVENTFD: c_int = 9;
pub const DTYPE_TIMERFD: c_int = 10;
2 changes: 2 additions & 0 deletions src/new/netbsd/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
//!
//! https://github.com/NetBSD/src/tree/trunk/sys/sys
pub(crate) mod file;
pub(crate) mod ipc;
pub(crate) mod socket;
pub(crate) mod statvfs;
pub(crate) mod time;
pub(crate) mod timex;
Expand Down
44 changes: 44 additions & 0 deletions src/new/netbsd/sys/socket.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//! Header: `sys/socket.h`
//!
//! <https://github.com/NetBSD/src/blob/trunk/sys/sys/socket.h>
//!

use crate::prelude::*;

s_no_extra_traits! {
pub union __c_anonymous_pcb_sockaddr_src {
pub _kis_src: crate::sockaddr,
_kis_pad: Padding<[c_char; 256 + 8]>,
}

pub union __c_anonymous_pcb_sockaddr_dst {
pub _kid_dst: crate::sockaddr,
_kid_pad: Padding<[c_char; 256 + 8]>,
}

pub struct kinfo_pcb {
pub ki_pcbaddr: u64,
pub ki_ppcbaddr: u64,
pub ki_sockaddr: u64,
pub ki_family: u32,
pub ki_type: u32,
pub ki_protocol: u32,
pub ki_pflags: u32,
pub ki_sostate: u32,
pub ki_prstate: u32,
pub ki_tstate: i32,
pub ki_tflags: u32,
pub ki_rcvq: u64,
pub ki_sndq: u64,
pub ki_s: __c_anonymous_pcb_sockaddr_src,
pub ki_d: __c_anonymous_pcb_sockaddr_dst,
pub ki_inode: u64,
pub ki_vnode: u64,
pub ki_conn: u64,
pub ki_refs: u64,
pub ki_nextref: u64,
}
}

pub const PCB_SLOP: c_int = 20;
pub const PCB_ALL: c_int = 0;
31 changes: 31 additions & 0 deletions src/unix/bsd/netbsdlike/netbsd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,33 @@ s! {
pub a_v: Elf64_Xword,
}

// sys/sysctl.h

pub struct kinfo_file {
pub ki_fileaddr: u64,
pub ki_flag: u32,
pub ki_iflags: u32,
pub ki_ftype: u32,
pub ki_count: u32,
pub ki_msgcount: u32,
pub ki_usecount: u32,
pub ki_fucred: u64,
pub ki_fuid: u32,
pub ki_fgid: u32,
pub ki_fops: u64,
pub ki_foffset: u64,
pub ki_fdata: u64,
pub ki_vun: u64,
pub ki_vsize: u64,
pub ki_vtype: u32,
pub ki_vtag: u32,
pub ki_vdata: u64,
pub ki_pid: u32,
pub ki_fd: i32,
pub ki_ofileflags: u32,
_ki_padto64bits: Padding<u32>,
}

// link.h

pub struct dl_phdr_info {
Expand Down Expand Up @@ -1697,6 +1724,10 @@ pub const KI_MAXLOGNAME: c_int = 24;
pub const KI_MAXEMULLEN: c_int = 16;
pub const KI_LNAMELEN: c_int = 20;

pub const KERN_FILE_BYFILE: c_int = 1;
pub const KERN_FILE_BYPID: c_int = 2;
pub const KERN_FILESLOP: c_int = 10;

// sys/lwp.h
pub const LSIDL: c_int = 1;
pub const LSRUN: c_int = 2;
Expand Down