diff --git a/endianness.h b/endianness.h
new file mode 100644
index 0000000000..376edb24c4
--- /dev/null
+++ b/endianness.h
@@ -0,0 +1,64 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2014 - Daniel De Matteis
+ *
+ * RetroArch is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Found-
+ * ation, either version 3 of the License, or (at your option) any later version.
+ *
+ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with RetroArch.
+ * If not, see .
+ */
+
+#ifndef __ENDIANNESS_H
+#define __ENDIANNESS_H
+
+#include
+
+static inline uint8_t is_little_endian(void)
+{
+ union
+ {
+ uint16_t x;
+ uint8_t y[2];
+ } u;
+
+ u.x = 1;
+ return u.y[0];
+}
+
+static inline uint32_t swap_if_big32(uint32_t val)
+{
+ if (is_little_endian())
+ return val;
+ return (val >> 24) | ((val >> 8) & 0xFF00) |
+ ((val << 8) & 0xFF0000) | (val << 24);
+}
+
+static inline uint32_t swap_if_little32(uint32_t val)
+{
+ if (is_little_endian())
+ return (val >> 24) | ((val >> 8) & 0xFF00) |
+ ((val << 8) & 0xFF0000) | (val << 24);
+ return val;
+}
+
+static inline uint16_t swap_if_big16(uint16_t val)
+{
+ if (is_little_endian())
+ return val;
+ return (val >> 8) | (val << 8);
+}
+
+static inline uint16_t swap_if_little16(uint16_t val)
+{
+ if (is_little_endian())
+ return (val >> 8) | (val << 8);
+ return val;
+}
+
+#endif
diff --git a/miscellaneous.h b/miscellaneous.h
index d751196f72..4c572571bb 100644
--- a/miscellaneous.h
+++ b/miscellaneous.h
@@ -38,6 +38,7 @@
#include "msvc/msvc_compat.h"
#include "retroarch_logger.h"
+#include "endianness.h"
#include
/* Some platforms do not set this value.
@@ -107,48 +108,6 @@ static inline uint32_t prev_pow2(uint32_t v)
return v - (v >> 1);
}
-static inline uint8_t is_little_endian(void)
-{
- union
- {
- uint16_t x;
- uint8_t y[2];
- } u;
-
- u.x = 1;
- return u.y[0];
-}
-
-static inline uint32_t swap_if_big32(uint32_t val)
-{
- if (is_little_endian())
- return val;
- return (val >> 24) | ((val >> 8) & 0xFF00) |
- ((val << 8) & 0xFF0000) | (val << 24);
-}
-
-static inline uint32_t swap_if_little32(uint32_t val)
-{
- if (is_little_endian())
- return (val >> 24) | ((val >> 8) & 0xFF00) |
- ((val << 8) & 0xFF0000) | (val << 24);
- return val;
-}
-
-static inline uint16_t swap_if_big16(uint16_t val)
-{
- if (is_little_endian())
- return val;
- return (val >> 8) | (val << 8);
-}
-
-static inline uint16_t swap_if_little16(uint16_t val)
-{
- if (is_little_endian())
- return (val >> 8) | (val << 8);
- return val;
-}
-
/* Helper macros and struct to keep track of many booleans.
* To check for multiple bits, use &&, not &.
* For OR, | can be used. */