Merge pull request #1026 from mfleisz/sysinfofix

Fixed sysinfo issues with Win32 builds
This commit is contained in:
Vic Lee 2013-03-04 06:01:54 -08:00
commit ef16cee209
3 changed files with 21 additions and 46 deletions

View File

@ -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)

View File

@ -82,6 +82,11 @@ if(IPP_FOUND)
endforeach()
endif()
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
MONOLITHIC ${MONOLITHIC_BUILD}
MODULE winpr
MODULES winpr-sysinfo)
if(MONOLITHIC_BUILD)
set(FREERDP_LIBS ${FREERDP_LIBS} ${${MODULE_PREFIX}_LIBS} PARENT_SCOPE)
else()

View File

@ -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: