From a822d736f0a7279dd961c02e20f0fd428637606e Mon Sep 17 00:00:00 2001 From: Martin Fleisz Date: Mon, 4 Mar 2013 09:40:26 +0100 Subject: [PATCH] Fixed issues with new sysinfo on windows --- client/Windows/wfreerdp.c | 41 ---------------------------- libfreerdp/primitives/CMakeLists.txt | 2 ++ winpr/libwinpr/sysinfo/sysinfo.c | 21 ++++++++++---- 3 files changed, 18 insertions(+), 46 deletions(-) diff --git a/client/Windows/wfreerdp.c b/client/Windows/wfreerdp.c index 1b0233b58..6e786ba55 100644 --- a/client/Windows/wfreerdp.c +++ b/client/Windows/wfreerdp.c @@ -306,44 +306,6 @@ BOOL wf_pre_connect(freerdp* instance) return TRUE; } -void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx) -{ -#if defined(__GNUC__) -#if defined(__i386__) || defined(__x86_64__) - *eax = info; - __asm volatile - ("mov %%ebx, %%edi;" /* 32bit PIC: don't clobber ebx */ - "cpuid;" - "mov %%ebx, %%esi;" - "mov %%edi, %%ebx;" - :"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) - : :"edi"); -#endif -#elif defined(_MSC_VER) - int a[4]; - __cpuid(a, info); - *eax = a[0]; - *ebx = a[1]; - *ecx = a[2]; - *edx = a[3]; -#endif -} - -UINT32 wfi_detect_cpu() -{ - UINT32 cpu_opt = 0; - unsigned int eax, ebx, ecx, edx = 0; - - cpuid(1, &eax, &ebx, &ecx, &edx); - - if (edx & (1<<26)) - { - cpu_opt |= CPU_SSE2; - } - - return cpu_opt; -} - BOOL wf_post_connect(freerdp* instance) { rdpGdi* gdi; @@ -368,8 +330,6 @@ BOOL wf_post_connect(freerdp* instance) gdi = instance->context->gdi; wfi->hdc = gdi->primary->hdc; wfi->primary = wf_image_new(wfi, wfi->width, wfi->height, wfi->dstBpp, gdi->primary_buffer); - - rfx_context_set_cpu_opt((RFX_CONTEXT*) gdi->rfx_context, wfi_detect_cpu()); } else { @@ -396,7 +356,6 @@ BOOL wf_post_connect(freerdp* instance) { wfi->tile = wf_image_new(wfi, 64, 64, 32, NULL); wfi->rfx_context = rfx_context_new(); - rfx_context_set_cpu_opt(wfi->rfx_context, wfi_detect_cpu()); } if (settings->NSCodec) diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index 780ae94e1..656b6873c 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -82,6 +82,8 @@ if(IPP_FOUND) endforeach() endif() +set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-sysinfo) + if(MONOLITHIC_BUILD) set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE) else() diff --git a/winpr/libwinpr/sysinfo/sysinfo.c b/winpr/libwinpr/sysinfo/sysinfo.c index 6e561ddff..afd10ebe6 100644 --- a/winpr/libwinpr/sysinfo/sysinfo.c +++ b/winpr/libwinpr/sysinfo/sysinfo.c @@ -338,12 +338,12 @@ DWORD GetTickCount(void) return ticks; } +#endif // _WIN32 -/* If x86 and gcc*/ +/* If x86 */ #ifdef _M_IX86_AMD64 -#ifdef __GNUC__ -#ifdef __AVX__ +#if defined(__GNUC__) && defined(__AVX__) #define xgetbv(_func_, _lo_, _hi_) \ __asm__ __volatile__ ("xgetbv" : "=a" (_lo_), "=d" (_hi_) : "c" (_func_)) #endif @@ -373,6 +373,7 @@ static void cpuid( unsigned *ecx, unsigned *edx) { +#ifdef __GNUC__ *eax = *ebx = *ecx = *edx = 0; __asm volatile @@ -392,8 +393,16 @@ static void cpuid( : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx) : "0" (info) ); + +#elif defined(_MSC_VER) + int a[4]; + __cpuid(a, info); + *eax = a[0]; + *ebx = a[1]; + *ecx = a[2]; + *edx = a[3]; +#endif } -#endif // __GNUC__ #elif defined(_M_ARM) #if defined(__linux__) // HWCAP flags from linux kernel - uapi/asm/hwcap.h @@ -453,6 +462,8 @@ static unsigned GetARMCPUCaps(void){ #endif // defined(__linux__) #endif // _M_IX86_AMD64 +#ifndef _WIN32 + BOOL IsProcessorFeaturePresent(DWORD ProcessorFeature) { BOOL ret = FALSE; @@ -609,7 +620,7 @@ BOOL IsProcessorFeaturePresentEx(DWORD ProcessorFeature) if (c & C_BIT_SSE42) ret = TRUE; break; -#ifdef __AVX__ +#if defined(__GNUC__) && defined(__AVX__) case PF_EX_AVX: case PF_EX_FMA: case PF_EX_AVX_AES: