summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-04 11:12:11 -0500
committerChristopher Peplin <chris.peplin@rhubarbtech.com>2014-01-04 11:12:11 -0500
commit57ea37a8fad405df23256144367b6a18a5ab1580 (patch)
treea5ea1803821c0ee01e9e5c1a95ea76f0c2a5750a /src
parent08db5c9eb826f7aa0dba36cbef8011d7bc6b55a5 (diff)
Use more portable endinaness macros to check architecture.
Diffstat (limited to 'src')
-rw-r--r--src/bitfield/bitfield.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bitfield/bitfield.c b/src/bitfield/bitfield.c
index 52f368f5..dddb0ee2 100644
--- a/src/bitfield/bitfield.c
+++ b/src/bitfield/bitfield.c
@@ -2,7 +2,7 @@
#include <limits.h>
#include <string.h>
#include <stddef.h>
-#include <endian.h>
+#include <sys/param.h>
uint64_t bitmask(const uint8_t bit_count) {
return (((uint64_t)0x1) << bit_count) - 1;
@@ -40,7 +40,10 @@ uint64_t get_bitfield(const uint8_t source[], const uint8_t source_length,
} combined;
copy_bits_right_aligned(source, source_length, offset, bit_count,
combined.bytes, sizeof(combined.bytes));
- return htobe64(combined.whole);
+ if(BYTE_ORDER == LITTLE_ENDIAN) {
+ combined.whole = __builtin_bswap64(combined.whole);
+ }
+ return combined.whole;
}
bool set_nibble(const uint16_t nibble_index, const uint8_t value,