diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/ChangeLog | 5 | ||||
| -rw-r--r-- | lib/system.h | 26 |
2 files changed, 30 insertions, 1 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index a95f8041..589953cf 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,10 @@ 2021-08-20 Saleem Abdulrasool <[email protected]> + * system.h: Check for HAVE_ERROR_H and HAVE_ERR_H and define + error_message_cont and error if necessary. + +2021-08-20 Saleem Abdulrasool <[email protected]> + * fixedsizehash.h: Remove sys/cdefs.h include. Unconditionally define STROF and CONCAT macros. diff --git a/lib/system.h b/lib/system.h index 58d9deee..b963fd15 100644 --- a/lib/system.h +++ b/lib/system.h @@ -29,8 +29,9 @@ #ifndef LIB_SYSTEM_H #define LIB_SYSTEM_H 1 +#include <config.h> + #include <errno.h> -#include <error.h> #include <stddef.h> #include <stdint.h> #include <sys/param.h> @@ -38,8 +39,31 @@ #include <byteswap.h> #include <unistd.h> #include <string.h> +#include <stdarg.h> #include <stdlib.h> +#if defined(HAVE_ERROR_H) +#include <error.h> +#elif defined(HAVE_ERR_H) +#include <err.h> + +static int error_message_count = 0; + +static inline void error(int status, int errnum, const char *format, ...) { + va_list argp; + + va_start(argp, format); + verr(status, format, argp); + va_end(argp); + + if (status) + exit(status); + ++error_message_count; +} +#else +#error "err.h or error.h must be available" +#endif + #if __BYTE_ORDER == __LITTLE_ENDIAN # define LE32(n) (n) # define LE64(n) (n) |
