|
CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
|
APIs for synchronously handling traps. More...
#include <cdefs.h>#include <setjmp.h>#include <switcher.h>#include <thread.h>#include <unwind-assembly.h>Go to the source code of this file.
Classes | |
| struct | CleanupList |
| On-stack linked list of cleanup handlers. More... | |
Macros | |
| #define | CHERIOT_DURING |
| Simple error handling macros. | |
| #define | CHERIOT_HANDLER |
| See CHERIOT_DURING. | |
| #define | CHERIOT_END_HANDLER |
| See CHERIOT_DURING. | |
Functions | |
| static struct CleanupList ** | cleanup_list_head () |
| Head of the cleanup list. | |
| static void | cleanup_unwind (void) |
| Unwind the stack to the most recent CHERIOT_HANDLER block. | |
| static void | on_error (auto fn, auto err) |
| On-error helper. | |
| static void | on_error (auto fn) |
| On-error helper with no error handler (returns normally from forced unwind). | |
APIs for synchronously handling traps.
Definition in file unwind.h.
| #define CHERIOT_DURING |
Simple error handling macros.
These are modelled on the OpenStep exception macros and are similarly built on top of setjmp. Code between CHERIOT_DURING and CHERIOT_HANDLER corresponds to a try block. Code between CHERIOT_HANDLER and CHERIOT_END_HANDLER corresponds to a catch block, though no exception value is actually thrown.
Any automatic-storage values accessed in both blocks must be declared volatile.
Definition at line 84 of file unwind.h.
Referenced by on_error().
| #define CHERIOT_END_HANDLER |
| #define CHERIOT_HANDLER |
|
inlinestatic |
Head of the cleanup list.
This is stored in the space that the switcher reserves at the top of the stack. The stack is zeroed on entry to a compartment and so this will be null until explicitly written to.
This is managed by the CHERIOT_HANDLER macro and should not be used directly.
Definition at line 39 of file unwind.h.
References invocation_state_slot().
Referenced by cleanup_unwind().
|
inlinestatic |
Unwind the stack to the most recent CHERIOT_HANDLER block.
The equivalent of this code is run automatically if you add unwind_error_handler as a dependency for your compartment. If you implement a stackfull error handler then you can call this function to return to the last cleanup block. Such error handlers should call switcher_handler_invocation_count_reset if they do not wish the compartment to be forcibly unwound after an error limit is reached.
This can also be called directly to unwind to the closest handler on the stack.
Definition at line 63 of file unwind.h.
References cleanup_list_head(), CleanupList::env, CleanupList::next, and switcher_handler_invocation_count_reset().
|
inlinestatic |
On-error helper with no error handler (returns normally from forced unwind).
Definition at line 132 of file unwind.h.
References on_error().
|
inlinestatic |
On-error helper.
Invokes fn and, if cleanup_unwind is called, invokes err. Destructors in between fn and the frame that calls cleanup_unwind are not called, but this function returns normally and so destructors of objects above this on the stack will be called normally.
Definition at line 120 of file unwind.h.
References CHERIOT_DURING, CHERIOT_END_HANDLER, and CHERIOT_HANDLER.
Referenced by on_error().