Kill all users of is_errno().
[osl.git] / error.h
1 #define FSCK_ERROR_BIT 29
2 /**
3 * This bit indicates whether a number is considered a system error number
4 * If yes, the system errno is just the result of clearing this bit from
5 * the given number.
6 */
7 #define SYSTEM_ERROR_BIT 30
8
9 /** Check whether the system error bit is set. */
10 #define IS_SYSTEM_ERROR(num) (!!((num) & (1 << SYSTEM_ERROR_BIT)))
11
12 /** Set the system error bit for the given number. */
13 #define ERRNO_TO_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT))
14
15 /**
16 * Check whether a given number is a system error number.
17 *
18 * \param num The value to be checked.
19 * \param _errno The system error number.
20 *
21 * \return True if \a num is the representation of the system
22 * error identified by \a _errno.
23 */
24 static inline int is_errno(int num, int _errno)
25 {
26 assert(num > 0 && _errno > 0);
27 return ERRNO_TO_ERROR(_errno) == num;
28 }