summaryrefslogtreecommitdiffstats
path: root/bswap.h
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-07-13 17:24:42 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2005-07-13 17:24:42 +0000
commit2d7dbaa10fbdb7cc7985418cc71ae5c775c0a0fe (patch)
tree1126622054549852c4ae7566ad8c779c37d44423 /bswap.h
parente20ffdf5b682457fa0aadba61c1719e21accd8f0 (diff)
downloadmpv-2d7dbaa10fbdb7cc7985418cc71ae5c775c0a0fe.tar.bz2
mpv-2d7dbaa10fbdb7cc7985418cc71ae5c775c0a0fe.tar.xz
(hopefully) fixing remaining float endianness problems
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15977 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'bswap.h')
-rw-r--r--bswap.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/bswap.h b/bswap.h
index 42cd6400dd..16e488b149 100644
--- a/bswap.h
+++ b/bswap.h
@@ -117,6 +117,37 @@ static inline uint64_t ByteSwap64(uint64_t x)
#endif /* !HAVE_BYTESWAP_H */
+static float inline bswap_flt(float x) {
+ union {uint32_t i; float f;} u;
+ u.f = x;
+ u.i = bswap_32(u.i);
+ return u.f;
+}
+
+static double inline bswap_dbl(double x) {
+ union {uint64_t i; double d;} u;
+ u.d = x;
+ u.i = bswap_64(u.i);
+ return u.d;
+}
+
+static long double inline bswap_ldbl(long double x) {
+ union {char d[10]; long double ld;} uin;
+ union {char d[10]; long double ld;} uout;
+ uin.ld = x;
+ uout.d[0] = uin.d[9];
+ uout.d[1] = uin.d[8];
+ uout.d[2] = uin.d[7];
+ uout.d[3] = uin.d[6];
+ uout.d[4] = uin.d[5];
+ uout.d[5] = uin.d[4];
+ uout.d[6] = uin.d[3];
+ uout.d[7] = uin.d[2];
+ uout.d[8] = uin.d[1];
+ uout.d[9] = uin.d[0];
+ return uout.ld;
+}
+
// be2me ... BigEndian to MachineEndian
// le2me ... LittleEndian to MachineEndian
@@ -127,6 +158,12 @@ static inline uint64_t ByteSwap64(uint64_t x)
#define le2me_16(x) bswap_16(x)
#define le2me_32(x) bswap_32(x)
#define le2me_64(x) bswap_64(x)
+#define be2me_flt(x) (x)
+#define be2me_dbl(x) (x)
+#define be2me_ldbl(x) (x)
+#define le2me_flt(x) bswap_flt(x)
+#define le2me_dbl(x) bswap_dbl(x)
+#define le2me_ldbl(x) bswap_ldbl(x)
#else
#define be2me_16(x) bswap_16(x)
#define be2me_32(x) bswap_32(x)
@@ -134,6 +171,12 @@ static inline uint64_t ByteSwap64(uint64_t x)
#define le2me_16(x) (x)
#define le2me_32(x) (x)
#define le2me_64(x) (x)
+#define be2me_flt(x) bswap_flt(x)
+#define be2me_dbl(x) bswap_dbl(x)
+#define be2me_ldbl(x) bswap_ldbl(x)
+#define le2me_flt(x) (x)
+#define le2me_dbl(x) (x)
+#define le2me_ldbl(x) (x)
#endif
#endif /* __BSWAP_H__ */