#define FSCK_ERROR_BIT 29 /** * This bit indicates whether a number is considered a system error number * If yes, the system errno is just the result of clearing this bit from * the given number. */ #define SYSTEM_ERROR_BIT 30 /** Check whether the system error bit is set. */ #define IS_SYSTEM_ERROR(num) (!!((num) & (1 << SYSTEM_ERROR_BIT))) /** Set the system error bit for the given number. */ #define ERRNO_TO_ERROR(num) ((num) | (1 << SYSTEM_ERROR_BIT)) /** * Check whether a given number is a system error number. * * \param num The value to be checked. * \param _errno The system error number. * * \return True if \a num is the representation of the system * error identified by \a _errno. */ static inline int is_errno(int num, int _errno) { assert(num > 0 && _errno > 0); return ERRNO_TO_ERROR(_errno) == num; }