Skip to content

Commit 19751e6

Browse files
joshtripletttgross35
authored andcommitted
Require rust >= 1.37 and drop libc_underscore_const_names conditional
[ adjust for ctest limitations - Trevor ]
1 parent a8ed1c2 commit 19751e6

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

build.rs

-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1919
"libc_deny_warnings",
2020
"libc_long_array",
2121
"libc_thread_local",
22-
"libc_underscore_const_names",
2322
"libc_ctest",
2423
];
2524

@@ -86,11 +85,6 @@ fn main() {
8685
set_cfg("libc_long_array");
8786
}
8887

89-
// Rust >= 1.37.0 allows underscores as anonymous constant names.
90-
if rustc_minor_ver >= 37 || rustc_dep_of_std {
91-
set_cfg("libc_underscore_const_names");
92-
}
93-
9488
// #[thread_local] is currently unstable
9589
if rustc_dep_of_std {
9690
set_cfg("libc_thread_local");

src/fixed_width_ints.rs

+31-25
Original file line numberDiff line numberDiff line change
@@ -60,40 +60,46 @@ cfg_if! {
6060
pub type __uint128_t = u128;
6161

6262
cfg_if! {
63-
if #[cfg(libc_underscore_const_names)] {
63+
if #[cfg(libc_ctest)] {
64+
// FIXME(ctest): ctest does not accept `_` as an identifier
65+
macro_rules! static_assert_eq {
66+
($a:expr, $b:expr) => {};
67+
}
68+
} else {
6469
macro_rules! static_assert_eq {
6570
($a:expr, $b:expr) => {
6671
const _: [(); $a] = [(); $b];
6772
};
6873
}
74+
}
75+
76+
}
6977

70-
// NOTE: if you add more platforms to here, you may need to cfg
71-
// these consts. They should always match the platform's values
72-
// for `sizeof(__int128)` and `_Alignof(__int128)`.
73-
const _SIZE_128: usize = 16;
74-
const _ALIGN_128: usize = 16;
78+
// NOTE: if you add more platforms to here, you may need to cfg
79+
// these consts. They should always match the platform's values
80+
// for `sizeof(__int128)` and `_Alignof(__int128)`.
81+
const _SIZE_128: usize = 16;
82+
const _ALIGN_128: usize = 16;
7583

76-
// Since Rust doesn't officially guarantee that these types
77-
// have compatible ABIs, we const assert that these values have the
78-
// known size/align of the target platform's libc. If rustc ever
79-
// tries to regress things, it will cause a compilation error.
80-
//
81-
// This isn't a bullet-proof solution because e.g. it doesn't
82-
// catch the fact that llvm and gcc disagree on how x64 __int128
83-
// is actually *passed* on the stack (clang underaligns it for
84-
// the same reason that rustc *never* properly aligns it).
85-
static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128);
86-
static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128);
84+
// Since Rust doesn't officially guarantee that these types
85+
// have compatible ABIs, we const assert that these values have the
86+
// known size/align of the target platform's libc. If rustc ever
87+
// tries to regress things, it will cause a compilation error.
88+
//
89+
// This isn't a bullet-proof solution because e.g. it doesn't
90+
// catch the fact that llvm and gcc disagree on how x64 __int128
91+
// is actually *passed* on the stack (clang underaligns it for
92+
// the same reason that rustc *never* properly aligns it).
93+
static_assert_eq!(core::mem::size_of::<__int128>(), _SIZE_128);
94+
static_assert_eq!(core::mem::align_of::<__int128>(), _ALIGN_128);
8795

88-
static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128);
89-
static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128);
96+
static_assert_eq!(core::mem::size_of::<__uint128>(), _SIZE_128);
97+
static_assert_eq!(core::mem::align_of::<__uint128>(), _ALIGN_128);
9098

91-
static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128);
92-
static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128);
99+
static_assert_eq!(core::mem::size_of::<__int128_t>(), _SIZE_128);
100+
static_assert_eq!(core::mem::align_of::<__int128_t>(), _ALIGN_128);
93101

94-
static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
95-
static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
96-
}
97-
}
102+
static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
103+
static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
98104
}
99105
}

0 commit comments

Comments
 (0)