X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=error.h;h=2d03585a953f811c5d85cc1cea0cb474a18589c3;hp=5ed3830450b2b1e19bf76600513f1c7e7ebc562d;hb=d1a194d437608fd036f6eb22ab7db284ee7c07f4;hpb=32facbd1b7948f146515e53194cfd4f33c54353f 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 #