Skip to content

Commit 1447f78

Browse files
authored
Merge pull request #3966 from tgross35/backport-cabbage
[0.2] backports
2 parents 42d1000 + a37cdde commit 1447f78

File tree

11 files changed

+190
-3
lines changed

11 files changed

+190
-3
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ This crate exports all underlying platform types, functions, and constants under
1111
the crate root, so all items are accessible as `libc::foo`. The types and values
1212
of all the exported APIs match the platform that libc is compiled for.
1313

14+
Windows API bindings are not included in this crate. If you are looking for WinAPI
15+
bindings, consider using crates like [windows-sys].
16+
1417
More detailed information about the design of this library can be found in its
1518
[associated RFC][rfc].
1619

1720
[rfc]: https://github.com/rust-lang/rfcs/blob/HEAD/text/1291-promote-libc.md
21+
[windows-sys]: https://docs.rs/windows-sys
1822

1923
## v0.3 Roadmap
2024

libc-test/build.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3746,6 +3746,9 @@ fn test_linux(target: &str) {
37463746
if musl && ty == "fanout_args" {
37473747
return true;
37483748
}
3749+
if sparc64 && ty == "fanotify_event_info_error" {
3750+
return true;
3751+
}
37493752

37503753
match ty {
37513754
// These cannot be tested when "resolv.h" is included and are tested
@@ -4480,7 +4483,21 @@ fn test_linux(target: &str) {
44804483
// the `ifc_ifcu` field is an anonymous union
44814484
(struct_ == "ifconf" && field == "ifc_ifcu") ||
44824485
// glibc uses a single array `uregs` instead of individual fields.
4483-
(struct_ == "user_regs" && arm)
4486+
(struct_ == "user_regs" && arm) ||
4487+
// the `ifr_ifrn` field is an anonymous union
4488+
(struct_ == "iwreq" && field == "ifr_ifrn") ||
4489+
// the `key` field is a zero-sized array
4490+
(struct_ == "iw_encode_ext" && field == "key") ||
4491+
// the `tcpi_snd_rcv_wscale` map two bitfield fields stored in a u8
4492+
(struct_ == "tcp_info" && field == "tcpi_snd_rcv_wscale") ||
4493+
// the `tcpi_delivery_rate_app_limited` field is a bitfield on musl
4494+
(musl && struct_ == "tcp_info" && field == "tcpi_delivery_rate_app_limited") ||
4495+
// the `tcpi_fast_open_client_fail` field is a bitfield on musl
4496+
(musl && struct_ == "tcp_info" && field == "tcpi_fast_open_client_fail") ||
4497+
// either fsid_t or int[2] type
4498+
(struct_ == "fanotify_event_info_fid" && field == "fsid") ||
4499+
// `handle` is a VLA
4500+
(struct_ == "fanotify_event_info_fid" && field == "handle")
44844501
});
44854502

44864503
cfg.skip_roundtrip(move |s| match s {

libc-test/semver/emscripten.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
getentropy
22
posix_fallocate64
3+
getpwnam_r
4+
getpwuid_r

libc-test/semver/linux-gnu.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,15 @@ dlinfo
628628
dlmopen
629629
endutxent
630630
explicit_bzero
631+
fanotify_event_info_error
632+
fanotify_event_info_header
633+
fanotify_event_info_pidfd
634+
fgetgrent_r
631635
fgetspent_r
632636
futimes
633637
getauxval
634638
getentropy
635639
getgrent_r
636-
fgetgrent_r
637640
getloadavg
638641
getpt
639642
getpwent_r
@@ -712,3 +715,4 @@ putgrent
712715
execveat
713716
close_range
714717
epoll_pwait2
718+
tcp_info

libc-test/semver/linux-musl.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ process_vm_writev
8080
pwritev2
8181
pwritev64
8282
reallocarray
83+
tcp_info
8384
timex
8485
euidaccess
8586
eaccess

libc-test/semver/linux.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,7 @@ execvpe
34973497
faccessat
34983498
fallocate
34993499
fallocate64
3500+
fanotify_event_info_fid
35003501
fanotify_event_metadata
35013502
fanotify_init
35023503
fanotify_mark

src/unix/linux_like/emscripten/mod.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,21 @@ extern "C" {
17761776
) -> ::c_int;
17771777

17781778
pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
1779+
1780+
pub fn getpwnam_r(
1781+
name: *const ::c_char,
1782+
pwd: *mut passwd,
1783+
buf: *mut ::c_char,
1784+
buflen: ::size_t,
1785+
result: *mut *mut passwd,
1786+
) -> ::c_int;
1787+
pub fn getpwuid_r(
1788+
uid: ::uid_t,
1789+
pwd: *mut passwd,
1790+
buf: *mut ::c_char,
1791+
buflen: ::size_t,
1792+
result: *mut *mut passwd,
1793+
) -> ::c_int;
17791794
}
17801795

17811796
// Alias <foo> to <foo>64 to mimic glibc's LFS64 support

src/unix/linux_like/linux/gnu/mod.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,55 @@ s! {
454454
pub aio_flags: ::__u32,
455455
pub aio_resfd: ::__u32,
456456
}
457+
458+
// netinet/tcp.h
459+
460+
pub struct tcp_info {
461+
pub tcpi_state: u8,
462+
pub tcpi_ca_state: u8,
463+
pub tcpi_retransmits: u8,
464+
pub tcpi_probes: u8,
465+
pub tcpi_backoff: u8,
466+
pub tcpi_options: u8,
467+
/// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
468+
/// Each is 4 bits.
469+
pub tcpi_snd_rcv_wscale: u8,
470+
pub tcpi_rto: u32,
471+
pub tcpi_ato: u32,
472+
pub tcpi_snd_mss: u32,
473+
pub tcpi_rcv_mss: u32,
474+
pub tcpi_unacked: u32,
475+
pub tcpi_sacked: u32,
476+
pub tcpi_lost: u32,
477+
pub tcpi_retrans: u32,
478+
pub tcpi_fackets: u32,
479+
pub tcpi_last_data_sent: u32,
480+
pub tcpi_last_ack_sent: u32,
481+
pub tcpi_last_data_recv: u32,
482+
pub tcpi_last_ack_recv: u32,
483+
pub tcpi_pmtu: u32,
484+
pub tcpi_rcv_ssthresh: u32,
485+
pub tcpi_rtt: u32,
486+
pub tcpi_rttvar: u32,
487+
pub tcpi_snd_ssthresh: u32,
488+
pub tcpi_snd_cwnd: u32,
489+
pub tcpi_advmss: u32,
490+
pub tcpi_reordering: u32,
491+
pub tcpi_rcv_rtt: u32,
492+
pub tcpi_rcv_space: u32,
493+
pub tcpi_total_retrans: u32,
494+
}
495+
496+
pub struct fanotify_event_info_pidfd {
497+
pub hdr: ::fanotify_event_info_header,
498+
pub pidfd: ::__s32,
499+
}
500+
501+
pub struct fanotify_event_info_error {
502+
pub hdr: ::fanotify_event_info_header,
503+
pub error: ::__s32,
504+
pub error_count: ::__u32,
505+
}
457506
}
458507

459508
impl siginfo_t {

src/unix/linux_like/linux/mod.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pub type loff_t = ::c_longlong;
1616
pub type pthread_key_t = ::c_uint;
1717
pub type pthread_once_t = ::c_int;
1818
pub type pthread_spinlock_t = ::c_int;
19+
pub type __kernel_fsid_t = __c_anonymous__kernel_fsid_t;
1920

2021
pub type __u8 = ::c_uchar;
2122
pub type __u16 = ::c_ushort;
@@ -548,6 +549,20 @@ s! {
548549
pub sh_entsize: Elf64_Xword,
549550
}
550551

552+
pub struct __c_anonymous_elf32_rel {
553+
pub r_offset: Elf32_Addr,
554+
pub r_info: Elf32_Word,
555+
}
556+
557+
pub struct __c_anonymous_elf64_rel {
558+
pub r_offset: Elf64_Addr,
559+
pub r_info: Elf64_Xword,
560+
}
561+
562+
pub struct __c_anonymous__kernel_fsid_t {
563+
pub val: [::c_int; 2],
564+
}
565+
551566
pub struct ucred {
552567
pub pid: ::pid_t,
553568
pub uid: ::uid_t,
@@ -615,6 +630,18 @@ s! {
615630
pub response: __u32,
616631
}
617632

633+
pub struct fanotify_event_info_header {
634+
pub info_type: __u8,
635+
pub pad: __u8,
636+
pub len: __u16,
637+
}
638+
639+
pub struct fanotify_event_info_fid {
640+
pub hdr: fanotify_event_info_header,
641+
pub fsid: ::__kernel_fsid_t,
642+
pub handle: [::c_uchar; 0],
643+
}
644+
618645
pub struct sockaddr_vm {
619646
pub svm_family: ::sa_family_t,
620647
pub svm_reserved1: ::c_ushort,

src/unix/linux_like/linux/musl/mod.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,73 @@ s! {
348348
pub len: ::__u32,
349349
pub options: ::__u32,
350350
}
351+
352+
// netinet/tcp.h
353+
354+
pub struct tcp_info {
355+
pub tcpi_state: u8,
356+
pub tcpi_ca_state: u8,
357+
pub tcpi_retransmits: u8,
358+
pub tcpi_probes: u8,
359+
pub tcpi_backoff: u8,
360+
pub tcpi_options: u8,
361+
/*
362+
* FIXME(musl): when musl headers are more up to date
363+
/// This contains the bitfields `tcpi_snd_wscale` and `tcpi_rcv_wscale`.
364+
/// Each is 4 bits.
365+
pub tcpi_snd_rcv_wscale: u8,
366+
/// This contains the bitfields `tcpi_delivery_rate_app_limited` (1 bit) and
367+
/// `tcpi_fastopen_client_fail` (2 bits).
368+
pub tcpi_delivery_fastopen_bitfields: u8,
369+
*/
370+
pub tcpi_rto: u32,
371+
pub tcpi_ato: u32,
372+
pub tcpi_snd_mss: u32,
373+
pub tcpi_rcv_mss: u32,
374+
pub tcpi_unacked: u32,
375+
pub tcpi_sacked: u32,
376+
pub tcpi_lost: u32,
377+
pub tcpi_retrans: u32,
378+
pub tcpi_fackets: u32,
379+
pub tcpi_last_data_sent: u32,
380+
pub tcpi_last_ack_sent: u32,
381+
pub tcpi_last_data_recv: u32,
382+
pub tcpi_last_ack_recv: u32,
383+
pub tcpi_pmtu: u32,
384+
pub tcpi_rcv_ssthresh: u32,
385+
pub tcpi_rtt: u32,
386+
pub tcpi_rttvar: u32,
387+
pub tcpi_snd_ssthresh: u32,
388+
pub tcpi_snd_cwnd: u32,
389+
pub tcpi_advmss: u32,
390+
pub tcpi_reordering: u32,
391+
pub tcpi_rcv_rtt: u32,
392+
pub tcpi_rcv_space: u32,
393+
pub tcpi_total_retrans: u32,
394+
pub tcpi_pacing_rate: u64,
395+
pub tcpi_max_pacing_rate: u64,
396+
pub tcpi_bytes_acked: u64,
397+
pub tcpi_bytes_received: u64,
398+
pub tcpi_segs_out: u32,
399+
pub tcpi_segs_in: u32,
400+
pub tcpi_notsent_bytes: u32,
401+
pub tcpi_min_rtt: u32,
402+
pub tcpi_data_segs_in: u32,
403+
pub tcpi_data_segs_out: u32,
404+
pub tcpi_delivery_rate: u64,
405+
pub tcpi_busy_time: u64,
406+
pub tcpi_rwnd_limited: u64,
407+
pub tcpi_sndbuf_limited: u64,
408+
pub tcpi_delivered: u32,
409+
pub tcpi_delivered_ce: u32,
410+
pub tcpi_bytes_sent: u64,
411+
pub tcpi_bytes_retrans: u64,
412+
pub tcpi_dsack_dups: u32,
413+
pub tcpi_reord_seen: u32,
414+
// FIXME(musl): to uncomment once CI musl is updated
415+
//pub tcpi_rcv_ooopack: u32,
416+
//pub tcpi_snd_wnd: u32,
417+
}
351418
}
352419

353420
s_no_extra_traits! {

src/unix/redox/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub type clockid_t = ::c_int;
2222
pub type dev_t = ::c_long;
2323
pub type fsblkcnt_t = ::c_ulong;
2424
pub type fsfilcnt_t = ::c_ulong;
25-
pub type ino_t = ::c_ulong;
25+
pub type ino_t = ::c_ulonglong;
2626
pub type mode_t = ::c_int;
2727
pub type nfds_t = ::c_ulong;
2828
pub type nlink_t = ::c_ulong;

0 commit comments

Comments
 (0)