CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
pointer.h File Reference

Pointer utilities. More...

#include <cheri.hh>
#include <concepts>

Go to the source code of this file.

Classes

class  ds::pointer::proxy::Pointer< T >
 Pointer references are pointer proxies, shockingly enough. More...
class  ds::pointer::proxy::PtrAddr< T >
 Equipped with a context for bounds, an address reference can be a proxy for a pointer. More...
class  ds::pointer::proxy::OffsetPtrAddr< Offset, T >
 Like the above, but with a constant offset on the interpretation of its addresss fields. More...

Concepts

concept  ds::pointer::proxy::Proxies
 Proxies<P,T> if P is a proxy object for T*-s.

Functions

template<typename T, typename U>
static T * ds::pointer::offset (U *base, std::integral auto offset)
 Offset a pointer by a number of bytes.
static size_t ds::pointer::diff (const void *base, const void *cursor)
 Compute the unsigned difference in bytes between two pointers' target addresses.
template<typename T>
 ds::pointer::proxy::PtrAddr (T *, ptraddr_t) -> PtrAddr< T >
 Deduction gude for the common enough case where the context type and the represented type are equal.

Detailed Description

Pointer utilities.

Definition in file pointer.h.

Function Documentation

◆ diff()

size_t ds::pointer::diff ( const void * base,
const void * cursor )
inlinestatic

Compute the unsigned difference in bytes between two pointers' target addresses.

To be standards-compliant, cursor must be part of the same allocation as base and at a higher address.

Definition at line 36 of file pointer.h.

◆ offset()

template<typename T, typename U>
T * ds::pointer::offset ( U * base,
std::integral auto offset )
inlinestatic

Offset a pointer by a number of bytes.

The return type must be explicitly specified by the caller. The type of the displacement offset (Offset) is templated so that we can accept both signed and unsigned offsets.

Definition at line 24 of file pointer.h.

References CHERI::Capability< T, IsSealedT >::address().