From d1a194d437608fd036f6eb22ab7db284ee7c07f4 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 9 Oct 2007 20:05:16 +0200 Subject: [PATCH] error.h: Add more helper macros. --- error.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/error.h b/error.h index 5ed38304..2d03585a 100644 --- a/error.h +++ b/error.h @@ -516,17 +516,23 @@ extern const char **para_errlist[]; */ #define ERRNUM_TO_INDEX(num) (((1 << SS_SHIFT) - 1) & (num)) +#define SYSTEM_ERROR_BIT 30 + +#define IS_SYSTEM_ERROR(num) (!!((num) & (1 << SYSTEM_ERROR_BIT))) + +#define ERRNO_TO_PARA_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT)) + +#define IS_SYSTEM_ERRNO(val, _errno) (ERRNO_TO_PARA_ERROR(_errno) == (val)) + /** * paraslash's version of strerror(3) * * expands to the error text of \a num (a string constant). */ -#define PARA_STRERROR(num) (num) & (1 << 30)? \ - strerror((num) & ((1 << 30) - 1)) : \ +#define PARA_STRERROR(num) IS_SYSTEM_ERROR(num)? \ + strerror((num) & ((1 << SYSTEM_ERROR_BIT) - 1)) : \ para_errlist[ERRNUM_TO_SS(num)] [ERRNUM_TO_INDEX(num)] -#define ERRNO_TO_PARA_ERROR(num) (-((num) | (1 << 30))) - /** * define the error list for one subsystem # -- 2.39.5