Suppressing external gas stuff to improve portability to Win32
authorNick Kurshev <nickols_k@mail.ru>
Sun, 5 Aug 2001 16:49:57 +0000 (16:49 +0000)
committerNick Kurshev <nickols_k@mail.ru>
Sun, 5 Aug 2001 16:49:57 +0000 (16:49 +0000)
Originally committed as revision 33 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/Makefile
libavcodec/i386/cpuid.s [deleted file]
libavcodec/i386/cputest.c

index de9376bb0d9c988fdf49b3f4b3e5b835a74b4afc..251c3e6b99d6c7980802c93be058984bec687e1e 100644 (file)
@@ -25,7 +25,7 @@ endif
 
 # i386 mmx specific stuff
 ifeq ($(TARGET_MMX),yes)
-ASM_OBJS += i386/fdct_mmx.o i386/sad_mmx.o i386/cpuid.o
+ASM_OBJS += i386/fdct_mmx.o i386/sad_mmx.o
 OBJS += i386/fdctdata.o i386/cputest.o \
        i386/dsputil_mmx.o i386/mpegvideo_mmx.o
 endif
@@ -47,9 +47,6 @@ dsputil.o: dsputil.c dsputil.h
 %.o: %.c
        $(CC) $(CFLAGS) -c -o $@ $< 
 
-i386/cpuid.o: i386/cpuid.s
-       $(CC) -c -o $@ $< 
-
 %.o: %.s
        nasm -f elf -o $@ $<
 
diff --git a/libavcodec/i386/cpuid.s b/libavcodec/i386/cpuid.s
deleted file mode 100644 (file)
index c25367e..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-       .file   "cpuid.s"
-       .version        "01.01"
-gcc2_compiled.:
-.text
-       .align 4
-        .globl   cpuid
-       .type    cpuid,@function
-cpuid:
-       pushl %ebp
-       movl %esp,%ebp
-       pushl %edi
-       pushl %esi
-       pushl %ebx
-       movl 8(%ebp),%eax
-       movl 12(%ebp),%edi
-       movl 24(%ebp),%esi
-       cpuid
-       movl %eax,(%edi)
-       movl 16(%ebp),%eax
-       movl %ebx,(%eax)
-       movl 20(%ebp),%eax
-       movl %ecx,(%eax)
-       movl %edx,(%esi)
-       popl %ebx
-       popl %esi
-       popl %edi
-       leave
-       ret
-.Lfe1:
-       .size    cpuid,.Lfe1-cpuid
-       .align 4
index 3de21a708bda17242da580e6715dacff0f3c8484..4847bac15d3db6aae7ba54ec5dc723c6660b66cb 100644 (file)
@@ -4,8 +4,15 @@
 #include <stdlib.h>
 #include "../dsputil.h"
 
-/* need this external function to solve -fPIC ebx issues ! */
-extern void cpuid(int index, int *eax, int *ebx, int *ecx, int *edx);
+/* ebx saving is necessary for PIC. gcc seems unable to see it alone */
+#define cpuid(index,eax,ebx,ecx,edx)\
+    asm ("movl %%ebx, %%esi\n\t"\
+         "cpuid\n\t"\
+         "xchgl %%ebx, %%esi"\
+         : "=a" (eax), "=S" (ebx),\
+           "=c" (ecx), "=d" (edx)\
+         : "0" (index)\
+         : "cc")\
 
 /* Function to test if multimedia instructions are supported...  */
 int mm_support(void)
@@ -37,7 +44,7 @@ int mm_support(void)
     if (eax == ecx)
         return 0; /* CPUID not supported */
     
-    cpuid(0, &eax, &ebx, &ecx, &edx);
+    cpuid(0, eax, ebx, ecx, edx);
 
     if (ebx == 0x756e6547 &&
         edx == 0x49656e69 &&
@@ -45,7 +52,7 @@ int mm_support(void)
         
         /* intel */
     inteltest:
-        cpuid(1, &eax, &ebx, &ecx, &edx);
+        cpuid(1, eax, ebx, ecx, edx);
         if ((edx & 0x00800000) == 0)
             return 0;
         rval = MM_MMX;
@@ -58,10 +65,10 @@ int mm_support(void)
                edx == 0x69746e65 &&
                ecx == 0x444d4163) {
         /* AMD */
-        cpuid(0x80000000, &eax, &ebx, &ecx, &edx);
+        cpuid(0x80000000, eax, ebx, ecx, edx);
         if ((unsigned)eax < 0x80000001)
             goto inteltest;
-        cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
+        cpuid(0x80000001, eax, ebx, ecx, edx);
         if ((edx & 0x00800000) == 0)
             return 0;
         rval = MM_MMX;
@@ -84,7 +91,7 @@ int mm_support(void)
         */
         if (eax != 2) 
             goto inteltest;
-        cpuid(0x80000001, &eax, &ebx, &ecx, &edx);
+        cpuid(0x80000001, eax, ebx, ecx, edx);
         if ((eax & 0x00800000) == 0)
             return 0;
         rval = MM_MMX;