Skip to content

Commit 7c64d5d

Browse files
authored
Merge pull request #4064 from tgross35/remove-cfg-underscore-const-names
[0.2] Require rust >= 1.37 and drop libc_underscore_const_names conditional
2 parents b194077 + f0febd5 commit 7c64d5d

File tree

2 files changed

+30
-38
lines changed

2 files changed

+30
-38
lines changed

build.rs

-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ const ALLOWED_CFGS: &'static [&'static str] = &[
1717
"libc_deny_warnings",
1818
"libc_long_array",
1919
"libc_thread_local",
20-
"libc_underscore_const_names",
2120
"libc_ctest",
2221
];
2322

@@ -83,11 +82,6 @@ fn main() {
8382
set_cfg("libc_long_array");
8483
}
8584

86-
// Rust >= 1.37.0 allows underscores as anonymous constant names.
87-
if rustc_minor_ver >= 37 || rustc_dep_of_std {
88-
set_cfg("libc_underscore_const_names");
89-
}
90-
9185
// #[thread_local] is currently unstable
9286
if rustc_dep_of_std {
9387
set_cfg("libc_thread_local");

src/fixed_width_ints.rs

+30-32
Original file line numberDiff line numberDiff line change
@@ -59,41 +59,39 @@ cfg_if! {
5959
/// C __uint128_t (alternate name for [__uint128][])
6060
pub type __uint128_t = u128;
6161

62-
cfg_if! {
63-
if #[cfg(libc_underscore_const_names)] {
64-
macro_rules! static_assert_eq {
65-
($a:expr, $b:expr) => {
66-
const _: [(); $a] = [(); $b];
67-
};
68-
}
62+
// NOTE: if you add more platforms to here, you may need to cfg
63+
// these consts. They should always match the platform's values
64+
// for `sizeof(__int128)` and `_Alignof(__int128)`.
65+
const _SIZE_128: usize = 16;
66+
const _ALIGN_128: usize = 16;
6967

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;
75-
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);
68+
// FIXME(ctest): ctest doesn't handle `_` as an identifier so these tests are temporarily
69+
// disabled.
70+
// macro_rules! static_assert_eq {
71+
// ($a:expr, $b:expr) => {
72+
// const _: [(); $a] = [(); $b];
73+
// };
74+
// }
75+
//
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);
8787

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

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

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-
}
94+
// static_assert_eq!(core::mem::size_of::<__uint128_t>(), _SIZE_128);
95+
// static_assert_eq!(core::mem::align_of::<__uint128_t>(), _ALIGN_128);
9896
}
9997
}

0 commit comments

Comments
 (0)