aboutsummaryrefslogtreecommitdiff
path: root/src/compat
diff options
context:
space:
mode:
authorMatt Corallo <git@bluematt.me>2018-04-16 11:43:57 -0400
committerMatt Corallo <git@bluematt.me>2018-04-16 11:47:32 -0400
commit150b2f0265f11590940d9c89560b5c067f4d2120 (patch)
tree5b7a2c9969d41fc8a096b3c8a0332b7b85458899 /src/compat
parent0d6992168c2bda85b18fda8f6dea08da433a0dc9 (diff)
downloadbitcoin-150b2f0265f11590940d9c89560b5c067f4d2120.tar.xz
Default to defining endian-conversion DECLs in compat w/o config
While this isn't a supported build configuration, some build systems need to build without going through our autotools steps, so defaulting to something sane may make it easier to build. Specifically, this fixes the inability to build rust-bitcoinconsensus on some non-x86 platforms. It needs to build without our autotools/configure steps to ensure correct compile args are passed from the rust build system to gcc. Converting the args from the rust build system to gcc would be a lot of unmaintainable work.
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/endian.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/compat/endian.h b/src/compat/endian.h
index e5c7e50223..4f244c3930 100644
--- a/src/compat/endian.h
+++ b/src/compat/endian.h
@@ -19,6 +19,51 @@
#include <sys/endian.h>
#endif
+#ifndef HAVE_CONFIG_H
+// While not technically a supported configuration, defaulting to defining these
+// DECLs when we were compiled without autotools makes it easier for other build
+// systems to build things like libbitcoinconsensus for strange targets.
+#ifdef htobe16
+#define HAVE_DECL_HTOBE16 1
+#endif
+#ifdef htole16
+#define HAVE_DECL_HTOLE16 1
+#endif
+#ifdef be16toh
+#define HAVE_DECL_BE16TOH 1
+#endif
+#ifdef le16toh
+#define HAVE_DECL_LE16TOH 1
+#endif
+
+#ifdef htobe32
+#define HAVE_DECL_HTOBE32 1
+#endif
+#ifdef htole32
+#define HAVE_DECL_HTOLE32 1
+#endif
+#ifdef be32toh
+#define HAVE_DECL_BE32TOH 1
+#endif
+#ifdef le32toh
+#define HAVE_DECL_LE32TOH 1
+#endif
+
+#ifdef htobe64
+#define HAVE_DECL_HTOBE64 1
+#endif
+#ifdef htole64
+#define HAVE_DECL_HTOLE64 1
+#endif
+#ifdef be64toh
+#define HAVE_DECL_BE64TOH 1
+#endif
+#ifdef le64toh
+#define HAVE_DECL_LE64TOH 1
+#endif
+
+#endif // HAVE_CONFIG_H
+
#if defined(WORDS_BIGENDIAN)
#if HAVE_DECL_HTOBE16 == 0