@@ -99,6 +99,8 @@ cfg_if! {
99
99
target_os = "watchos"
100
100
) )
101
101
) ) ] {
102
+ use core:: mem:: { align_of, size_of} ;
103
+
102
104
// This introduces partial support for FFI with __int128 and
103
105
// equivalent types on platforms where Rust's definition is validated
104
106
// to match the standard C ABI of that platform.
@@ -143,34 +145,32 @@ cfg_if! {
143
145
const _SIZE_128: usize = 16 ;
144
146
const _ALIGN_128: usize = 16 ;
145
147
146
- // FIXME(ctest): ctest doesn't handle `_` as an identifier so these tests are temporarily
147
- // disabled.
148
- // macro_rules! static_assert_eq {
149
- // ($a:expr, $b:expr) => {
150
- // const _: [(); $a] = [(); $b];
151
- // };
152
- // }
148
+ macro_rules! static_assert_eq {
149
+ ( $a: expr, $b: expr) => {
150
+ const _: [ ( ) ; $a] = [ ( ) ; $b] ;
151
+ } ;
152
+ }
153
+
154
+ // Since Rust doesn't officially guarantee that these types
155
+ // have compatible ABIs, we const assert that these values have the
156
+ // known size/align of the target platform's libc. If rustc ever
157
+ // tries to regress things, it will cause a compilation error.
153
158
//
154
- // // Since Rust doesn't officially guarantee that these types
155
- // // have compatible ABIs, we const assert that these values have the
156
- // // known size/align of the target platform's libc. If rustc ever
157
- // // tries to regress things, it will cause a compilation error.
158
- // //
159
- // // This isn't a bullet-proof solution because e.g. it doesn't
160
- // // catch the fact that llvm and gcc disagree on how x64 __int128
161
- // // is actually *passed* on the stack (clang underaligns it for
162
- // // the same reason that rustc *never* properly aligns it).
163
- // static_assert_eq!(size_of::<__int128>(), _SIZE_128);
164
- // static_assert_eq!(align_of::<__int128>(), _ALIGN_128);
165
-
166
- // static_assert_eq!(size_of::<__uint128>(), _SIZE_128);
167
- // static_assert_eq!(align_of::<__uint128>(), _ALIGN_128);
168
-
169
- // static_assert_eq!(size_of::<__int128_t>(), _SIZE_128);
170
- // static_assert_eq!(align_of::<__int128_t>(), _ALIGN_128);
171
-
172
- // static_assert_eq!(size_of::<__uint128_t>(), _SIZE_128);
173
- // static_assert_eq!(align_of::<__uint128_t>(), _ALIGN_128);
159
+ // This isn't a bullet-proof solution because e.g. it doesn't
160
+ // catch the fact that llvm and gcc disagree on how x64 __int128
161
+ // is actually *passed* on the stack (clang underaligns it for
162
+ // the same reason that rustc *never* properly aligns it).
163
+ static_assert_eq!( size_of:: <__int128>( ) , _SIZE_128) ;
164
+ static_assert_eq!( align_of:: <__int128>( ) , _ALIGN_128) ;
165
+
166
+ static_assert_eq!( size_of:: <__uint128>( ) , _SIZE_128) ;
167
+ static_assert_eq!( align_of:: <__uint128>( ) , _ALIGN_128) ;
168
+
169
+ static_assert_eq!( size_of:: <__int128_t>( ) , _SIZE_128) ;
170
+ static_assert_eq!( align_of:: <__int128_t>( ) , _ALIGN_128) ;
171
+
172
+ static_assert_eq!( size_of:: <__uint128_t>( ) , _SIZE_128) ;
173
+ static_assert_eq!( align_of:: <__uint128_t>( ) , _ALIGN_128) ;
174
174
} else if #[ cfg( all(
175
175
target_arch = "aarch64" ,
176
176
any(
0 commit comments