Big Endian Fixes like mad. Other fixes - Alex
[terminatorX.git] / src / tX_endian.h
index fc5dd69d570701c1a70be7a66d260bbfef0fcc43..122c944a3a7d8ae36eb7865956ae960c24896e87 100644 (file)
                 include <bits/endian.h>
 */    
 
+#ifndef _H_TX_ENDIAN_
+#define _H_TX_ENDIAN_
+
 #ifdef HAVE_CONFIG_H
-#include <config.h>
-#ifdef WORDS_BIGENDIAN
-#define BIG_ENDIAN_MACHINE 1
-#else
-#undef BIG_ENDIAN_MACHINE
-#endif
+#      include <config.h>
+#      ifdef WORDS_BIGENDIAN
+#              define BIG_ENDIAN_MACHINE 1
+#      else
+#              undef BIG_ENDIAN_MACHINE
+#      endif
 #endif
 
 #ifdef WORDS_BIGENDIAN
 
-#include "tX_types.h"
+#      include "tX_types.h"
+
+#define __USE_XOPEN // we need this for swab()
+#      include <unistd.h>
+#undef __USE_XOPEN
 
-#ifdef __cplusplus
+#define swapbuffer(b, s) swab((void *) b, (void *) b, (ssize_t) s<<1)
+
+#      ifdef __cplusplus
 extern "C" {
-#endif /* __cplusplus */
+#      endif /* __cplusplus */
 
 extern void swap16(int16_t * val);
 extern void swap32(int32_t * val);
-extern void swapbuffer(int16_t *buffer, int samples);
-#ifdef __cplusplus
+       
+#      ifdef __cplusplus
 }
-#endif /* __cplusplus */
+#      endif /* __cplusplus */
 
-#endif
+#endif /* WORDS_BIGENDIAN */
+
+#endif /* _H_TX_ENDIAN_ */