openalbridge/endianness.h
changeset 2203 6bd39d75e0dd
parent 2200 8192be6e3aef
child 2212 6b5da1a2765a
--- a/openalbridge/endianness.h	Sun Jun 28 16:44:04 2009 +0000
+++ b/openalbridge/endianness.h	Sun Jun 28 16:54:51 2009 +0000
@@ -28,11 +28,27 @@
 #ifdef __CPLUSPLUS
 extern "C" {
 #endif 
-
+	
+#ifdef HAVE_BYTESWAP_H
+	/* use byteswap macros from the host system, hopefully optimized ones ;-) */
+#include <byteswap.h>
+#else
+	/* define our own version, simple, stupid, straight-forward... */
+	
+#define bswap_16(x)	((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))
+	
+#define bswap_32(x)	((((x) & 0xFF000000) >> 24) | \
+					(((x) & 0x00FF0000) >> 8)  | \
+					(((x) & 0x0000FF00) << 8)  | \
+					(((x) & 0x000000FF) << 24) )
+	
+#endif
+	
+	
 #pragma once
-
-int invert_endianness(int number);
-
+	
+	int invert_endianness(int number);
+	
 #ifdef __CPLUSPLUS
 }
 #endif
\ No newline at end of file