CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
CHERI::PermissionSet Class Reference

Class encapsulating a set of permissions. More...

#include <cheri.hh>

Public Member Functions

constexpr PermissionSet (Permission p)
 Constructs a permission set from a single permission.
constexpr PermissionSet (std::initializer_list< Permission > permissions)
 Construct a permission set from a list of permissions.
constexpr PermissionSet (const PermissionSet &other)=default
 Copy constructor.
constexpr PermissionSet operator& (PermissionSet p)
 And-permissions operation, creates a new permission set containing only permissions present in both this set and the argument.
constexpr PermissionSet & operator&= (PermissionSet p)
 And-permissions operation, removes all permissions that are not present in both permission sets.
constexpr PermissionSet without (Permission p) const
 Constructs a new permission set without the specified permission.
template<std::same_as< Permission >... Permissions>
constexpr PermissionSet without (Permission p, Permissions... ps) const
 Constructs a new permission set without the specified permissions.
constexpr bool can_derive_from (PermissionSet other) const
 Returns true if, and only if, this permission set can be derived from the argument set.
constexpr bool contains (Permission permission) const
 Returns true if this permission set contains the specified permission.
template<std::same_as< Permission >... Permissions>
constexpr bool contains (Permission p, Permissions... ps) const
 Returns true if this permission set contains the specified permissions.
constexpr uint32_t as_raw () const
 Returns the raw permission mask as an integer containing a bitfield of permissions.
constexpr Iterator begin () const
 Returns an iterator over the permissions starting at the lowest-numbered permission.
constexpr Iterator end () const
 Returns an end iterator.
constexpr auto operator<=> (const PermissionSet Other) const
 Three-way comparison.
constexpr bool operator== (PermissionSet other) const
 Equality operator, wraps the three-way compare operator.

Static Public Member Functions

static constexpr uint32_t valid_permissions_mask ()
 Computes (at compile time) a bitmask containing the set of valid permission bits.
static constexpr PermissionSet from_raw (uint32_t raw)
 Constructs a permission set from a raw permission mask.
static constexpr PermissionSet omnipotent ()
 Returns a permission set representing all permissions.

Public Attributes

uint32_t rawPermissions = 0
 The raw bitmap of permissions.

Detailed Description

Class encapsulating a set of permissions.

Definition at line 89 of file cheri.hh.

Constructor & Destructor Documentation

◆ PermissionSet() [1/2]

CHERI::PermissionSet::PermissionSet ( Permission p)
inlineconstexpr

Constructs a permission set from a single permission.

Definition at line 204 of file cheri.hh.

◆ PermissionSet() [2/2]

CHERI::PermissionSet::PermissionSet ( std::initializer_list< Permission > permissions)
inlineconstexpr

Construct a permission set from a list of permissions.

Definition at line 212 of file cheri.hh.

Member Function Documentation

◆ as_raw()

uint32_t CHERI::PermissionSet::as_raw ( ) const
inlinenodiscardconstexpr

Returns the raw permission mask as an integer containing a bitfield of permissions.

Definition at line 307 of file cheri.hh.

References rawPermissions.

◆ begin()

Iterator CHERI::PermissionSet::begin ( ) const
inlinenodiscardconstexpr

Returns an iterator over the permissions starting at the lowest-numbered permission.

Definition at line 316 of file cheri.hh.

References rawPermissions.

◆ can_derive_from()

bool CHERI::PermissionSet::can_derive_from ( PermissionSet other) const
inlinenodiscardconstexpr

Returns true if, and only if, this permission set can be derived from the argument set.

Definition at line 277 of file cheri.hh.

References rawPermissions.

Referenced by operator<=>().

◆ contains() [1/2]

template<std::same_as< Permission >... Permissions>
bool CHERI::PermissionSet::contains ( Permission p,
Permissions... ps ) const
inlinenodiscardconstexpr

Returns true if this permission set contains the specified permissions.

Definition at line 297 of file cheri.hh.

References contains().

◆ contains() [2/2]

bool CHERI::PermissionSet::contains ( Permission permission) const
inlinenodiscardconstexpr

Returns true if this permission set contains the specified permission.

Definition at line 286 of file cheri.hh.

References rawPermissions.

Referenced by contains().

◆ end()

Iterator CHERI::PermissionSet::end ( ) const
inlinenodiscardconstexpr

Returns an end iterator.

Definition at line 324 of file cheri.hh.

◆ from_raw()

constexpr PermissionSet CHERI::PermissionSet::from_raw ( uint32_t raw)
inlinestaticconstexpr

Constructs a permission set from a raw permission mask.

Definition at line 195 of file cheri.hh.

References valid_permissions_mask().

◆ omnipotent()

constexpr PermissionSet CHERI::PermissionSet::omnipotent ( )
inlinestaticconstexpr

Returns a permission set representing all permissions.

Definition at line 231 of file cheri.hh.

References valid_permissions_mask().

Referenced by CHERI::Capability< T, IsSealedT >::without_permissions().

◆ operator&()

PermissionSet CHERI::PermissionSet::operator& ( PermissionSet p)
inlineconstexpr

And-permissions operation, creates a new permission set containing only permissions present in both this set and the argument.

Definition at line 240 of file cheri.hh.

References rawPermissions.

◆ operator&=()

PermissionSet & CHERI::PermissionSet::operator&= ( PermissionSet p)
inlineconstexpr

And-permissions operation, removes all permissions that are not present in both permission sets.

Definition at line 249 of file cheri.hh.

References rawPermissions.

◆ operator<=>()

auto CHERI::PermissionSet::operator<=> ( const PermissionSet Other) const
inlineconstexpr

Three-way comparison.

Treats a superset as greater-than, identical permissions as equivalent, and sets that don't have a superset releationship as unordered.

Definition at line 337 of file cheri.hh.

References can_derive_from(), and rawPermissions.

◆ operator==()

bool CHERI::PermissionSet::operator== ( PermissionSet other) const
inlineconstexpr

Equality operator, wraps the three-way compare operator.

Definition at line 357 of file cheri.hh.

◆ valid_permissions_mask()

constexpr uint32_t CHERI::PermissionSet::valid_permissions_mask ( )
inlinestaticconstexpr

Computes (at compile time) a bitmask containing the set of valid permission bits.

FIXME would ideally make this private and expose a public static constexpr field but this seems to trigger a compiler bug when trying to initialise said field using this function.

Definition at line 128 of file cheri.hh.

Referenced by from_raw(), and omnipotent().

◆ without() [1/2]

PermissionSet CHERI::PermissionSet::without ( Permission p) const
inlinenodiscardconstexpr

Constructs a new permission set without the specified permission.

Definition at line 258 of file cheri.hh.

References rawPermissions.

Referenced by without(), and CHERI::Capability< T, IsSealedT >::without_permissions().

◆ without() [2/2]

template<std::same_as< Permission >... Permissions>
PermissionSet CHERI::PermissionSet::without ( Permission p,
Permissions... ps ) const
inlinenodiscardconstexpr

Constructs a new permission set without the specified permissions.

Definition at line 267 of file cheri.hh.

References without().

Member Data Documentation

◆ rawPermissions

uint32_t CHERI::PermissionSet::rawPermissions = 0

The raw bitmap of permissions.

This is public so that this class meets the requirements of a structural type and can therefore be used as a template parameter. This field should never be directly modified.

Definition at line 190 of file cheri.hh.

Referenced by as_raw(), begin(), can_derive_from(), contains(), operator&(), operator&=(), operator<=>(), and without().


The documentation for this class was generated from the following file: