aboutsummaryrefslogtreecommitdiff
path: root/include/util
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-11-14 15:45:46 +0000
committerDavid Oberhollenzer <goliath@infraroot.at>2019-11-15 01:15:39 +0100
commitd8535473c787386e5a341632ea758013a61b247c (patch)
tree4ffb943b51f62836a8332156284d2cec40345c78 /include/util
parente21b55590c2b89989da3d6f272f518a69d109115 (diff)
Fix build on BSD systems
I tested FreeBSD, DragonflyBSD, NetBSD and OpenBSD and the endian macros weren't necessary (and in fact caused errors) on all of them. Because OpenBSD ships with an ancient GCC that doesn't support the checked addition/multiplication builtins, the build there would fail unless built with CC=cc or CC=clang. I changed configure.ac to prefer cc over gcc, so that the distribution's compiler preference is respected. (The default is [gcc cc]). I had to move AC_PROG_CC above LT_INIT because otherwise LT_INIT would run AC_PROG_CC first, and we wouldn't have a chance to use non-default parameters.
Diffstat (limited to 'include/util')
-rw-r--r--include/util/compat.h13
1 files changed, 5 insertions, 8 deletions
diff --git a/include/util/compat.h b/include/util/compat.h
index a1a45b6..cb9e81c 100644
--- a/include/util/compat.h
+++ b/include/util/compat.h
@@ -7,6 +7,10 @@
#ifndef COMPAT_H
#define COMPAT_H
+#ifndef __linux__
+#define O_PATH 0
+#endif
+
#if defined(__APPLE__)
#include <libkern/OSByteOrder.h>
@@ -17,14 +21,8 @@
#define le32toh(x) OSSwapLittleToHostInt32(x)
#define le16toh(x) OSSwapLittleToHostInt16(x)
#define le64toh(x) OSSwapLittleToHostInt64(x)
-#elif defined(__OpenBSD__)
+#elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
-#include <sys/endian.h>
-
-#define le16toh(x) letoh16(x)
-#define le32toh(x) letoh32(x)
-#define le64toh(x) letoh64(x)
#elif defined(_WIN32) || defined(__WINDOWS__)
#define htole16(x) (x)
#define htole32(x) (x)
@@ -107,7 +105,6 @@ struct stat {
#else
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/sysmacros.h>
#endif
#ifndef HAVE_GETLINE