@@ -12,7 +12,7 @@ pub type c_char = i8;
12
12
13
13
/// This is an exact copy of https://doc.rust-lang.org/core/ffi/enum.c_void.html
14
14
/// It should be Equivalent to C's void type when used as a pointer.
15
- ///
15
+ ///
16
16
/// We can replace this with `core::ffi::c_void` once we update the rustc version to >=1.30.0.
17
17
#[ repr( u8 ) ]
18
18
pub enum c_void {
@@ -40,3 +40,42 @@ mod tests {
40
40
assert_eq ! ( TypeId :: of:: <types:: c_char>( ) , TypeId :: of:: <raw:: c_char>( ) ) ;
41
41
}
42
42
}
43
+
44
+
45
+ #[ doc( hidden) ]
46
+ #[ cfg( target_arch = "wasm32" ) ]
47
+ pub fn sanity_checks_for_wasm ( ) {
48
+ use std:: mem:: { size_of, align_of} ;
49
+ extern "C" {
50
+ pub static WASM32_INT_SIZE : c_uchar ;
51
+ pub static WASM32_INT_ALIGN : c_uchar ;
52
+
53
+ pub static WASM32_UNSIGNED_INT_SIZE : c_uchar ;
54
+ pub static WASM32_UNSIGNED_INT_ALIGN : c_uchar ;
55
+
56
+ pub static WASM32_SIZE_T_SIZE : c_uchar ;
57
+ pub static WASM32_SIZE_T_ALIGN : c_uchar ;
58
+
59
+ pub static WASM32_UNSIGNED_CHAR_SIZE : c_uchar ;
60
+ pub static WASM32_UNSIGNED_CHAR_ALIGN : c_uchar ;
61
+
62
+ pub static WASM32_PTR_SIZE : c_uchar ;
63
+ pub static WASM32_PTR_ALIGN : c_uchar ;
64
+ }
65
+ unsafe {
66
+ assert_eq ! ( size_of:: <c_int>( ) , WASM32_INT_SIZE as usize ) ;
67
+ assert_eq ! ( align_of:: <c_int>( ) , WASM32_INT_ALIGN as usize ) ;
68
+
69
+ assert_eq ! ( size_of:: <c_uint>( ) , WASM32_UNSIGNED_INT_SIZE as usize ) ;
70
+ assert_eq ! ( align_of:: <c_uint>( ) , WASM32_UNSIGNED_INT_ALIGN as usize ) ;
71
+
72
+ assert_eq ! ( size_of:: <size_t>( ) , WASM32_SIZE_T_SIZE as usize ) ;
73
+ assert_eq ! ( align_of:: <size_t>( ) , WASM32_SIZE_T_ALIGN as usize ) ;
74
+
75
+ assert_eq ! ( size_of:: <c_uchar>( ) , WASM32_UNSIGNED_CHAR_SIZE as usize ) ;
76
+ assert_eq ! ( align_of:: <c_uchar>( ) , WASM32_UNSIGNED_CHAR_ALIGN as usize ) ;
77
+
78
+ assert_eq ! ( size_of:: <* const ( ) >( ) , WASM32_PTR_SIZE as usize ) ;
79
+ assert_eq ! ( align_of:: <* const ( ) >( ) , WASM32_PTR_ALIGN as usize ) ;
80
+ }
81
+ }
0 commit comments