Skip to content

Commit 75be074

Browse files
committed
Sync more files with libc-0.2 to reduce the diff
1 parent 86b04cb commit 75be074

File tree

7 files changed

+56
-43
lines changed

7 files changed

+56
-43
lines changed

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4904,16 +4904,16 @@ pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC;
49044904
pub const TFD_TIMER_ABSTIME: ::c_int = 0x01;
49054905
pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02;
49064906

4907+
// sys/unistd.h
4908+
4909+
pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;
4910+
49074911
pub const KCMP_FILE: ::c_int = 100;
49084912
pub const KCMP_FILEOBJ: ::c_int = 101;
49094913
pub const KCMP_FILES: ::c_int = 102;
49104914
pub const KCMP_SIGHAND: ::c_int = 103;
49114915
pub const KCMP_VM: ::c_int = 104;
49124916

4913-
// sys/unistd.h
4914-
4915-
pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;
4916-
49174917
pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int {
49184918
a << 24
49194919
}
@@ -5632,19 +5632,19 @@ extern "C" {
56325632
pub fn closefrom(lowfd: ::c_int);
56335633
pub fn close_range(lowfd: ::c_uint, highfd: ::c_uint, flags: ::c_int) -> ::c_int;
56345634

5635+
pub fn execvpe(
5636+
file: *const ::c_char,
5637+
argv: *const *const ::c_char,
5638+
envp: *const *const ::c_char,
5639+
) -> ::c_int;
5640+
56355641
pub fn kcmp(
56365642
pid1: ::pid_t,
56375643
pid2: ::pid_t,
56385644
type_: ::c_int,
56395645
idx1: ::c_ulong,
56405646
idx2: ::c_ulong,
56415647
) -> ::c_int;
5642-
5643-
pub fn execvpe(
5644-
file: *const ::c_char,
5645-
argv: *const *const ::c_char,
5646-
envp: *const *const ::c_char,
5647-
) -> ::c_int;
56485648
}
56495649

56505650
#[link(name = "memstat")]

src/unix/bsd/freebsdlike/freebsd/riscv64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ s_no_extra_traits! {
3636
}
3737
}
3838

39-
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
40-
4139
cfg_if! {
4240
if #[cfg(feature = "extra_traits")] {
4341
impl PartialEq for gpregs {
@@ -142,6 +140,8 @@ cfg_if! {
142140
}
143141
}
144142

143+
pub(crate) const _ALIGNBYTES: usize = ::mem::size_of::<::c_longlong>() - 1;
144+
145145
pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
146146
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
147147
pub const MAP_32BIT: ::c_int = 0x00080000;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,10 @@ cfg_if! {
10451045
}
10461046
}
10471047

1048-
impl Eq for statfs { }
1048+
impl Eq for statfs {}
10491049

10501050
impl ::fmt::Debug for statfs {
1051-
fn fmt(&self, f: &mut ::fmt::Formatter)
1052-
-> ::fmt::Result {
1051+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
10531052
f.debug_struct("statfs")
10541053
.field("f_flags", &self.f_flags)
10551054
.field("f_bsize", &self.f_bsize)

src/unix/linux_like/android/b32/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ s_no_extra_traits! {
4848
pub uc_mcontext: mcontext_t,
4949
pub uc_sigmask__c_anonymous_union: __c_anonymous_uc_sigmask,
5050
/* The kernel adds extra padding after uc_sigmask to match
51-
* glibc sigset_t on ARM. */
51+
* glibc sigset_t on ARM. */
5252
__padding: [c_char; 120],
5353
__align: [::c_longlong; 0],
5454
uc_regspace: [::c_ulong; 128],

src/unix/linux_like/android/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4153,6 +4153,8 @@ extern "C" {
41534153
pub fn fflush_unlocked(stream: *mut ::FILE) -> ::c_int;
41544154
pub fn fgets_unlocked(buf: *mut ::c_char, size: ::c_int, stream: *mut ::FILE) -> *mut ::c_char;
41554155

4156+
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
4157+
41564158
pub fn memfd_create(name: *const ::c_char, flags: ::c_uint) -> ::c_int;
41574159
pub fn renameat2(
41584160
olddirfd: ::c_int,
@@ -4168,8 +4170,6 @@ extern "C" {
41684170
mask: ::c_uint,
41694171
statxbuf: *mut statx,
41704172
) -> ::c_int;
4171-
4172-
pub fn klogctl(syslog_type: ::c_int, bufp: *mut ::c_char, len: ::c_int) -> ::c_int;
41734173
}
41744174

41754175
cfg_if! {

src/unix/linux_like/linux/mod.rs

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
//! Linux-specific definitions for linux-like values
22
3+
use core::mem;
4+
35
pub type useconds_t = u32;
46
pub type dev_t = u64;
57
pub type socklen_t = u32;
@@ -422,7 +424,7 @@ s! {
422424
pub direction: ::__u16,
423425
pub trigger: ff_trigger,
424426
pub replay: ff_replay,
425-
// FIXME this is actually a union
427+
// FIXME(1.0) this is actually a union
426428
#[cfg(target_pointer_width = "64")]
427429
pub u: [u64; 4],
428430
#[cfg(target_pointer_width = "32")]
@@ -930,33 +932,39 @@ s! {
930932
pub disabled: __u8,
931933
pub flags: __u16,
932934
}
935+
933936
pub struct iw_point {
934937
pub pointer: *mut ::c_void,
935938
pub length: __u16,
936939
pub flags: __u16,
937940
}
941+
938942
pub struct iw_freq {
939943
pub m: __s32,
940944
pub e: __s16,
941945
pub i: __u8,
942946
pub flags: __u8,
943947
}
948+
944949
pub struct iw_quality {
945950
pub qual: __u8,
946951
pub level: __u8,
947952
pub noise: __u8,
948953
pub updated: __u8,
949954
}
955+
950956
pub struct iw_discarded {
951957
pub nwid: __u32,
952958
pub code: __u32,
953959
pub fragment: __u32,
954960
pub retries: __u32,
955961
pubmisc: __u32,
956962
}
963+
957964
pub struct iw_missed {
958965
pub beacon: __u32,
959966
}
967+
960968
pub struct iw_scan_req {
961969
pub scan_type: __u8,
962970
pub essid_len: __u8,
@@ -968,6 +976,7 @@ s! {
968976
pub max_channel_time: __u32,
969977
pub channel_list: [iw_freq; IW_MAX_FREQUENCIES],
970978
}
979+
971980
pub struct iw_encode_ext {
972981
pub ext_flags: __u32,
973982
pub tx_seq: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
@@ -977,22 +986,26 @@ s! {
977986
pub key_len: __u16,
978987
pub key: [__u8;0],
979988
}
989+
980990
pub struct iw_pmksa {
981991
pub cmd: __u32,
982992
pub bssid: ::sockaddr,
983993
pub pmkid: [__u8; IW_PMKID_LEN],
984994
}
995+
985996
pub struct iw_pmkid_cand {
986997
pub flags: __u32,
987998
pub index: __u32,
988999
pub bssid: ::sockaddr,
9891000
}
1001+
9901002
pub struct iw_statistics {
9911003
pub status: __u16,
9921004
pub qual: iw_quality,
9931005
pub discard: iw_discarded,
9941006
pub miss: iw_missed,
9951007
}
1008+
9961009
pub struct iw_range {
9971010
pub throughput: __u32,
9981011
pub min_nwid: __u32,
@@ -1038,6 +1051,7 @@ s! {
10381051
pub freq: [iw_freq; IW_MAX_FREQUENCIES],
10391052
pub enc_capa: __u32,
10401053
}
1054+
10411055
pub struct iw_priv_args {
10421056
pub cmd: __u32,
10431057
pub set_args: __u16,
@@ -1127,16 +1141,19 @@ cfg_if! {
11271141
pub low: iw_quality,
11281142
pub high: iw_quality,
11291143
}
1144+
11301145
pub struct iw_mlme {
11311146
pub cmd: __u16,
11321147
pub reason_code: __u16,
11331148
pub addr: ::sockaddr,
11341149
}
1150+
11351151
pub struct iw_michaelmicfailure {
11361152
pub flags: __u32,
11371153
pub src_addr: ::sockaddr,
11381154
pub tsc: [__u8; IW_ENCODE_SEQ_MAX_SIZE],
11391155
}
1156+
11401157
pub struct __c_anonymous_elf32_rela {
11411158
pub r_offset: Elf32_Addr,
11421159
pub r_info: Elf32_Word,
@@ -1251,7 +1268,10 @@ s_no_extra_traits! {
12511268
pub ifcu_req: *mut ::ifreq,
12521269
}
12531270

1271+
/// Structure used in SIOCGIFCONF request. Used to retrieve interface configuration for
1272+
/// machine (useful for programs which must know all networks accessible).
12541273
pub struct ifconf {
1274+
/// Size of buffer
12551275
pub ifc_len: ::c_int,
12561276
pub ifc_ifcu: __c_anonymous_ifc_ifcu,
12571277
}
@@ -1400,6 +1420,13 @@ s_no_extra_traits! {
14001420
size: [u8; ::__SIZEOF_PTHREAD_BARRIER_T],
14011421
}
14021422

1423+
// linux/net_tstamp.h
1424+
#[allow(missing_debug_implementations)]
1425+
pub struct sock_txtime {
1426+
pub clockid: ::clockid_t,
1427+
pub flags: ::__u32,
1428+
}
1429+
14031430
// linux/can.h
14041431
#[repr(align(8))]
14051432
#[allow(missing_debug_implementations)]
@@ -1433,19 +1460,7 @@ s_no_extra_traits! {
14331460
pub af: u32,
14341461
pub data: [u8; CANXL_MAX_DLEN],
14351462
}
1436-
}
1437-
1438-
s_no_extra_traits! {
1439-
// linux/net_tstamp.h
1440-
#[allow(missing_debug_implementations)]
1441-
pub struct sock_txtime {
1442-
pub clockid: ::clockid_t,
1443-
pub flags: ::__u32,
1444-
}
1445-
}
14461463

1447-
s_no_extra_traits! {
1448-
// linux/can.h
14491464
#[allow(missing_debug_implementations)]
14501465
pub union __c_anonymous_sockaddr_can_can_addr {
14511466
pub tp: __c_anonymous_sockaddr_can_tp,
@@ -1458,9 +1473,7 @@ s_no_extra_traits! {
14581473
pub can_ifindex: ::c_int,
14591474
pub can_addr: __c_anonymous_sockaddr_can_can_addr,
14601475
}
1461-
}
14621476

1463-
s_no_extra_traits! {
14641477
// linux/wireless.h
14651478
pub union iwreq_data {
14661479
pub name: [c_char; ::IFNAMSIZ],
@@ -3518,15 +3531,15 @@ pub const TP_STATUS_TS_SYS_HARDWARE: ::__u32 = 1 << 30;
35183531
pub const TP_STATUS_TS_RAW_HARDWARE: ::__u32 = 1 << 31;
35193532

35203533
pub const TPACKET_ALIGNMENT: usize = 16;
3521-
pub const TPACKET_HDRLEN: usize = ((core::mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
3534+
pub const TPACKET_HDRLEN: usize = ((mem::size_of::<::tpacket_hdr>() + TPACKET_ALIGNMENT - 1)
3535+
& !(TPACKET_ALIGNMENT - 1))
3536+
+ mem::size_of::<::sockaddr_ll>();
3537+
pub const TPACKET2_HDRLEN: usize = ((mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1)
35223538
& !(TPACKET_ALIGNMENT - 1))
3523-
+ core::mem::size_of::<::sockaddr_ll>();
3524-
pub const TPACKET2_HDRLEN: usize =
3525-
((core::mem::size_of::<::tpacket2_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1))
3526-
+ core::mem::size_of::<::sockaddr_ll>();
3527-
pub const TPACKET3_HDRLEN: usize =
3528-
((core::mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1))
3529-
+ core::mem::size_of::<::sockaddr_ll>();
3539+
+ mem::size_of::<::sockaddr_ll>();
3540+
pub const TPACKET3_HDRLEN: usize = ((mem::size_of::<::tpacket3_hdr>() + TPACKET_ALIGNMENT - 1)
3541+
& !(TPACKET_ALIGNMENT - 1))
3542+
+ mem::size_of::<::sockaddr_ll>();
35303543

35313544
// linux/netfilter.h
35323545
pub const NF_DROP: ::c_int = 0;
@@ -5046,7 +5059,7 @@ pub const CANXL_SEC: ::c_int = 0x01;
50465059
pub const CAN_MTU: usize = ::mem::size_of::<can_frame>();
50475060
pub const CANFD_MTU: usize = ::mem::size_of::<canfd_frame>();
50485061
pub const CANXL_MTU: usize = ::mem::size_of::<canxl_frame>();
5049-
// FIXME: use `core::mem::offset_of!` once that is available
5062+
// FIXME(offset_of): use `core::mem::offset_of!` once that is available
50505063
// https://github.com/rust-lang/rfcs/pull/3308
50515064
// pub const CANXL_HDR_SIZE: usize = core::mem::offset_of!(canxl_frame, data);
50525065
pub const CANXL_HDR_SIZE: usize = 12;
@@ -5561,7 +5574,6 @@ f! {
55615574
(x + TPACKET_ALIGNMENT - 1) & !(TPACKET_ALIGNMENT - 1)
55625575
}
55635576

5564-
55655577
pub fn BPF_RVAL(code: ::__u32) -> ::__u32 {
55665578
code & 0x18
55675579
}

src/unix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,7 @@ extern "C" {
900900
pub fn close(fd: ::c_int) -> ::c_int;
901901
pub fn dup(fd: ::c_int) -> ::c_int;
902902
pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
903+
903904
pub fn execl(path: *const c_char, arg0: *const c_char, ...) -> ::c_int;
904905
pub fn execle(path: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
905906
pub fn execlp(file: *const ::c_char, arg0: *const ::c_char, ...) -> ::c_int;
@@ -910,6 +911,7 @@ extern "C" {
910911
envp: *const *mut c_char,
911912
) -> ::c_int;
912913
pub fn execvp(c: *const c_char, argv: *const *mut c_char) -> ::c_int;
914+
913915
pub fn fork() -> pid_t;
914916
pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
915917
pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;

0 commit comments

Comments
 (0)