Expand description
ABI type spellings and the C layout of every record on 32-bit and 64-bit targets.
#[derive(NvAbi)] records rustc’s field offsets for the build target only. Hosts also run on
32-bit targets, so this module recomputes every record’s C layout for the three data models NV
runs on, from the field types:
- LP64 / LLP64 (64-bit pointers);
- ILP32 with 8-byte-aligned 64-bit fields (
armeabi-v7a,arm64_32watchOS, wasm32, Windows x86); - i386 System V (Android x86, 32-bit Linux), where 64-bit fields are only 4-byte aligned inside structs.
It then checks the model of the running build against rustc and every declared offset /
size contract. A record whose layout drifts is a codegen error, never a wrong static_assert.
Structs§
- Field
Layout - One field of a
RecordLayout. - Record
Layout - C layout of one struct or union on both pointer widths.
- Vtable
Header Layout - Validated layout of one vtable’s leading header fields and first function-pointer slot offset.
- Width
- A size or offset under each
Model([P64, P32, I386]).
Enums§
- Model
- The C data models NV hosts run on, in
Widthorder. - Scalar
- Fixed-width scalar of the ABI.
- Ty
- One parsed ABI type spelling (
u32,*const NvValue,[u32; 5],Option<NvHostInvokeFn>,NvStrSlice,()).
Constants§
- MAX_
C_ ALIGNAS - Largest
align(N)C reproduces withNV_ALIGNAS(N)(Swift’s ClangImporter rejects more).
Functions§
- layout_
records - Computes the layout of every record of
files, in declaration order, and checks it againstrustcand the declared contracts. - layout_
records_ on layout_recordsfor files whose records may store records, aliases, or callbacks of an already laid out header they include (base,base_files), e.g. the runtime ABI storingNvStrSliceby value.- layout_
vtable_ headers_ on - Validates every vtable’s
header_fields,slots_offset, alignment, and total size across[P64, P32, I386]and against the running hostrustclayout.