summaryrefslogtreecommitdiff
path: root/libavutil/x86/bswap.h
diff options
context:
space:
mode:
authorMans Rullgard <mans@mansr.com>2011-12-12 00:50:08 +0000
committerMans Rullgard <mans@mansr.com>2011-12-12 12:14:14 +0000
commitf64c2e710fa1a7b59753224e717f57c48462076f (patch)
tree760f8b52024f89e22778498c4f00ceac03f3f01e /libavutil/x86/bswap.h
parent5695ae46f8771f5c63cb0f62faca6a3d27f7d921 (diff)
bswap: make generic implementation more compiler-friendly
With these changes, gcc 4.5 and later recognise it as a bswap and use the proper instructions on ARM and x86. On x86, the 16-bit bswap is recognised from gcc 4.1. Signed-off-by: Mans Rullgard <mans@mansr.com>
Diffstat (limited to 'libavutil/x86/bswap.h')
-rw-r--r--libavutil/x86/bswap.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/libavutil/x86/bswap.h b/libavutil/x86/bswap.h
index b60d9ccd6c..6840b632cb 100644
--- a/libavutil/x86/bswap.h
+++ b/libavutil/x86/bswap.h
@@ -28,13 +28,16 @@
#include "config.h"
#include "libavutil/attributes.h"
+#if !AV_GCC_VERSION_AT_LEAST(4,1)
#define av_bswap16 av_bswap16
static av_always_inline av_const unsigned av_bswap16(unsigned x)
{
__asm__("rorw $8, %w0" : "+r"(x));
return x;
}
+#endif /* !AV_GCC_VERSION_AT_LEAST(4,1) */
+#if !AV_GCC_VERSION_AT_LEAST(4,5)
#define av_bswap32 av_bswap32
static av_always_inline av_const uint32_t av_bswap32(uint32_t x)
{
@@ -57,5 +60,6 @@ static inline uint64_t av_const av_bswap64(uint64_t x)
return x;
}
#endif
+#endif /* !AV_GCC_VERSION_AT_LEAST(4,5) */
#endif /* AVUTIL_X86_BSWAP_H */