Blob Blame History Raw
/***********************************************************/
/*  ntux: native translation und extension                 */
/*  Copyright (C) 2016--2021  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)