diff --git a/src/base/system.c b/src/base/system.c index 098e48c3d..b9b334809 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -44,6 +44,10 @@ #error NOT IMPLEMENTED #endif +#if defined(CONF_ARCH_IA32) || defined(CONF_ARCH_AMD64) + #include //_mm_pause +#endif + #if defined(CONF_PLATFORM_SOLARIS) #include #endif @@ -504,6 +508,14 @@ void thread_detach(void *thread) #endif } +void cpu_relax() +{ +#if defined(CONF_ARCH_IA32) || defined(CONF_ARCH_AMD64) + _mm_pause(); +#else + (void) 0; +#endif +} diff --git a/src/base/system.h b/src/base/system.h index b2a74b024..32ec8e710 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -405,6 +405,12 @@ void thread_yield(); */ void thread_detach(void *thread); +/* + Function: cpu_relax + Lets the cpu relax a bit. +*/ +void cpu_relax(); + /* Group: Locks */ typedef void* LOCK; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index b01ec3600..ce653af0a 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -2,7 +2,6 @@ /* If you are missing that file, acquire a complete release at teeworlds.com. */ #include -#include //_mm_pause #include // qsort #include @@ -1776,7 +1775,7 @@ bool CClient::LimitFps() Now = time_get(); RenderDeltaTime = (Now - LastT) / Freq; d = DesiredTime - RenderDeltaTime; - _mm_pause(); + cpu_relax(); } SkipFrame = false;