CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
assembly-helpers.h File Reference

Helpers for exposing field offsets and structure sizes into assembly. More...

Go to the source code of this file.

Classes

struct  CheckSize< Real, Expected >
 Helper class for checking the size of a structure. More...

Macros

#define EXPORT_ASSEMBLY_NAME(name, val)
 Export a macro into assembly named name with value value.
#define EXPORT_ASSEMBLY_EXPRESSION(name, expression, val)
 Export a macro into assembly named name with value value.
#define EXPORT_ASSEMBLY_OFFSET(structure, field, val)
 Export a macro into assembly of the form {structure}_offset_{field}.
#define EXPORT_ASSEMBLY_OFFSET_NAMED(structure, field, value, name)
 Variant of EXPORT_ASSEMBLY_OFFSET that can be used to specify the name of the exported offset.
#define EXPORT_ASSEMBLY_SIZE(structure, val)
 Export a macro into assembly of the form {structure}_size.

Detailed Description

Helpers for exposing field offsets and structure sizes into assembly.

This file provides macros that should be included in both C++ and assembly files. In C++, they will check (at compile time) that the values are correct and print a helpful error message if they do not. In assembly, they will simply expose the values as assembler symbol definitions.

Definition in file assembly-helpers.h.

Macro Definition Documentation

◆ EXPORT_ASSEMBLY_EXPRESSION

#define EXPORT_ASSEMBLY_EXPRESSION ( name,
expression,
val )
Value:
static constexpr size_t name = expression; \
static_assert(CheckSize<name, val>::Value, \
"Value provided for assembly is incorrect");

Export a macro into assembly named name with value value.

In C++, this macro will report an error if the provided value does not equal the constexpr evaluation of expression.

Definition at line 41 of file assembly-helpers.h.

◆ EXPORT_ASSEMBLY_NAME

#define EXPORT_ASSEMBLY_NAME ( name,
val )
Value:
static_assert(CheckSize<name, val>::Value, \
"Value provided for assembly is incorrect");

Export a macro into assembly named name with value value.

In C++, this macro will report an error if the provided value does not equal the constexpr evaluation of expression.

Definition at line 32 of file assembly-helpers.h.

◆ EXPORT_ASSEMBLY_OFFSET

#define EXPORT_ASSEMBLY_OFFSET ( structure,
field,
val )
Value:
static constexpr size_t structure##_offset_##field = val; \
static_assert(CheckSize<offsetof(structure, field), val>::Value, \
"Offset provided for assembly is incorrect");
Helper class for checking the size of a structure.

Export a macro into assembly of the form {structure}_offset_{field}.

The value of this macro will be value. In C++, this macro will report an error if the provided value does not match the compiler's understanding of the field offset. The error message will contain the correct value.

This macros also defines a static constexpr value of the same name as the assembly definition.

Definition at line 55 of file assembly-helpers.h.

◆ EXPORT_ASSEMBLY_OFFSET_NAMED

#define EXPORT_ASSEMBLY_OFFSET_NAMED ( structure,
field,
value,
name )
Value:
static constexpr size_t name = value; \
EXPORT_ASSEMBLY_OFFSET(structure, field, value)

Variant of EXPORT_ASSEMBLY_OFFSET that can be used to specify the name of the exported offset.

This is useful for providing the offset of fields in nested structures when assembly code does not need to know the shape of the overall structure, only the offset of various fields.

This macros also defines a static constexpr value of the same name as the assembly definition.

Definition at line 69 of file assembly-helpers.h.

◆ EXPORT_ASSEMBLY_SIZE

#define EXPORT_ASSEMBLY_SIZE ( structure,
val )
Value:
static constexpr size_t structure##_size = val; \
static_assert(CheckSize<sizeof(structure), val>::Value, \
"Size provided for assembly is incorrect");

Export a macro into assembly of the form {structure}_size.

The value of this macro will be value. In C++, this macro will report an error if the provided value does not match the compiler's understanding of the structure size. The error message will contain the correct value.

This macros also defines a static constexpr value of the same name as the assembly definition.

Definition at line 81 of file assembly-helpers.h.