From 797d81af4ae036e42619700fe194d8f607fed698 Mon Sep 17 00:00:00 2001 From: sezero Date: Fri, 10 Aug 2018 20:38:57 +0300 Subject: [PATCH] h3, fxglide.h, gthread.c: copy over gcc compatibility changes from h5. --- glide3x/h3/glide3/src/fxglide.h | 20 ++++++++++++++------ glide3x/h3/glide3/src/gthread.c | 14 +++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/glide3x/h3/glide3/src/fxglide.h b/glide3x/h3/glide3/src/fxglide.h index 38820fd..1ce9abb 100644 --- a/glide3x/h3/glide3/src/fxglide.h +++ b/glide3x/h3/glide3/src/fxglide.h @@ -1891,13 +1891,21 @@ _grSstVRetraceOn(void); #define WNT_TEB_TLS_OFFSET 0xE10 #define WNT_TLS_INDEX_TO_OFFSET(i) ((i)*sizeof(DWORD)+WNT_TEB_TLS_OFFSET) -#define __GR_GET_TLSC_VALUE() \ -__asm { \ - __asm mov eax, DWORD PTR fs:[WNT_TEB_PTR] \ - __asm add eax, DWORD PTR _GlideRoot.tlsOffset \ - __asm mov eax, DWORD PTR [eax] \ +#ifdef __GNUC__ + +extern __inline FxU32 getThreadValueFast (void) +{ + FxU32 t; + __asm __volatile (" \ + mov %%fs:(%0), %%eax; \ + add %1, %%eax; \ + mov (%%eax), %%eax; \ + ":"=a"(t):"i"(WNT_TEB_PTR), "g"(_GlideRoot.tlsOffset)); + return t; } +#else /* __GNUC__ */ + #pragma warning (4:4035) /* No return value */ __inline FxU32 getThreadValueFast() { @@ -1907,7 +1915,7 @@ getThreadValueFast() { __asm mov eax, DWORD PTR [eax] } } -#pragma warning (3:4035) +#endif /* __GNUC__ */ #endif #if (GLIDE_PLATFORM & GLIDE_OS_MACOS) diff --git a/glide3x/h3/glide3/src/gthread.c b/glide3x/h3/glide3/src/gthread.c index 1be373f..382b6e0 100644 --- a/glide3x/h3/glide3/src/gthread.c +++ b/glide3x/h3/glide3/src/gthread.c @@ -63,19 +63,11 @@ void setThreadValue( unsigned long value ) { TlsSetValue( _GlideRoot.tlsIndex, (void*)value ); } -#pragma warning (4:4035) /* No return value */ -unsigned long getThreadValueSLOW( void ) { +unsigned long getThreadValueSLOW( void ) +{ GR_CHECK_F( "getThreadValue", !threadInit, "Thread storage not initialized\n" ); -#if 0 - return (FxU32)TlsGetValue( _GlideRoot.tlsIndex ); -#elif 1 - __GR_GET_TLSC_VALUE(); -#else - __asm { - __asm mov esi, DWORD PTR fs:[WNT_TEB_PTR] - __asm add esi, DWORD PTR _GlideRoot.tlsOffset \ - __asm mov eax, DWORD PTR [esi] \ + return getThreadValueFast(); } #endif