@@ -63,19 +63,25 @@ They have the same layout as the [pointer types] for which the pointee is
63
63
64
64
## Fixed-width integer types
65
65
66
- Rust's signed and unsigned fixed-width integer types ` {i,u}{8,16,32,64} ` have
67
- the same layout as the C fixed-width integer types from the ` <stdint.h> ` header
68
- ` {u,}int{8,16,32,64}_t ` . That is:
66
+ For all Rust's fixed-width integer types ` {i,u}{8,16,32,64,128} ` it holds that:
69
67
70
68
* these types have no padding bits,
71
69
* their size exactly matches their bit-width,
72
70
* negative values of signed integer types are represented using 2's complement.
73
71
74
- This properties also hold for Rust's 128-bit wide ` {i,u}128 ` integer types, but
75
- C does not expose equivalent types in ` <stdint.h> ` .
72
+ Furthermore, Rust's signed and unsigned fixed-width integer types
73
+ ` {i,u}{8,16,32,64} ` have the same layout the C fixed-width integer types from
74
+ the ` <stdint.h> ` header ` {u,}int{8,16,32,64}_t ` . These fixed-width integer types
75
+ are therefore safe to use directly in C FFI where the corresponding C
76
+ fixed-width integer types are expected.
76
77
77
- Rust fixed-width integer types are therefore safe to use directly in C FFI where
78
- the corresponding C fixed-width integer types are expected.
78
+ The alignment of Rust's ` {i,u}128 ` is _ unspecified_ and allowed to change.
79
+
80
+ > ** Note** : While the C standard does not define fixed-width 128-bit wide
81
+ > integer types, many C compilers provide non-standard ` __int128 ` types as a
82
+ > language extension. The layout of ` {i,u}128 ` in the current Rust
83
+ > implementation does ** not** match that of these C types, see
84
+ > [ rust-lang/#54341 ] ( https://github.com/rust-lang/rust/issues/54341 ) .
79
85
80
86
### Layout compatibility with C native integer types
81
87
0 commit comments