summaryrefslogtreecommitdiffstats
path: root/dvdread/bswap.h
diff options
context:
space:
mode:
Diffstat (limited to 'dvdread/bswap.h')
-rw-r--r--dvdread/bswap.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/dvdread/bswap.h b/dvdread/bswap.h
index 7abd167a43..6e9d5a151e 100644
--- a/dvdread/bswap.h
+++ b/dvdread/bswap.h
@@ -80,6 +80,13 @@
#define B2N_32(x) x = be32toh(x)
#define B2N_64(x) x = be64toh(x)
+
+#elif defined(__APPLE__) || defined(__DARWIN__)
+#include <libkern/OSByteOrder.h>
+#define B2N_16(x) x = OSSwapBigToHostConstInt16(x)
+#define B2N_32(x) x = OSSwapBigToHostConstInt32(x)
+#define B2N_64(x) x = OSSwapBigToHostConstInt64(x)
+
#elif defined(ARCH_X86)
inline static unsigned short bswap_16(unsigned short x)
{
@@ -118,13 +125,22 @@ inline static unsigned long long int bswap_64(unsigned long long int x)
}
#define B2N_64(x) x = bswap_64(x)
+#else
+#if defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__) || defined(__INTERIX) || defined(__CYGWIN__)
+/* These systems don't have swap macros */
+#else
+/* If there isn't a header provided with your system with this functionality
+ * add the relevant || define( ) to the list above.
+ */
+#warning "You should add endian swap macros for your system"
+#endif
+
/* This is a slow but portable implementation, it has multiple evaluation
* problems so beware.
* Old FreeBSD's and Solaris don't have <byteswap.h> or any other such
* functionality!
*/
-#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__) || defined(WIN32) || defined(__BEOS__) || defined(__INTERIX) || defined(__CYGWIN__)
#define B2N_16(x) \
x = ((((x) & 0xff00) >> 8) | \
(((x) & 0x00ff) << 8))
@@ -143,12 +159,7 @@ inline static unsigned long long int bswap_64(unsigned long long int x)
(((x) & 0x000000000000ff00) << 40) | \
(((x) & 0x00000000000000ff) << 56))
-#else
-/* If there isn't a header provided with your system with this functionality
- * add the relevant || define( ) to the portable implementation above.
- */
-#error "You need to add endian swap macros for you're system"
#endif