diff options
author | Mattias Andrée <maandree@kth.se> | 2019-04-13 22:00:04 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-04-13 22:00:04 +0200 |
commit | 05ad06600b712a29bc99a65ae89f38d4d8f30371 (patch) | |
tree | 1d7d8a6ac3b83c0150635a2e81dd51d4e648e4b3 /liberror.h | |
parent | Document fields for error details (diff) | |
download | liberror-05ad06600b712a29bc99a65ae89f38d4d8f30371.tar.gz liberror-05ad06600b712a29bc99a65ae89f38d4d8f30371.tar.bz2 liberror-05ad06600b712a29bc99a65ae89f38d4d8f30371.tar.xz |
Add liberror_start and liberror_end
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'liberror.h')
-rw-r--r-- | liberror.h | 49 |
1 files changed, 49 insertions, 0 deletions
@@ -218,6 +218,31 @@ struct liberror_error { union liberror_details details; }; +/** + * Saved error state for a thread + */ +struct liberror_state { + /** + * The backtrace for the next error + */ + struct liberror_backtrace *backtrace; + + /** + * The thread's error + */ + struct liberror_error error; + + /** + * Whether the thread hade an error + */ + int have_error; + + /** + * The thread's value of `errno` + */ + int errnum; +}; + /** * Get the current error for the thread @@ -346,5 +371,29 @@ void liberror_set_error_errno(const char[256], const char[64], int); */ void liberror_print_error(struct liberror_error *, FILE *, int, const char *); +/** + * Save the thread's liberror error, pending backtrace, + * and `errno`, and then reset the error information + * for the thread + * + * Asynchronously called functions such as signal handlers + * should call this function the first thing they do + * + * @param state Output parameter for the error state + */ +void liberror_start(struct liberror_state *); + +/** + * Restore the thread's liberror error, pending backtrace, + * and `errno` + * + * Asynchronously called functions such as signal handlers + * should call this function the last thing they do before + * returning + * + * @param state The saved error state to restore + */ +void liberror_end(const struct liberror_state *); + #endif |