From 8f880269e0342d7f29e2073f8d558bc3c7314ce0 Mon Sep 17 00:00:00 2001 From: oparviai Date: Fri, 13 Feb 2009 16:22:48 +0000 Subject: [PATCH] Fix for x86-64 support: Removed pop/push instructions from the cpu detection algorithm. --- source/SoundTouch/cpu_detect_x86_gcc.cpp | 9 ++++----- source/SoundTouch/cpu_detect_x86_win.cpp | 9 ++++++--- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/SoundTouch/cpu_detect_x86_gcc.cpp b/source/SoundTouch/cpu_detect_x86_gcc.cpp index 2c797dc..77b816d 100644 --- a/source/SoundTouch/cpu_detect_x86_gcc.cpp +++ b/source/SoundTouch/cpu_detect_x86_gcc.cpp @@ -87,22 +87,21 @@ uint detectCPUextensions(void) // check if 'cpuid' instructions is available by toggling eflags bit 21 "\n\tpushf" // save eflags to stack - "\n\tpop %%eax" // load eax from stack (with eflags) + "\n\tmovl (%%esp), %%eax" // load eax from stack (with eflags) "\n\tmovl %%eax, %%ecx" // save the original eflags values to ecx "\n\txor $0x00200000, %%eax" // toggle bit 21 - "\n\tpush %%eax" // store toggled eflags to stack + "\n\tmovl %%eax, (%%esp)" // store toggled eflags to stack "\n\tpopf" // load eflags from stack "\n\tpushf" // save updated eflags to stack - "\n\tpop %%eax" // load from stack + "\n\tmovl (%%esp), %%eax" // load eax from stack + "\n\tpopf" // pop stack to restore esp "\n\txor %%edx, %%edx" // clear edx for defaulting no mmx "\n\tcmp %%ecx, %%eax" // compare to original eflags values "\n\tjz end" // jumps to 'end' if cpuid not present - // cpuid instruction available, test for presence of mmx instructions "\n\tmovl $1, %%eax" "\n\tcpuid" -// movl $0x00800000, %edx // force enable MMX "\n\ttest $0x00800000, %%edx" "\n\tjz end" // branch if MMX not available diff --git a/source/SoundTouch/cpu_detect_x86_win.cpp b/source/SoundTouch/cpu_detect_x86_win.cpp index be6895e..98ff022 100644 --- a/source/SoundTouch/cpu_detect_x86_win.cpp +++ b/source/SoundTouch/cpu_detect_x86_win.cpp @@ -78,13 +78,16 @@ uint detectCPUextensions(void) xor esi, esi ; clear esi = result register pushfd ; save eflags to stack - pop eax ; load eax from stack (with eflags) + mov eax,dword ptr [esp] ; load eax from stack (with eflags) mov ecx, eax ; save the original eflags values to ecx xor eax, 0x00200000 ; toggle bit 21 - push eax ; store toggled eflags to stack + mov dword ptr [esp],eax ; store toggled eflags to stack popfd ; load eflags from stack + pushfd ; save updated eflags to stack - pop eax ; load from stack + mov eax,dword ptr [esp] ; load eax from stack + popfd ; pop stack to restore stack pointer + xor edx, edx ; clear edx for defaulting no mmx cmp eax, ecx ; compare to original eflags values jz end ; jumps to 'end' if cpuid not present