Skip to main content

Module layout

Module layout 

Source
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_32 watchOS, 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§

FieldLayout
One field of a RecordLayout.
RecordLayout
C layout of one struct or union on both pointer widths.
VtableHeaderLayout
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 Width order.
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 with NV_ALIGNAS(N) (Swift’s ClangImporter rejects more).

Functions§

layout_records
Computes the layout of every record of files, in declaration order, and checks it against rustc and the declared contracts.
layout_records_on
layout_records for 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 storing NvStrSlice by 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 host rustc layout.