CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
Collaboration diagram for Internal helpers:

Macros

#define BITPACK_HAS_MACRO_MAP
 An in-situ probe for the #include-sion of <__macro_map.h>.
#define BITPACK_MAP_DECLTYPE_HELPER(x, b)
 Map function for BITPACK_MAP_DECLTYPE.
#define BITPACK_MAP_DECLTYPE(b, ...)
 Given bitpack b, qualify each additional argument with decltype(b).
#define BITPACK_MAP_DEPENDENT_HELPER(x, b)
 Map function for BITPACK_MAP_DEPENDENT.
#define BITPACK_MAP_DEPENDENT(b, ...)
 Given bitpack b, qualify each additional argument with typename decltype(b).
#define BITPACK_MAP_WITHS_HELPER(x)
 Map function for BITPACK_WITHS.

Detailed Description

Macro Definition Documentation

◆ BITPACK_HAS_MACRO_MAP

#define BITPACK_HAS_MACRO_MAP
Value:
([]() { \
struct BITPACK_HAS_MACRO_MAP_T \
{ \
char t; \
}; \
struct BITPACK_HAS_MACRO_MAP_U \
{ \
char u[2]; \
}; \
BITPACK_HAS_MACRO_MAP_U CHERIOT_EVAL0(BITPACK_HAS_MACRO_MAP_T); \
return sizeof(BITPACK_HAS_MACRO_MAP_T); \
}() > 1)

An in-situ probe for the #include-sion of <__macro_map.h>.

While we could gate our behavior on #if defined(CHERIOT_EVAL0), for example, that would require that <__macro_map.h> be included before us, which is slightly rude. Instead, we can take creative advantage of the syntactic primitives __macro_map.h uses internally and some C++ quirks to (ab)usefully test the behavior of CHERIOT_EVAL0 at each expansion of this macro.

In terms of operation, this relies on U CHERIOT_EVAL0(T); meaning one of two very different things and so dramatically changing what the subsequent sizeof(T) means.

  • If CHERIOT_EVAL0 hasn't been #defined, then this defines a function named CHERIOT_EVAL0 which takes a struct T and returns a U. In this case, the T in sizeof(T) means struct T, and that's 1 by definition, since sizeof(char) is defined to be 1.
  • If CHERIOT_EVAL0 has been defined as per <__macro_map.h>, then this is preprocessed into U T;, a variable declaration, and the T in sizeof(T) now refers to that variable and evaluates to 2.

Definition at line 1352 of file bitpack.hh.

◆ BITPACK_MAP_DECLTYPE

#define BITPACK_MAP_DECLTYPE ( b,
... )
Value:
CHERIOT_MAP_LIST_UD(BITPACK_MAP_DECLTYPE_HELPER, b, __VA_ARGS__)
#define BITPACK_MAP_DECLTYPE_HELPER(x, b)
Map function for BITPACK_MAP_DECLTYPE.
Definition bitpack.hh:1367

Given bitpack b, qualify each additional argument with decltype(b).

That is, BITPACK_MAP_DECLTYPE(b, X, Y) evalutes to decltype(b)::X, decltype(b)::Y.

This requires #include <__macro_map.h> (and will give confusing error messages if not included). (Because this is very much a C++ token level hack, unlike the other __macro_map users, it's hard for us to statically assert and give nice error messages.)

Definition at line 1380 of file bitpack.hh.

◆ BITPACK_MAP_DECLTYPE_HELPER

#define BITPACK_MAP_DECLTYPE_HELPER ( x,
b )
Value:
std::remove_reference_t<decltype(b)>::x

Map function for BITPACK_MAP_DECLTYPE.

Definition at line 1367 of file bitpack.hh.

◆ BITPACK_MAP_DEPENDENT

#define BITPACK_MAP_DEPENDENT ( b,
... )
Value:
CHERIOT_MAP_LIST_UD(BITPACK_MAP_DEPENDENT_HELPER, b, __VA_ARGS__)
#define BITPACK_MAP_DEPENDENT_HELPER(x, b)
Map function for BITPACK_MAP_DEPENDENT.
Definition bitpack.hh:1384

Given bitpack b, qualify each additional argument with typename decltype(b).

That is, BITPACK_DEPENDENT(b, X, Y) evalutes to typename decltype(b)::X, typename decltype(b)::Y.

This requires #include <__macro_map.h>.

Definition at line 1394 of file bitpack.hh.

◆ BITPACK_MAP_DEPENDENT_HELPER

#define BITPACK_MAP_DEPENDENT_HELPER ( x,
b )
Value:
typename std::remove_reference_t<decltype(b)>::x

Map function for BITPACK_MAP_DEPENDENT.

Definition at line 1384 of file bitpack.hh.

◆ BITPACK_MAP_WITHS_HELPER

#define BITPACK_MAP_WITHS_HELPER ( x)
Value:
.with(x)

Map function for BITPACK_WITHS.

Definition at line 1398 of file bitpack.hh.