Mercurial > mplayer.hg
changeset 1923:40084ad62591
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.
author | jkeil |
---|---|
date | Thu, 20 Sep 2001 09:12:29 +0000 |
parents | 5f0e4310dd4d |
children | 6185fef2703a |
files | loader/win32.c |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/loader/win32.c Wed Sep 19 20:40:20 2001 +0000 +++ b/loader/win32.c Thu Sep 20 09:12:29 2001 +0000 @@ -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" (®s)); + : "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;