pub struct DataLayout {Show 17 fields
pub char_is_signed: bool,
pub short_size: u64,
pub int_size: u64,
pub long_size: u64,
pub long_long_size: u64,
pub long_long_align: u64,
pub pointer_size: u64,
pub pointer_align: u64,
pub float: FloatType,
pub double: FloatType,
pub long_double: FloatType,
pub wchar_size: u64,
pub wchar_is_signed: bool,
pub leading_underscore: bool,
pub bitfield_order: BitfieldOrder,
pub max_field_align: Option<u64>,
pub has_int128: bool,
}Expand description
The type sizes and alignments a target’s headers were written against.
Everything here is a fact the psABI states and the compiler has to agree with. None of it is something C decides, which is the point: two compilers can both implement C correctly and disagree about every field in this struct, and the one that disagrees with the target’s headers is the one that is wrong.
Fields§
§char_is_signed: boolWhether a plain char is signed.
short_size: u64The width of a short in bytes, which is two everywhere on the target list.
int_size: u64The width of an int in bytes.
long_size: u64The width of a long in bytes, which is the field the old three field triple got wrong
for every 64-bit Windows target.
long_long_size: u64The width of a long long in bytes.
long_long_align: u64What a long long is aligned to.
Four on System V i386, where it is eight bytes aligned to four, which is
spec/cross-compile/06-abis.md section 6.2 item 2’s example of a layout rule that is not
derivable from the member alignments. Eight under mingw on the same architecture.
pointer_size: u64The width of a pointer in bytes.
pointer_align: u64What a pointer is aligned to.
float: FloatTypefloat.
double: FloatTypedouble.
long_double: FloatTypelong double, which is the one that differs across almost every target.
wchar_size: u64The width of a wchar_t in bytes, which decides what a wide string literal is encoded in.
Two on Windows, so a wide string there is UTF-16 and a character outside the basic plane
takes two elements, and four everywhere else, where it is UTF-32 and no character takes
more than one. It is the operating system’s answer and not the architecture’s, which
facts/aarch64-windows-msvc.facts and facts/aarch64-linux-gnu.facts show as a pair.
wchar_is_signed: boolWhether a wchar_t is signed.
A separate fact from DataLayout::char_is_signed and not derivable from it. AArch64
FreeBSD makes both unsigned, AArch64 NetBSD makes char unsigned and wchar_t signed, and
Windows makes char signed and wchar_t unsigned, so no rule over one of them answers the
other. L'\xffffffff' is minus one where this is true and four billion where it is false.
leading_underscore: boolWhether a symbol gets a leading underscore, which is section 6.2 item 11.
bitfield_order: BitfieldOrderWhich end of a storage unit a bit-field starts at.
max_field_align: Option<u64>The largest alignment the ABI will give a struct member on its own, in bytes, and None
where there is no cap.
Four on System V i386 and eight on s390x. A cap is invisible until a program uses a sixteen byte type inside a struct, and then it is a layout difference rather than an error.
has_int128: boolWhether the target has __int128.
It is a fact about the architecture and not about the pointer width, which is the trap:
x86_64-linux-gnux32 has four byte pointers and the type, and i686-linux-gnu has four
byte pointers and not the type. Both references provide it wherever the machine has sixty
four bit registers to hold half of it in, and refuse it everywhere else.
Implementations§
Source§impl DataLayout
impl DataLayout
Sourcepub fn for_target(target: TargetTuple) -> Self
pub fn for_target(target: TargetTuple) -> Self
The layout for this target.
Every field is derived from the tuple rather than from the host, which is
spec/cross-compile/08-sysroots.md section 8.5’s rule applied to types instead of to directories, and
it is what makes spec/cross-compile/02-the-goal.md claim 5 checkable: two hosts asking about the same
target get the same answer because there is nothing in here for the host to influence.
Sourcepub const fn long_double_is_double(&self) -> bool
pub const fn long_double_is_double(&self) -> bool
Whether a long double is really a double, which is true on Darwin, under MSVC and on
every 32-bit ARM target, and which decides whether %Lf and LDBL_MAX and the l
suffixed math functions mean anything different from their unsuffixed forms.
Trait Implementations§
Source§impl Clone for DataLayout
impl Clone for DataLayout
Source§fn clone(&self) -> DataLayout
fn clone(&self) -> DataLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more