]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
error.h: Add more helper macros.
authorAndre Noll <maan@systemlinux.org>
Tue, 9 Oct 2007 18:05:16 +0000 (20:05 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 9 Oct 2007 18:05:16 +0000 (20:05 +0200)
error.h

diff --git a/error.h b/error.h
index 5ed3830450b2b1e19bf76600513f1c7e7ebc562d..2d03585a953f811c5d85cc1cea0cb474a18589c3 100644 (file)
--- 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 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).
  */
 /**
  * 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)]
 
        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
  #
 /**
  * define the error list for one subsystem
  #