summaryrefslogtreecommitdiff
path: root/scanpci
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-10-09 03:53:05 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-10-09 03:53:05 -0700
commitb9c5ce8083be53ea017bd15a63b173b4476fff23 (patch)
tree126c38cccb858c291ad9143ca88adb9444891c79 /scanpci
parent30e9ec91107791835d722f99498d659dec048922 (diff)
downloadlibpciaccess-b9c5ce8083be53ea017bd15a63b173b4476fff23.tar.gz
libpciaccess-b9c5ce8083be53ea017bd15a63b173b4476fff23.tar.bz2
libpciaccess-b9c5ce8083be53ea017bd15a63b173b4476fff23.zip
scanpci: Build fix for systems without <err.h>
https://bugs.freedesktop.org/show_bug.cgi?id=31133 Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'scanpci')
-rw-r--r--scanpci/scanpci.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/scanpci/scanpci.c b/scanpci/scanpci.c
index 36ecf04..219c814 100644
--- a/scanpci/scanpci.c
+++ b/scanpci/scanpci.c
@@ -22,11 +22,29 @@
* DEALINGS IN THE SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <stdlib.h>
#include <stdio.h>
-#include <err.h>
#include <unistd.h>
+#ifdef HAVE_ERR_H
+#include <err.h>
+#else
+# include <errno.h>
+# include <string.h>
+# define err(exitcode, format, args...) \
+ errx(exitcode, format ": %s", ## args, strerror(errno))
+# define errx(exitcode, format, args...) \
+ { warnx(format, ## args); exit(exitcode); }
+# define warn(format, args...) \
+ warnx(format ": %s", ## args, strerror(errno))
+# define warnx(format, args...) \
+ fprintf(stderr, format "\n", ## args)
+#endif
+
#include "pciaccess.h"