Skip to content

[0.2] Backports #4090

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 18, 2024
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
8 changes: 4 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4589,11 +4589,11 @@ fn test_linux(target: &str) {
true
}

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

// FIXME: the call ABI of max_align_t is incorrect on these platforms:
Expand Down
23 changes: 23 additions & 0 deletions libc-test/semver/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1353,9 +1353,16 @@ IW_ENC_CAPA_CIPHER_TKIP
IW_ENC_CAPA_WPA
IW_ENC_CAPA_WPA2
IW_ESSID_MAX_SIZE
IW_EVENT_CAPA_K_0
IW_EVENT_CAPA_K_1
IW_EV_ADDR_PK_LEN
IW_EV_CHAR_PK_LEN
IW_EV_FREQ_PK_LEN
IW_EV_LCP_PK_LEN
IW_EV_PARAM_PK_LEN
IW_EV_POINT_PK_LEN
IW_EV_QUAL_PK_LEN
IW_EV_UINT_PK_LEN
IW_FREQ_AUTO
IW_FREQ_FIXED
IW_GENERIC_IE_MAX
Expand Down Expand Up @@ -3728,6 +3735,22 @@ ip_mreq_source
ip_mreqn
ipc_perm
itimerspec
iw_discarded
iw_encode_ext
iw_event
iw_freq
iw_missed
iw_param
iw_pmkid_cand
iw_pmksa
iw_point
iw_priv_args
iw_quality
iw_range
iw_scan_req
iw_statistics
iwreq
iwreq_data
j1939_filter
jrand48
key_t
Expand Down
4 changes: 4 additions & 0 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,8 @@ grantpt
group
hostent
hstrerror
htonl
htons
if_indextoname
if_nametoindex
in6_addr
Expand Down Expand Up @@ -658,6 +660,8 @@ munmap
nanosleep
nfds_t
nlink_t
ntohl
ntohs
off_t
open
opendir
Expand Down
15 changes: 15 additions & 0 deletions libc-test/test/primitive_types.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use std::any::TypeId;

macro_rules! ok {
($($t:ident)*) => {$(
assert!(TypeId::of::<libc::$t>() == TypeId::of::<ffi::$t>(),
"{} is wrong", stringify!($t));
)*}
}

#[test]
fn same() {
use std::ffi;
ok!(c_char c_schar c_uchar c_short c_ushort c_int c_uint c_long c_ulong
c_longlong c_ulonglong c_float c_double);
}
30 changes: 5 additions & 25 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,11 @@ macro_rules! s {
__item! {
#[repr(C)]
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
#[allow(deprecated)]
$(#[$attr])*
pub struct $i { $($field)* }
}
#[allow(deprecated)]
impl ::Copy for $i {}
#[allow(deprecated)]
impl ::Clone for $i {
fn clone(&self) -> $i { *self }
}
);
}

Expand All @@ -106,13 +101,10 @@ macro_rules! s_paren {
)* ) => ($(
__item! {
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
$(#[$attr])*
pub struct $i ( $($field)* );
}
impl ::Copy for $i {}
impl ::Clone for $i {
fn clone(&self) -> $i { *self }
}
)*);
}

Expand All @@ -130,28 +122,19 @@ macro_rules! s_no_extra_traits {
(it: $(#[$attr:meta])* pub union $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[derive(Copy, Clone)]
$(#[$attr])*
pub union $i { $($field)* }
}

impl ::Copy for $i {}
impl ::Clone for $i {
fn clone(&self) -> $i { *self }
}
);

(it: $(#[$attr:meta])* pub struct $i:ident { $($field:tt)* }) => (
__item! {
#[repr(C)]
#[derive(Copy, Clone)]
$(#[$attr])*
pub struct $i { $($field)* }
}
#[allow(deprecated)]
impl ::Copy for $i {}
#[allow(deprecated)]
impl ::Clone for $i {
fn clone(&self) -> $i { *self }
}
);
}

Expand All @@ -177,13 +160,10 @@ macro_rules! e {
)*) => ($(
__item! {
#[cfg_attr(feature = "extra_traits", derive(Debug, Eq, Hash, PartialEq))]
#[derive(Copy, Clone)]
$(#[$attr])*
pub enum $i { $($field)* }
}
impl ::Copy for $i {}
impl ::Clone for $i {
fn clone(&self) -> $i { *self }
}
)*);
}

Expand Down
Loading