summaryrefslogtreecommitdiffhomepage
path: root/src/internal/ntux_errinfo_impl.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/internal/ntux_errinfo_impl.h')
-rw-r--r--src/internal/ntux_errinfo_impl.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/internal/ntux_errinfo_impl.h b/src/internal/ntux_errinfo_impl.h
new file mode 100644
index 0000000..1d3b527
--- /dev/null
+++ b/src/internal/ntux_errinfo_impl.h
@@ -0,0 +1,96 @@
+/***********************************************************/
+/* ntux: native translation und extension */
+/* Copyright (C) 2016--2018 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.NTUX. */
+/***********************************************************/
+
+#include <ntux/ntux.h>
+
+int ntux_errno(const struct ntux_driver_ctx *);
+
+int ntux_errno_set(
+ const struct ntux_driver_ctx *,
+ int esyscode);
+
+int ntux_record_error(
+ const struct ntux_driver_ctx *,
+ int esyscode,
+ int elibcode,
+ const char * efunction,
+ int eline,
+ unsigned eflags,
+ void * eany);
+
+#define NTUX_SYSTEM_ERROR(dctx) \
+ ntux_record_error( \
+ dctx, \
+ ntux_errno(dctx), \
+ 0, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL, \
+ 0)
+
+#define NTUX_BUFFER_ERROR(dctx) \
+ ntux_record_error( \
+ dctx, \
+ ENOBUFS, \
+ 0, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL, \
+ 0)
+
+#define NTUX_SPAWN_ERROR(dctx) \
+ ntux_record_error( \
+ dctx, \
+ ntux_errno(dctx), \
+ 0, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL \
+ | (ntux_errno(dctx) ? 0 \
+ : NTUX_ERROR_CHILD), \
+ 0)
+
+#define NTUX_FILE_ERROR(dctx) \
+ ntux_record_error( \
+ dctx, \
+ EIO, \
+ 0, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL, \
+ 0)
+
+#define NTUX_CUSTOM_ERROR(dctx,elibcode) \
+ ntux_record_error( \
+ dctx, \
+ 0, \
+ elibcode, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL \
+ | NTUX_ERROR_CUSTOM, \
+ 0)
+
+#define NTUX_NATIVE_ERROR(dctx,elibcode) \
+ ntux_record_error( \
+ dctx, \
+ 0, \
+ elibcode, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_TOP_LEVEL \
+ | NTUX_ERROR_NATIVE, \
+ 0)
+
+#define NTUX_NESTED_ERROR(dctx) \
+ ntux_record_error( \
+ dctx, \
+ 0, \
+ 0, \
+ __func__, \
+ __LINE__, \
+ NTUX_ERROR_NESTED, \
+ 0)