From 6fab8af91df1b4212cec7ab7719e0b1aaef3fb38 Mon Sep 17 00:00:00 2001 From: relan Date: Sat, 26 Oct 2013 18:08:10 +0000 Subject: [PATCH] Fix bitmaps handling on big-endian machines. --- libexfat/byteorder.h | 8 ++++++++ libexfat/exfat.h | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libexfat/byteorder.h b/libexfat/byteorder.h index e06e065..a371c0c 100644 --- a/libexfat/byteorder.h +++ b/libexfat/byteorder.h @@ -31,6 +31,7 @@ typedef struct { uint32_t __u32; } le32_t; typedef struct { uint64_t __u64; } le64_t; #if EXFAT_BYTE_ORDER == EXFAT_LITTLE_ENDIAN + static inline uint16_t le16_to_cpu(le16_t v) { return v.__u16; } static inline uint32_t le32_to_cpu(le32_t v) { return v.__u32; } static inline uint64_t le64_to_cpu(le64_t v) { return v.__u64; } @@ -38,7 +39,11 @@ static inline uint64_t le64_to_cpu(le64_t v) { return v.__u64; } static inline le16_t cpu_to_le16(uint16_t v) { le16_t t = {v}; return t; } static inline le32_t cpu_to_le32(uint32_t v) { le32_t t = {v}; return t; } static inline le64_t cpu_to_le64(uint64_t v) { le64_t t = {v}; return t; } + +typedef size_t bitmap_t; + #elif EXFAT_BYTE_ORDER == EXFAT_BIG_ENDIAN + static inline uint16_t le16_to_cpu(le16_t v) { return exfat_bswap16(v.__u16); } static inline uint32_t le32_to_cpu(le32_t v) @@ -52,6 +57,9 @@ static inline le32_t cpu_to_le32(uint32_t v) { le32_t t = {exfat_bswap32(v)}; return t; } static inline le64_t cpu_to_le64(uint64_t v) { le64_t t = {exfat_bswap64(v)}; return t; } + +typedef unsigned char bitmap_t; + #else #error Wow! You have a PDP machine?! #endif diff --git a/libexfat/exfat.h b/libexfat/exfat.h index 50f690c..f8924cb 100644 --- a/libexfat/exfat.h +++ b/libexfat/exfat.h @@ -51,7 +51,6 @@ #define ROUND_UP(x, d) (DIV_ROUND_UP(x, d) * (d)) #define UTF8_BYTES(c) ((c) * 6) /* UTF-8 character can occupy up to 6 bytes */ -typedef size_t bitmap_t; #define BMAP_SIZE(count) (ROUND_UP(count, sizeof(bitmap_t) * 8) / 8) #define BMAP_BLOCK(index) ((index) / sizeof(bitmap_t) / 8) #define BMAP_MASK(index) ((bitmap_t) 1 << ((index) % (sizeof(bitmap_t) * 8))) -- 2.11.0