Skip to content

Commit 78d6dcb

Browse files
authored
Merge pull request #4090 from tgross35/backport-leek
[0.2] Backports
2 parents 1c913e7 + 70e2542 commit 78d6dcb

File tree

7 files changed

+319
-31
lines changed

7 files changed

+319
-31
lines changed

libc-test/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4589,11 +4589,11 @@ fn test_linux(target: &str) {
45894589
true
45904590
}
45914591

4592-
// The `inotify_event` and `cmsghdr` types contain Flexible Array Member fields (the
4593-
// `name` and `data` fields respectively) which have unspecified calling convention.
4594-
// The roundtripping tests deliberately pass the structs by value to check "by value"
4595-
// layout consistency, but this would be UB for the these types.
4592+
// The following types contain Flexible Array Member fields which have unspecified calling
4593+
// convention. The roundtripping tests deliberately pass the structs by value to check "by
4594+
// value" layout consistency, but this would be UB for the these types.
45964595
"inotify_event" => true,
4596+
"fanotify_event_info_fid" => true,
45974597
"cmsghdr" => true,
45984598

45994599
// FIXME: the call ABI of max_align_t is incorrect on these platforms:

libc-test/semver/linux.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,9 +1353,16 @@ IW_ENC_CAPA_CIPHER_TKIP
13531353
IW_ENC_CAPA_WPA
13541354
IW_ENC_CAPA_WPA2
13551355
IW_ESSID_MAX_SIZE
1356+
IW_EVENT_CAPA_K_0
1357+
IW_EVENT_CAPA_K_1
1358+
IW_EV_ADDR_PK_LEN
13561359
IW_EV_CHAR_PK_LEN
1360+
IW_EV_FREQ_PK_LEN
13571361
IW_EV_LCP_PK_LEN
1362+
IW_EV_PARAM_PK_LEN
13581363
IW_EV_POINT_PK_LEN
1364+
IW_EV_QUAL_PK_LEN
1365+
IW_EV_UINT_PK_LEN
13591366
IW_FREQ_AUTO
13601367
IW_FREQ_FIXED
13611368
IW_GENERIC_IE_MAX
@@ -3728,6 +3735,22 @@ ip_mreq_source
37283735
ip_mreqn
37293736
ipc_perm
37303737
itimerspec
3738+
iw_discarded
3739+
iw_encode_ext
3740+
iw_event
3741+
iw_freq
3742+
iw_missed
3743+
iw_param
3744+
iw_pmkid_cand
3745+
iw_pmksa
3746+
iw_point
3747+
iw_priv_args
3748+
iw_quality
3749+
iw_range
3750+
iw_scan_req
3751+
iw_statistics
3752+
iwreq
3753+
iwreq_data
37313754
j1939_filter
37323755
jrand48
37333756
key_t

libc-test/semver/unix.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,8 @@ grantpt
588588
group
589589
hostent
590590
hstrerror
591+
htonl
592+
htons
591593
if_indextoname
592594
if_nametoindex
593595
in6_addr
@@ -658,6 +660,8 @@ munmap
658660
nanosleep
659661
nfds_t
660662
nlink_t
663+
ntohl
664+
ntohs
661665
off_t
662666
open
663667
opendir

libc-test/test/primitive_types.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std::any::TypeId;
2+
3+
macro_rules! ok {
4+
($($t:ident)*) => {$(
5+
assert!(TypeId::of::<libc::$t>() == TypeId::of::<ffi::$t>(),
6+
"{} is wrong", stringify!($t));
7+
)*}
8+
}
9+
10+
#[test]
11+
fn same() {
12+
use std::ffi;
13+
ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
14+
c_longlong c_ulonglong c_float c_double);
15+
}

src/macros.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,11 @@ macro_rules! s {
8282
__item! {
8383
#[repr(C)]
8484
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
85+
#[derive(Copy, Clone)]
8586
#[allow(deprecated)]
8687
$(#[$attr])*
8788
pub struct $i { $($field)* }
8889
}
89-
#[allow(deprecated)]
90-
impl ::Copy for $i {}
91-
#[allow(deprecated)]
92-
impl ::Clone for $i {
93-
fn clone(&self) -> $i { *self }
94-
}
9590
);
9691
}
9792

@@ -106,13 +101,10 @@ macro_rules! s_paren {
106101
)* ) => ($(
107102
__item! {
108103
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
104+
#[derive(Copy, Clone)]
109105
$(#[$attr])*
110106
pub struct $i ( $($field)* );
111107
}
112-
impl ::Copy for $i {}
113-
impl ::Clone for $i {
114-
fn clone(&self) -> $i { *self }
115-
}
116108
)*);
117109
}
118110

@@ -130,28 +122,19 @@ macro_rules! s_no_extra_traits {
130122
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
131123
__item! {
132124
#[repr(C)]
125+
#[derive(Copy, Clone)]
133126
$(#[$attr])*
134127
pub union $i { $($field)* }
135128
}
136-
137-
impl ::Copy for $i {}
138-
impl ::Clone for $i {
139-
fn clone(&self) -> $i { *self }
140-
}
141129
);
142130

143131
(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
144132
__item! {
145133
#[repr(C)]
134+
#[derive(Copy, Clone)]
146135
$(#[$attr])*
147136
pub struct $i { $($field)* }
148137
}
149-
#[allow(deprecated)]
150-
impl ::Copy for $i {}
151-
#[allow(deprecated)]
152-
impl ::Clone for $i {
153-
fn clone(&self) -> $i { *self }
154-
}
155138
);
156139
}
157140

@@ -177,13 +160,10 @@ macro_rules! e {
177160
)*) => ($(
178161
__item! {
179162
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
163+
#[derive(Copy, Clone)]
180164
$(#[$attr])*
181165
pub enum $i { $($field)* }
182166
}
183-
impl ::Copy for $i {}
184-
impl ::Clone for $i {
185-
fn clone(&self) -> $i { *self }
186-
}
187167
)*);
188168
}
189169

0 commit comments

Comments
 (0)