summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobin KAY <komadori@users.sourceforge.net>2002-10-19 01:29:43 +0000
committerRobin KAY <komadori@users.sourceforge.net>2002-10-19 01:29:43 +0000
commit89b4a644aaf20684d284fc6d82569cb0313772bf (patch)
tree085cf3038f2d3d2cb491ba8f663ae3f8b64e225a /src
parent6faab586f7d56366404ffcd55797a6224134fc51 (diff)
downloadxine-lib-89b4a644aaf20684d284fc6d82569cb0313772bf.tar.gz
xine-lib-89b4a644aaf20684d284fc6d82569cb0313772bf.tar.bz2
Added AXE_xx macros and assertions for alignment
CVS patchset: 2856 CVS date: 2002/10/19 01:29:43
Diffstat (limited to 'src')
-rw-r--r--src/xine-engine/bswap.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/src/xine-engine/bswap.h b/src/xine-engine/bswap.h
index 276dfcbf7..3fd7f4565 100644
--- a/src/xine-engine/bswap.h
+++ b/src/xine-engine/bswap.h
@@ -11,6 +11,7 @@
#else
#include <inttypes.h>
+#include <assert.h>
#ifdef ARCH_X86
inline static unsigned short ByteSwap16(unsigned short x)
@@ -90,12 +91,6 @@ inline static unsigned long long int ByteSwap64(unsigned long long int x)
#define le2me_64(x) (x)
#endif
-#ifdef FPM_SPARC
-
-/*
- * Workaround for code generation bug in gcc on SPARC
- */
-
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
@@ -106,22 +101,42 @@ inline static unsigned long long int ByteSwap64(unsigned long long int x)
(((uint8_t*)(x))[2] << 16) | \
(((uint8_t*)(x))[1] << 8) | \
((uint8_t*)(x))[0])
+#ifdef DEBUG
+
+inline static void* check_ptr_alignment(void* ptr, int align)
+{
+ assert((int)ptr % align == 0);
+ return ptr;
+}
+
+#define ABE_16(x) (be2me_16(*(uint16_t*)check_ptr_alignment((x), 2)))
+#define ABE_32(x) (be2me_32(*(uint32_t*)check_ptr_alignment((x), 4)))
+#define ALE_16(x) (le2me_16(*(uint16_t*)check_ptr_alignment((x), 2)))
+#define ALE_32(x) (le2me_32(*(uint32_t*)check_ptr_alignment((x), 4)))
#else
-#define BE_16(x) (be2me_16(*(uint16_t*)(x)))
-#define BE_32(x) (be2me_32(*(uint32_t*)(x)))
-#define LE_16(x) (le2me_16(*(uint16_t*)(x)))
-#define LE_32(x) (le2me_32(*(uint32_t*)(x)))
+#define ABE_16(x) (be2me_16(*(uint16_t*)(x)))
+#define ABE_32(x) (be2me_32(*(uint32_t*)(x)))
+#define ALE_16(x) (le2me_16(*(uint16_t*)(x)))
+#define ALE_32(x) (le2me_32(*(uint32_t*)(x)))
-#endif /* !FPM_SPARC */
+#endif
#ifdef WORDS_BIGENDIAN
+
#define ME_16(x) BE_16(x)
#define ME_32(x) BE_32(x)
+#define AME_16(x) ABE_16(x)
+#define AME_32(x) ABE_32(x)
+
#else
+
#define ME_16(x) LE_16(x)
#define ME_32(x) LE_32(x)
+#define AME_16(x) ALE_16(x)
+#define AME_32(x) ALE_32(x)
+
#endif
#endif