[1/2] mathops: convert MULL/MULH/MUL64 to inline functions rather than macros.

Message ID 1300210649-6744-1-git-send-email-justin.ruggles@gmail.com
State Committed
Headers show

Commit Message

Justin Ruggles March 15, 2011, 5:37 p.m.
This fixes unexpected name collisions that were occurring with variables
declared within the macros.
It also fixes the fate-acodec-ac3_fixed regression test on x86-32.
---
 libavcodec/x86/mathops.h |   57 +++++++++++++++++++++++++++++++--------------
 1 files changed, 39 insertions(+), 18 deletions(-)

Comments

Mans Rullgard March 15, 2011, 5:40 p.m. | #1
Justin Ruggles <justin.ruggles@gmail.com> writes:

> This fixes unexpected name collisions that were occurring with variables
> declared within the macros.
> It also fixes the fate-acodec-ac3_fixed regression test on x86-32.
> ---
>  libavcodec/x86/mathops.h |   57 +++++++++++++++++++++++++++++++--------------
>  1 files changed, 39 insertions(+), 18 deletions(-)

Seems OK.

Patch

diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
index 5949dfe..4e54886 100644
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -26,24 +26,45 @@ 
 #include "libavutil/common.h"
 
 #if ARCH_X86_32
-#define MULL(ra, rb, shift) \
-        ({ int rt, dummy; __asm__ (\
-            "imull %3               \n\t"\
-            "shrdl %4, %%edx, %%eax \n\t"\
-            : "=a"(rt), "=d"(dummy)\
-            : "a" ((int)(ra)), "rm" ((int)(rb)), "i"(shift));\
-         rt; })
 
-#define MULH(ra, rb) \
-    ({ int rt, dummy;\
-     __asm__ ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" ((int)(ra)), "rm" ((int)(rb)));\
-     rt; })
+#define MULL MULL
+static av_always_inline av_const int MULL(int a, int b, unsigned shift)
+{
+    int rt, dummy;
+    __asm__ (
+        "imull %3               \n\t"
+        "shrdl %4, %%edx, %%eax \n\t"
+        :"=a"(rt), "=d"(dummy)
+        :"a"(a), "rm"(b), "i"(shift)
+    );
+    return rt;
+}
 
-#define MUL64(ra, rb) \
-    ({ int64_t rt;\
-     __asm__ ("imull %2\n\t" : "=A"(rt) : "a" ((int)(ra)), "g" ((int)(rb)));\
-     rt; })
-#endif
+#define MULH MULH
+static av_always_inline av_const int MULH(int a, int b)
+{
+    int rt, dummy;
+    __asm__ (
+        "imull %3"
+        :"=d"(rt), "=a"(dummy)
+        :"a"(a), "rm"(b)
+    );
+    return rt;
+}
+
+#define MUL64 MUL64
+static av_always_inline av_const int64_t MUL64(int a, int b)
+{
+    int64_t rt;
+    __asm__ (
+        "imull %2"
+        :"=A"(rt)
+        :"a"(a), "g"(b)
+    );
+    return rt;
+}
+
+#endif /* ARCH_X86_32 */
 
 #if HAVE_CMOV
 /* median of 3 */