Skip to content

Commit

Permalink
Small improvements to the token APIs.
Browse files Browse the repository at this point in the history
Expose `token_unseal` as the type-safe wrapper for everything (C macro,
C++ templated function).  Make `token_allocate` not use the `Sealed`
wrapper when it's not needed.

The macro currently triggers a compiler bug.
  • Loading branch information
davidchisnall committed Feb 20, 2025
1 parent d1c2275 commit c63a015
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/include/token.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,18 @@ __always_inline T *token_unseal(SKey key, Sealed<T> sealed)
{
return static_cast<T *>(token_obj_unseal(key, sealed));
}

#endif // __cplusplus

#if __has_extension(cheri_sealed_pointers)
# ifdef __cplusplus
template<typename T>
__always_inline T *token_unseal(SKey key, T *__sealed_capability sealed)
{
return static_cast<T *>(token_obj_unseal(key, sealed));
}
# else
# define token_unseal(key, sealed) /*NOLINT*/ \
((__typeof__(*(sealed)) *)token_obj_unseal(key, sealed))
# endif
#endif

0 comments on commit c63a015

Please sign in to comment.