aboutsummaryrefslogtreecommitdiffstats
path: root/liberror.h
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-04-13 22:00:04 +0200
committerMattias Andrée <maandree@kth.se>2019-04-13 22:00:04 +0200
commit05ad06600b712a29bc99a65ae89f38d4d8f30371 (patch)
tree1d7d8a6ac3b83c0150635a2e81dd51d4e648e4b3 /liberror.h
parentDocument fields for error details (diff)
downloadliberror-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.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/liberror.h b/liberror.h
index 3cad426..6062889 100644
--- a/liberror.h
+++ b/liberror.h
@@ -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