[Mplayer-cvslog] CVS: main/loader win32.c,1.18,1.19

Jürgen Keil jkeil at mplayer.dev.hu
Thu Sep 20 11:12:56 CEST 2001


Update of /cvsroot/mplayer/main/loader
In directory mplayer:/var/tmp.root/cvs-serv5181

Modified Files:
	win32.c 
Log Message:
do_cpuid stored the results of the cpuid instruction in the wrong place
(overwriting stack memory)

To work around the buggy do_cpuid, localcount_stub was using a bogus test
to test for the availability of the TSC register.

Both problems fixed.


Index: win32.c
===================================================================
RCS file: /cvsroot/mplayer/main/loader/win32.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- win32.c	24 Aug 2001 16:12:28 -0000	1.18
+++ win32.c	20 Sep 2001 09:12:29 -0000	1.19
@@ -48,10 +48,8 @@
 
 char* def_path=WIN32_PATH;
 
-static void do_cpuid(unsigned int *regs)
+static void do_cpuid(unsigned int ax, unsigned int *regs)
 {
-  unsigned int ax;
-  ax=1;
     __asm__ __volatile__(
 	"pushl %%ebx; pushl %%ecx; pushl %%edx; "
         ".byte  0x0f, 0xa2;"
@@ -61,7 +59,7 @@
         "movl   %%edx, 12(%2);"
 	"popl %%edx; popl %%ecx; popl %%ebx; "
         : "=a" (ax)
-    :  "0" (ax), "S" (&regs));
+    :  "0" (ax), "S" (regs));
 }
 static unsigned int c_localcount_tsc()
 {
@@ -113,8 +111,8 @@
 static unsigned int localcount_stub(void)
 {
     unsigned int regs[4];
-    do_cpuid(regs);
-    if ((regs[3] & 0x00000010) == 0) 
+    do_cpuid(1, regs);
+    if ((regs[3] & 0x00000010) != 0) 
     {
 	localcount=c_localcount_tsc;
 	longcount=c_longcount_tsc;
@@ -129,8 +127,8 @@
 static void longcount_stub(long long* z)
 {
     unsigned int regs[4];
-    do_cpuid(regs);
-    if ((regs[3] & 0x00000010) == 0) 
+    do_cpuid(1, regs);
+    if ((regs[3] & 0x00000010) != 0) 
     {
 	localcount=c_localcount_tsc;
 	longcount=c_longcount_tsc;
@@ -705,7 +703,7 @@
 	cachedsi.wProcessorRevision		= 0x0101;
 	
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__svr4__)
-	do_cpuid(regs);
+	do_cpuid(1, regs);
 	switch ((regs[0] >> 8) & 0xf) {			// cpu family
 	case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
 		cachedsi.wProcessorLevel= 3;




More information about the MPlayer-cvslog mailing list