|
|
dd79d3 |
From 822739a9f5163f6836a05e694faaa7b88d74f39c Mon Sep 17 00:00:00 2001
|
|
|
dd79d3 |
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
|
|
dd79d3 |
Date: Tue, 9 Jan 2018 17:01:04 +0100
|
|
|
dd79d3 |
Subject: [PATCH] Fix machine portability issues, fixes tests on non-x86
|
|
|
dd79d3 |
architectures
|
|
|
dd79d3 |
|
|
|
dd79d3 |
---
|
|
|
dd79d3 |
lib/isc/tests/hash_test.c | 15 +++++++++++++++
|
|
|
dd79d3 |
lib/isc/unix/include/isc/int.h | 2 +-
|
|
|
dd79d3 |
2 files changed, 16 insertions(+), 1 deletion(-)
|
|
|
dd79d3 |
|
|
|
dd79d3 |
diff --git a/lib/isc/tests/hash_test.c b/lib/isc/tests/hash_test.c
|
|
|
dd79d3 |
index 0c287e83fa..d51b44fa26 100644
|
|
|
dd79d3 |
--- a/lib/isc/tests/hash_test.c
|
|
|
dd79d3 |
+++ b/lib/isc/tests/hash_test.c
|
|
|
dd79d3 |
@@ -1784,6 +1784,18 @@ ATF_TC_BODY(isc_hmacmd5, tc) {
|
|
|
dd79d3 |
}
|
|
|
dd79d3 |
#endif
|
|
|
dd79d3 |
|
|
|
dd79d3 |
+#ifdef WORDS_BIGENDIAN
|
|
|
dd79d3 |
+/* Source: https://stackoverflow.com/questions/2182002/convert-big-endian-to-little-endian-in-c-without-using-provided-func */
|
|
|
dd79d3 |
+static inline isc_uint64_t
|
|
|
dd79d3 |
+swap_uint64(isc_uint64_t val) {
|
|
|
dd79d3 |
+ val = ((val << 8) & 0xFF00FF00FF00FF00ULL ) |
|
|
|
dd79d3 |
+ ((val >> 8) & 0x00FF00FF00FF00FFULL );
|
|
|
dd79d3 |
+ val = ((val << 16) & 0xFFFF0000FFFF0000ULL ) |
|
|
|
dd79d3 |
+ ((val >> 16) & 0x0000FFFF0000FFFFULL );
|
|
|
dd79d3 |
+ return (val << 32) | (val >> 32);
|
|
|
dd79d3 |
+}
|
|
|
dd79d3 |
+#endif
|
|
|
dd79d3 |
+
|
|
|
dd79d3 |
/* CRC64 Test */
|
|
|
dd79d3 |
ATF_TC(isc_crc64);
|
|
|
dd79d3 |
ATF_TC_HEAD(isc_crc64, tc) {
|
|
|
dd79d3 |
@@ -1839,6 +1851,9 @@ ATF_TC_BODY(isc_crc64, tc) {
|
|
|
dd79d3 |
testcase->input_len);
|
|
|
dd79d3 |
}
|
|
|
dd79d3 |
isc_crc64_final(&crc;;
|
|
|
dd79d3 |
+#ifdef WORDS_BIGENDIAN
|
|
|
dd79d3 |
+ crc = swap_uint64(crc);
|
|
|
dd79d3 |
+#endif
|
|
|
dd79d3 |
tohexstr((unsigned char *) &crc, sizeof(crc), str);
|
|
|
dd79d3 |
ATF_CHECK_STREQ(str, testcase->result);
|
|
|
dd79d3 |
|
|
|
dd79d3 |
diff --git a/lib/isc/unix/include/isc/int.h b/lib/isc/unix/include/isc/int.h
|
|
|
dd79d3 |
index 00fc048f65..706353eaca 100644
|
|
|
dd79d3 |
--- a/lib/isc/unix/include/isc/int.h
|
|
|
dd79d3 |
+++ b/lib/isc/unix/include/isc/int.h
|
|
|
dd79d3 |
@@ -13,7 +13,7 @@
|
|
|
dd79d3 |
|
|
|
dd79d3 |
/*! \file */
|
|
|
dd79d3 |
|
|
|
dd79d3 |
-typedef char isc_int8_t;
|
|
|
dd79d3 |
+typedef signed char isc_int8_t;
|
|
|
dd79d3 |
typedef unsigned char isc_uint8_t;
|
|
|
dd79d3 |
typedef short isc_int16_t;
|
|
|
dd79d3 |
typedef unsigned short isc_uint16_t;
|
|
|
dd79d3 |
--
|
|
|
dd79d3 |
2.14.3
|
|
|
dd79d3 |
|