From: Christopher Peplin Date: Sat, 4 Jan 2014 16:12:11 +0000 (-0500) Subject: Use more portable endinaness macros to check architecture. X-Git-Tag: 5.0.2~277^2~10 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=57ea37a8fad405df23256144367b6a18a5ab1580;p=apps%2Fagl-service-can-low-level.git Use more portable endinaness macros to check architecture. --- 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 #include #include -#include +#include 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,