diff --git a/README.md b/README.md index 395b94ce0c8f3..3d5b5ec583457 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,14 @@ This crate exports all underlying platform types, functions, and constants under the crate root, so all items are accessible as `libc::foo`. The types and values of all the exported APIs match the platform that libc is compiled for. +Windows API bindings are not included in this crate. If you are looking for WinAPI +bindings, consider using crates like [windows-sys]. + More detailed information about the design of this library can be found in its [associated RFC][rfc]. [rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md +[windows-sys]: https://docs.rs/windows-sys ## v0.3 Roadmap diff --git a/libc-test/build.rs b/libc-test/build.rs index ca1301320b211..fb779daecc123 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3746,6 +3746,9 @@ fn test_linux(target: &str) { if musl && ty == "fanout_args" { return true; } + if sparc64 && ty == "fanotify_event_info_error" { + return true; + } match ty { // These cannot be tested when "resolv.h" is included and are tested @@ -4480,7 +4483,21 @@ fn test_linux(target: &str) { // the `ifc_ifcu` field is an anonymous union (struct_ == "ifconf" && field == "ifc_ifcu") || // glibc uses a single array `uregs` instead of individual fields. - (struct_ == "user_regs" && arm) + (struct_ == "user_regs" && arm) || + // the `ifr_ifrn` field is an anonymous union + (struct_ == "iwreq" && field == "ifr_ifrn") || + // the `key` field is a zero-sized array + (struct_ == "iw_encode_ext" && field == "key") || + // the `tcpi_snd_rcv_wscale` map two bitfield fields stored in a u8 + (struct_ == "tcp_info" && field == "tcpi_snd_rcv_wscale") || + // the `tcpi_delivery_rate_app_limited` field is a bitfield on musl + (musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") || + // the `tcpi_fast_open_client_fail` field is a bitfield on musl + (musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") || + // either fsid_t or int[2] type + (struct_ == "fanotify_event_info_fid" && field == "fsid") || + // `handle` is a VLA + (struct_ == "fanotify_event_info_fid" && field == "handle") }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/emscripten.txt b/libc-test/semver/emscripten.txt index 6b1df1aab4c7f..d14abae402367 100644 --- a/libc-test/semver/emscripten.txt +++ b/libc-test/semver/emscripten.txt @@ -1,2 +1,4 @@ getentropy posix_fallocate64 +getpwnam_r +getpwuid_r diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index ce4f85484eee0..bca6e4fd18ed7 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -628,12 +628,15 @@ dlinfo dlmopen endutxent explicit_bzero +fanotify_event_info_error +fanotify_event_info_header +fanotify_event_info_pidfd +fgetgrent_r fgetspent_r futimes getauxval getentropy getgrent_r -fgetgrent_r getloadavg getpt getpwent_r @@ -712,3 +715,4 @@ putgrent execveat close_range epoll_pwait2 +tcp_info diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 5a48357cb79e5..bb8dbb2f9834e 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -80,6 +80,7 @@ process_vm_writev pwritev2 pwritev64 reallocarray +tcp_info timex euidaccess eaccess diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index ebbe04d1b7262..d0b966f4f1085 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3497,6 +3497,7 @@ execvpe faccessat fallocate fallocate64 +fanotify_event_info_fid fanotify_event_metadata fanotify_init fanotify_mark diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 1dc607496a2ad..11a16aa7afa41 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1776,6 +1776,21 @@ extern "C" { ) -> ::c_int; pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; + + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; + pub fn getpwuid_r( + uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; } // Alias to 64 to mimic glibc's LFS64 support diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 75d150c90d58a..7fd7fb190ca9d 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -454,6 +454,55 @@ s! { pub aio_flags: ::__u32, pub aio_resfd: ::__u32, } + + // netinet/tcp.h + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + } + + pub struct fanotify_event_info_pidfd { + pub hdr: ::fanotify_event_info_header, + pub pidfd: ::__s32, + } + + pub struct fanotify_event_info_error { + pub hdr: ::fanotify_event_info_header, + pub error: ::__s32, + pub error_count: ::__u32, + } } impl siginfo_t { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index a7815ddfc3c14..3ca4446e66ef1 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -16,6 +16,7 @@ pub type loff_t = ::c_longlong; pub type pthread_key_t = ::c_uint; pub type pthread_once_t = ::c_int; pub type pthread_spinlock_t = ::c_int; +pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t; pub type __u8 = ::c_uchar; pub type __u16 = ::c_ushort; @@ -548,6 +549,20 @@ s! { pub sh_entsize: Elf64_Xword, } + pub struct __c_anonymous_elf32_rel { + pub r_offset: Elf32_Addr, + pub r_info: Elf32_Word, + } + + pub struct __c_anonymous_elf64_rel { + pub r_offset: Elf64_Addr, + pub r_info: Elf64_Xword, + } + + pub struct __c_anonymous__kernel_fsid_t { + pub val: [::c_int; 2], + } + pub struct ucred { pub pid: ::pid_t, pub uid: ::uid_t, @@ -615,6 +630,18 @@ s! { pub response: __u32, } + pub struct fanotify_event_info_header { + pub info_type: __u8, + pub pad: __u8, + pub len: __u16, + } + + pub struct fanotify_event_info_fid { + pub hdr: fanotify_event_info_header, + pub fsid: ::__kernel_fsid_t, + pub handle: [::c_uchar; 0], + } + pub struct sockaddr_vm { pub svm_family: ::sa_family_t, pub svm_reserved1: ::c_ushort, diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index a4c8f79c35cad..d102d5de2cfed 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -348,6 +348,73 @@ s! { pub len: ::__u32, pub options: ::__u32, } + + // netinet/tcp.h + + pub struct tcp_info { + pub tcpi_state: u8, + pub tcpi_ca_state: u8, + pub tcpi_retransmits: u8, + pub tcpi_probes: u8, + pub tcpi_backoff: u8, + pub tcpi_options: u8, + /* + * FIXME(musl): when musl headers are more up to date + /// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`. + /// Each is 4 bits. + pub tcpi_snd_rcv_wscale: u8, + /// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and + /// `tcpi_fastopen_client_fail` (2 bits). + pub tcpi_delivery_fastopen_bitfields: u8, + */ + pub tcpi_rto: u32, + pub tcpi_ato: u32, + pub tcpi_snd_mss: u32, + pub tcpi_rcv_mss: u32, + pub tcpi_unacked: u32, + pub tcpi_sacked: u32, + pub tcpi_lost: u32, + pub tcpi_retrans: u32, + pub tcpi_fackets: u32, + pub tcpi_last_data_sent: u32, + pub tcpi_last_ack_sent: u32, + pub tcpi_last_data_recv: u32, + pub tcpi_last_ack_recv: u32, + pub tcpi_pmtu: u32, + pub tcpi_rcv_ssthresh: u32, + pub tcpi_rtt: u32, + pub tcpi_rttvar: u32, + pub tcpi_snd_ssthresh: u32, + pub tcpi_snd_cwnd: u32, + pub tcpi_advmss: u32, + pub tcpi_reordering: u32, + pub tcpi_rcv_rtt: u32, + pub tcpi_rcv_space: u32, + pub tcpi_total_retrans: u32, + pub tcpi_pacing_rate: u64, + pub tcpi_max_pacing_rate: u64, + pub tcpi_bytes_acked: u64, + pub tcpi_bytes_received: u64, + pub tcpi_segs_out: u32, + pub tcpi_segs_in: u32, + pub tcpi_notsent_bytes: u32, + pub tcpi_min_rtt: u32, + pub tcpi_data_segs_in: u32, + pub tcpi_data_segs_out: u32, + pub tcpi_delivery_rate: u64, + pub tcpi_busy_time: u64, + pub tcpi_rwnd_limited: u64, + pub tcpi_sndbuf_limited: u64, + pub tcpi_delivered: u32, + pub tcpi_delivered_ce: u32, + pub tcpi_bytes_sent: u64, + pub tcpi_bytes_retrans: u64, + pub tcpi_dsack_dups: u32, + pub tcpi_reord_seen: u32, + // FIXME(musl): to uncomment once CI musl is updated + //pub tcpi_rcv_ooopack: u32, + //pub tcpi_snd_wnd: u32, + } } s_no_extra_traits! { diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index 5036f458067b6..ac092a372b576 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -22,7 +22,7 @@ pub type clockid_t = ::c_int; pub type dev_t = ::c_long; pub type fsblkcnt_t = ::c_ulong; pub type fsfilcnt_t = ::c_ulong; -pub type ino_t = ::c_ulong; +pub type ino_t = ::c_ulonglong; pub type mode_t = ::c_int; pub type nfds_t = ::c_ulong; pub type nlink_t = ::c_ulong;