made the mm_pause instruction only available for intel32 and amd64 architectures. closes #1882

This commit is contained in:
oy 2019-01-02 23:00:06 +01:00
parent b6c2e2fd73
commit 87fa77441a
3 changed files with 19 additions and 2 deletions

View file

@ -44,6 +44,10 @@
#error NOT IMPLEMENTED #error NOT IMPLEMENTED
#endif #endif
#if defined(CONF_ARCH_IA32) || defined(CONF_ARCH_AMD64)
#include <immintrin.h> //_mm_pause
#endif
#if defined(CONF_PLATFORM_SOLARIS) #if defined(CONF_PLATFORM_SOLARIS)
#include <sys/filio.h> #include <sys/filio.h>
#endif #endif
@ -504,6 +508,14 @@ void thread_detach(void *thread)
#endif #endif
} }
void cpu_relax()
{
#if defined(CONF_ARCH_IA32) || defined(CONF_ARCH_AMD64)
_mm_pause();
#else
(void) 0;
#endif
}

View file

@ -405,6 +405,12 @@ void thread_yield();
*/ */
void thread_detach(void *thread); void thread_detach(void *thread);
/*
Function: cpu_relax
Lets the cpu relax a bit.
*/
void cpu_relax();
/* Group: Locks */ /* Group: Locks */
typedef void* LOCK; typedef void* LOCK;

View file

@ -2,7 +2,6 @@
/* If you are missing that file, acquire a complete release at teeworlds.com. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <new> #include <new>
#include <immintrin.h> //_mm_pause
#include <stdlib.h> // qsort #include <stdlib.h> // qsort
#include <stdarg.h> #include <stdarg.h>
@ -1776,7 +1775,7 @@ bool CClient::LimitFps()
Now = time_get(); Now = time_get();
RenderDeltaTime = (Now - LastT) / Freq; RenderDeltaTime = (Now - LastT) / Freq;
d = DesiredTime - RenderDeltaTime; d = DesiredTime - RenderDeltaTime;
_mm_pause(); cpu_relax();
} }
SkipFrame = false; SkipFrame = false;