summaryrefslogtreecommitdiffstats
path: root/exfat/libexfat/byteorder.h
diff options
context:
space:
mode:
authorbigbiff <bigbiff@teamw.in>2014-11-01 14:34:57 +0100
committerDees Troy <dees_troy@teamw.in>2014-11-04 15:37:42 +0100
commitc40c1c52d68049434b1379c3a6d8652a1363bb07 (patch)
tree08321140321dd893136fa2fb30b896ce2027cb24 /exfat/libexfat/byteorder.h
parentadd "done" after "Updating partition details..." (diff)
downloadandroid_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar.gz
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar.bz2
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar.lz
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar.xz
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.tar.zst
android_bootable_recovery-c40c1c52d68049434b1379c3a6d8652a1363bb07.zip
Diffstat (limited to 'exfat/libexfat/byteorder.h')
-rw-r--r--exfat/libexfat/byteorder.h85
1 files changed, 64 insertions, 21 deletions
diff --git a/exfat/libexfat/byteorder.h b/exfat/libexfat/byteorder.h
index dd039f283..10746e1ef 100644
--- a/exfat/libexfat/byteorder.h
+++ b/exfat/libexfat/byteorder.h
@@ -3,7 +3,7 @@
Endianness stuff. exFAT uses little-endian byte order.
Free exFAT implementation.
- Copyright (C) 2010-2014 Andrew Nayenko
+ Copyright (C) 2010-2013 Andrew Nayenko
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,15 +23,68 @@
#ifndef BYTEORDER_H_INCLUDED
#define BYTEORDER_H_INCLUDED
+#define __GLIBC__
#include <stdint.h>
-#include "platform.h"
+
+#if defined(__GLIBC__)
+
+#include <endian.h>
+#include <byteswap.h>
+
+#elif defined(__APPLE__)
+
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+#define bswap_16(x) OSSwapInt16(x)
+#define bswap_32(x) OSSwapInt32(x)
+#define bswap_64(x) OSSwapInt64(x)
+#define __BYTE_ORDER BYTE_ORDER
+#define __LITTLE_ENDIAN LITTLE_ENDIAN
+#define __BIG_ENDIAN BIG_ENDIAN
+
+#elif defined(__FreeBSD__) || defined(__DragonFlyBSD__) || defined(__NetBSD__)
+
+#include <sys/endian.h>
+#define bswap_16(x) bswap16(x)
+#define bswap_32(x) bswap32(x)
+#define bswap_64(x) bswap64(x)
+#define __BYTE_ORDER _BYTE_ORDER
+#define __LITTLE_ENDIAN _LITTLE_ENDIAN
+#define __BIG_ENDIAN _BIG_ENDIAN
+
+#elif defined(__OpenBSD__)
+
+#include <machine/endian.h>
+#define bswap_16(x) swap16(x)
+#define bswap_32(x) swap32(x)
+#define bswap_64(x) swap64(x)
+#define __BYTE_ORDER _BYTE_ORDER
+#define __LITTLE_ENDIAN _LITTLE_ENDIAN
+#define __BIG_ENDIAN _BIG_ENDIAN
+
+#elif defined(__sun)
+
+#include <sys/byteorder.h>
+#define bswap_16(x) BSWAP_16(x)
+#define bswap_32(x) BSWAP_32(x)
+#define bswap_64(x) BSWAP_64(x)
+#define __LITTLE_ENDIAN 1234
+#define __BIG_ENDIAN 4321
+#ifdef _LITTLE_ENDIAN
+#define __BYTE_ORDER __LITTLE_ENDIAN
+#else
+#define __BYTE_ORDER __BIG_ENDIAN
+#endif
+
+#else
+#error No byte order macros available for your platform
+#endif
typedef struct { uint16_t __u16; } le16_t;
typedef struct { uint32_t __u32; } le32_t;
typedef struct { uint64_t __u64; } le64_t;
-#if EXFAT_BYTE_ORDER == EXFAT_LITTLE_ENDIAN
-
+#if __BYTE_ORDER == __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; }
@@ -39,27 +92,17 @@ 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)
- { return exfat_bswap32(v.__u32); }
-static inline uint64_t le64_to_cpu(le64_t v)
- { return exfat_bswap64(v.__u64); }
+#elif __BYTE_ORDER == __BIG_ENDIAN
+static inline uint16_t le16_to_cpu(le16_t v) { return bswap_16(v.__u16); }
+static inline uint32_t le32_to_cpu(le32_t v) { return bswap_32(v.__u32); }
+static inline uint64_t le64_to_cpu(le64_t v) { return bswap_64(v.__u64); }
static inline le16_t cpu_to_le16(uint16_t v)
- { le16_t t = {exfat_bswap16(v)}; return t; }
+ { le16_t t = {bswap_16(v)}; return t; }
static inline le32_t cpu_to_le32(uint32_t v)
- { le32_t t = {exfat_bswap32(v)}; return t; }
+ { le32_t t = {bswap_32(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;
-
+ { le64_t t = {bswap_64(v)}; return t; }
#else
#error Wow! You have a PDP machine?!
#endif