summaryrefslogtreecommitdiff
path: root/src/xine-utils/cpu_accel.c
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-11-18 00:05:06 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-11-18 00:05:06 +0000
commit803c6427205dd92bf1df072c49e26f7c700a2423 (patch)
tree0447962e6f8e33f28788fd0f991ee38a373f54c7 /src/xine-utils/cpu_accel.c
parent9ee92c975ddef88214ce317d9a25ff37d080aeed (diff)
downloadxine-lib-803c6427205dd92bf1df072c49e26f7c700a2423.tar.gz
xine-lib-803c6427205dd92bf1df072c49e26f7c700a2423.tar.bz2
update to latest mpeg2dec x86_accel sources, hopefully this solves conftest segfault
CVS patchset: 1062 CVS date: 2001/11/18 00:05:06
Diffstat (limited to 'src/xine-utils/cpu_accel.c')
-rw-r--r--src/xine-utils/cpu_accel.c159
1 files changed, 80 insertions, 79 deletions
diff --git a/src/xine-utils/cpu_accel.c b/src/xine-utils/cpu_accel.c
index b463b3140..838366c77 100644
--- a/src/xine-utils/cpu_accel.c
+++ b/src/xine-utils/cpu_accel.c
@@ -18,7 +18,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#define XINEUTILS_COMPILE
#include "config.h"
@@ -30,98 +29,100 @@
#ifdef ARCH_X86
static uint32_t x86_accel (void)
{
- uint32_t eax, ebx, ecx, edx;
- int AMD;
- uint32_t caps;
-
-#define cpuid(op,eax,ebx,ecx,edx) \
- asm ("cpuid" \
- : "=a" (eax), \
- "=b" (ebx), \
- "=c" (ecx), \
- "=d" (edx) \
- : "a" (op) \
- : "cc")
-
-
- asm ("pushfl\n\t"
- "pushfl\n\t"
- "popl %0\n\t"
- "movl %0,%1\n\t"
- "xorl $0x200000,%0\n\t"
- "pushl %0\n\t"
- "popfl\n\t"
- "pushfl\n\t"
- "popl %0\n\t"
- "popfl"
- : "=a" (eax),
- "=b" (ebx)
- :
- : "cc");
-
- if (eax == ebx) /* no cpuid */
- return 0;
-
- cpuid (0x00000000, eax, ebx, ecx, edx);
- if (!eax) /* vendor string only */
- return 0;
-
- AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
-
- cpuid (0x00000001, eax, ebx, ecx, edx);
- if (! (edx & 0x00800000)) /* no MMX */
- return 0;
- caps = MM_ACCEL_X86_MMX;
-
- if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
- caps |= MM_ACCEL_X86_SSE | MM_ACCEL_X86_MMXEXT;
-
- if (edx & 0x04000000) /* SSE2 */
- caps |= MM_ACCEL_X86_SSE2;
-
- cpuid (0x80000000, eax, ebx, ecx, edx);
- if (eax < 0x80000001) /* no extended capabilities */
- return caps;
-
- cpuid (0x80000001, eax, ebx, ecx, edx);
-
- if (edx & 0x80000000) /* 3DNOW */
- caps |= MM_ACCEL_X86_3DNOW;
-
- if (edx & 0x40000000) /* 3DNOWEXT */
- /*caps |= MM_ACCEL_X86_???*/ ;
-
- if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
- caps |= MM_ACCEL_X86_MMXEXT;
+ uint32_t eax, ebx, ecx, edx;
+ int AMD;
+ uint32_t caps;
+
+#ifndef PIC
+#define cpuid(op,eax,ebx,ecx,edx) \
+ asm ("cpuid" \
+ : "=a" (eax), \
+ "=b" (ebx), \
+ "=c" (ecx), \
+ "=d" (edx) \
+ : "a" (op) \
+ : "cc")
+#else // PIC version : save ebx
+#define cpuid(op,eax,ebx,ecx,edx) \
+ asm ("pushl %%ebx\n\t" \
+ "cpuid\n\t" \
+ "movl %%ebx,%1\n\t" \
+ "popl %%ebx" \
+ : "=a" (eax), \
+ "=r" (ebx), \
+ "=c" (ecx), \
+ "=d" (edx) \
+ : "a" (op) \
+ : "cc")
+#endif
+
+ asm ("pushfl\n\t"
+ "pushfl\n\t"
+ "popl %0\n\t"
+ "movl %0,%1\n\t"
+ "xorl $0x200000,%0\n\t"
+ "pushl %0\n\t"
+ "popfl\n\t"
+ "pushfl\n\t"
+ "popl %0\n\t"
+ "popfl"
+ : "=r" (eax),
+ "=r" (ebx)
+ :
+ : "cc");
+
+ if (eax == ebx) /* no cpuid */
+ return 0;
+
+ cpuid (0x00000000, eax, ebx, ecx, edx);
+ if (!eax) /* vendor string only */
+ return 0;
+
+ AMD = (ebx == 0x68747541) && (ecx == 0x444d4163) && (edx == 0x69746e65);
+
+ cpuid (0x00000001, eax, ebx, ecx, edx);
+ if (! (edx & 0x00800000)) /* no MMX */
+ return 0;
+
+ caps = MM_ACCEL_X86_MMX;
+ if (edx & 0x02000000) /* SSE - identical to AMD MMX extensions */
+ caps = MM_ACCEL_X86_MMX | MM_ACCEL_X86_MMXEXT;
+ cpuid (0x80000000, eax, ebx, ecx, edx);
+ if (eax < 0x80000001) /* no extended capabilities */
return caps;
+
+ cpuid (0x80000001, eax, ebx, ecx, edx);
+
+ if (edx & 0x80000000)
+ caps |= MM_ACCEL_X86_3DNOW;
+
+ if (AMD && (edx & 0x00400000)) /* AMD MMX extensions */
+ caps |= MM_ACCEL_X86_MMXEXT;
+
+ return caps;
}
#endif
+
uint32_t xine_mm_accel (void)
{
#ifdef ARCH_X86
- static int got_accel = 0;
- static uint32_t accel;
+ static int got_accel = 0;
+ static uint32_t accel;
- if (!got_accel) {
- got_accel = 1;
- accel = x86_accel ();
- }
+ if (!got_accel) {
+ got_accel = 1;
+ accel = x86_accel ();
+ }
- return accel;
+ return accel;
#else
#ifdef HAVE_MLIB
- return MM_ACCEL_MLIB;
+ return MM_ACCEL_MLIB;
#else
- return 0;
+ return 0;
#endif
#endif
}
-/*
-uint32_t xine_mm_support (void)
-{
- return xine_mm_accel();
-}
-*/