build: provide replacement for error(3) if not present

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2019-03-07 10:21:20 +01:00
parent ea72572364
commit 40ba2786d2
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
2 changed files with 18 additions and 2 deletions

View File

@ -32,7 +32,7 @@ PKG_CHECK_MODULES([FUSE], [fuse3 >= 3.2.1], [AC_DEFINE([HAVE_FUSE], 1, [Define i
AC_FUNC_ERROR_AT_LINE
AC_FUNC_MALLOC
AC_CHECK_FUNCS([memset strdup])
AC_CHECK_FUNCS([error memset strdup])
AC_CONFIG_FILES([Makefile lib/Makefile])
AC_OUTPUT

18
main.c
View File

@ -36,7 +36,23 @@
#include <assert.h>
#include <errno.h>
#include <err.h>
#include <error.h>
#ifdef HAVE_ERROR_H
# include <error.h>
#else
# define error(status, errno, fmt, ...) do { \
if (errno == 0) \
fprintf (stderr, "crun: " fmt "\n", ##__VA_ARGS__); \
else \
{ \
fprintf (stderr, "crun: " fmt, ##__VA_ARGS__); \
fprintf (stderr, ": %s\n", strerror (errno)); \
} \
if (status) \
exit (status); \
} while(0)
#endif
#include <inttypes.h>
#include <fcntl.h>
#include <hash.h>