glide3x, h3/h5: changed threadValue stuff from FxU32 to unsigned long.

This commit is contained in:
sezero
2018-08-21 04:11:28 +03:00
parent d04deb23d6
commit 85ec47f22b
4 changed files with 46 additions and 81 deletions

View File

@@ -1413,7 +1413,7 @@ struct _GlideRoot_s {
#if defined(__WATCOMC__) || defined(__MSC__) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) #if defined(__WATCOMC__) || defined(__MSC__) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
int p6Fencer; /* xchg to here to keep this in cache!!! */ int p6Fencer; /* xchg to here to keep this in cache!!! */
#endif #endif
FxU32 unsigned long
tlsIndex, tlsIndex,
tlsOffset; tlsOffset;
@@ -1884,9 +1884,9 @@ _grSstVRetraceOn(void);
#ifdef __GNUC__ #ifdef __GNUC__
extern __inline FxU32 getThreadValueFast (void) extern __inline unsigned long getThreadValueFast (void)
{ {
FxU32 t; unsigned long t;
__asm __volatile (" \ __asm __volatile (" \
mov %%fs:(%0), %%eax; \ mov %%fs:(%0), %%eax; \
add %1, %%eax; \ add %1, %%eax; \
@@ -1898,7 +1898,7 @@ extern __inline FxU32 getThreadValueFast (void)
#else /* __GNUC__ */ #else /* __GNUC__ */
#pragma warning (4:4035) /* No return value */ #pragma warning (4:4035) /* No return value */
__inline FxU32 __inline unsigned long
getThreadValueFast() { getThreadValueFast() {
__asm { __asm {
__asm mov eax, DWORD PTR fs:[WNT_TEB_PTR] __asm mov eax, DWORD PTR fs:[WNT_TEB_PTR]
@@ -1910,8 +1910,8 @@ getThreadValueFast() {
#endif #endif
#if (GLIDE_PLATFORM & GLIDE_OS_MACOS) #if (GLIDE_PLATFORM & GLIDE_OS_MACOS)
extern FxU32 _threadValueMacOS; extern unsigned long _threadValueMacOS;
__inline FxU32 __inline unsigned long
getThreadValueFast() { getThreadValueFast() {
return _threadValueMacOS; return _threadValueMacOS;
} }
@@ -1923,7 +1923,7 @@ extern unsigned long threadValueLinux;
#endif #endif
#if (GLIDE_PLATFORM & GLIDE_OS_DOS32) #if (GLIDE_PLATFORM & GLIDE_OS_DOS32)
extern FxU32 GR_CDECL threadValueDJGPP; extern unsigned long GR_CDECL threadValueDJGPP;
#define getThreadValueFast() threadValueDJGPP #define getThreadValueFast() threadValueDJGPP
#endif #endif

View File

@@ -25,8 +25,6 @@
#include <3dfx.h> #include <3dfx.h>
#include <glidesys.h> #include <glidesys.h>
#if defined( __WIN32__ )
#define FX_DLL_DEFINITION #define FX_DLL_DEFINITION
#include <fxdll.h> #include <fxdll.h>
#include <glide.h> #include <glide.h>
@@ -34,6 +32,8 @@
#include "fxglide.h" #include "fxglide.h"
#include "fxcmd.h" #include "fxcmd.h"
#if defined( __WIN32__ )
#if (GLIDE_PLATFORM & GLIDE_OS_WIN32) #if (GLIDE_PLATFORM & GLIDE_OS_WIN32)
#include <windows.h> #include <windows.h>
#endif #endif
@@ -44,8 +44,8 @@ static DWORD tlsIndex;
static FxBool threadInit; static FxBool threadInit;
static FxBool criticalSectionInit; static FxBool criticalSectionInit;
void void
initThreadStorage( void ) initThreadStorage( void )
{ {
if ( !threadInit ) { if ( !threadInit ) {
threadInit = 1; threadInit = 1;
@@ -89,17 +89,7 @@ void endCriticalSection( void ) {
#elif defined(macintosh) #elif defined(macintosh)
#include <3dfx.h> unsigned long _threadValueMacOS;
#include <glidesys.h>
#define FX_DLL_DEFINITION
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include "fxcmd.h"
FxU32 _threadValueMacOS;
void initThreadStorage(void) void initThreadStorage(void)
{ {
@@ -110,11 +100,11 @@ void setThreadValue( unsigned long value )
_threadValueMacOS = value; _threadValueMacOS = value;
} }
FxU32 getThreadValueSLOW( void ) unsigned long getThreadValueSLOW( void )
{ {
return _threadValueMacOS; return _threadValueMacOS;
} }
void initCriticalSection(void) void initCriticalSection(void)
{ {
} }
@@ -129,17 +119,6 @@ void endCriticalSection(void)
#elif defined(__linux__) || defined(__FreeBSD__) #elif defined(__linux__) || defined(__FreeBSD__)
#include <3dfx.h>
#include <glidesys.h>
#define FX_DLL_DEFINITION
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include "fxcmd.h"
unsigned long threadValueLinux; unsigned long threadValueLinux;
void initThreadStorage(void) void initThreadStorage(void)
@@ -155,7 +134,7 @@ unsigned long getThreadValueSLOW( void )
{ {
return threadValueLinux; return threadValueLinux;
} }
void initCriticalSection(void) void initCriticalSection(void)
{ {
} }
@@ -170,33 +149,22 @@ void endCriticalSection(void)
#elif (GLIDE_PLATFORM & GLIDE_OS_DOS32) #elif (GLIDE_PLATFORM & GLIDE_OS_DOS32)
unsigned long GR_CDECL threadValueDJGPP;
#include <3dfx.h>
#include <glidesys.h>
#define FX_DLL_DEFINITION
#include <fxdll.h>
#include <glide.h>
#include "fxglide.h"
#include "fxcmd.h"
FxU32 GR_CDECL threadValueDJGPP;
void initThreadStorage(void) void initThreadStorage(void)
{ {
} }
void setThreadValue( FxU32 value ) void setThreadValue( unsigned long value )
{ {
threadValueDJGPP = value; threadValueDJGPP = value;
} }
FxU32 getThreadValueSLOW( void ) unsigned long getThreadValueSLOW( void )
{ {
return threadValueDJGPP; return threadValueDJGPP;
} }
void initCriticalSection(void) void initCriticalSection(void)
{ {
} }

View File

@@ -2013,8 +2013,8 @@ struct _GlideRoot_s {
#if defined(__WATCOMC__) || defined(__MSC__) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) #if defined(__WATCOMC__) || defined(__MSC__) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
int p6Fencer; /* xchg to here to keep this in cache!!! */ int p6Fencer; /* xchg to here to keep this in cache!!! */
#endif #endif
FxU32 tlsIndex; unsigned long tlsIndex;
FxU32 tlsOffset; unsigned long tlsOffset;
int current_sst; int current_sst;
FxI32 windowsInit[MAX_NUM_SST]; /* Is the fullscreen part of glide initialized? */ FxI32 windowsInit[MAX_NUM_SST]; /* Is the fullscreen part of glide initialized? */
@@ -2735,14 +2735,14 @@ _grSstVRetraceOn(void);
#ifdef __GNUC__ #ifdef __GNUC__
extern extern
#endif #endif
__inline FxU32 __inline unsigned long
getThreadValueFast() { getThreadValueFast() {
/* According to Microsoft, TlsGetValue is implemented with speed as the /* According to Microsoft, TlsGetValue is implemented with speed as the
* primary goal. The function performs minimal parameter validation and * primary goal. The function performs minimal parameter validation and
* error checking. This function succeeds only when the TLS index is in * error checking. This function succeeds only when the TLS index is in
* the range 0 through (TLS_MINIMUM_AVAILABLE - 1). * the range 0 through (TLS_MINIMUM_AVAILABLE - 1).
*/ */
return (FxU32)TlsGetValue(_GlideRoot.tlsIndex); return (unsigned long)TlsGetValue(_GlideRoot.tlsIndex);
} }
#else #else
@@ -2757,9 +2757,9 @@ getThreadValueFast() {
#ifdef __GNUC__ #ifdef __GNUC__
extern __inline FxU32 getThreadValueFast (void) extern __inline unsigned long getThreadValueFast (void)
{ {
FxU32 t; unsigned long t;
__asm __volatile (" \ __asm __volatile (" \
mov %%fs:(%0), %%eax; \ mov %%fs:(%0), %%eax; \
add %1, %%eax; \ add %1, %%eax; \
@@ -2771,7 +2771,7 @@ extern __inline FxU32 getThreadValueFast (void)
#else /* __GNUC__ */ #else /* __GNUC__ */
#pragma warning (4:4035) /* No return value */ #pragma warning (4:4035) /* No return value */
__inline FxU32 __inline unsigned long
getThreadValueFast() { getThreadValueFast() {
__asm { __asm {
__asm mov eax, DWORD PTR fs:[WNT_TEB_PTR] __asm mov eax, DWORD PTR fs:[WNT_TEB_PTR]
@@ -2786,7 +2786,7 @@ getThreadValueFast() {
#endif #endif
#if (GLIDE_PLATFORM & GLIDE_OS_MACOS) #if (GLIDE_PLATFORM & GLIDE_OS_MACOS)
extern FxU32 _threadValueMacOS; extern unsigned long _threadValueMacOS;
__inline FxU32 __inline FxU32
getThreadValueFast() { getThreadValueFast() {
return _threadValueMacOS; return _threadValueMacOS;
@@ -2799,7 +2799,7 @@ extern unsigned long threadValueLinux;
#endif /* defined(GLIDE_PLATFORM & GLIDE_OS_UNIX) */ #endif /* defined(GLIDE_PLATFORM & GLIDE_OS_UNIX) */
#if (GLIDE_PLATFORM & GLIDE_OS_DOS32) #if (GLIDE_PLATFORM & GLIDE_OS_DOS32)
extern FxU32 GR_CDECL threadValueDJGPP; extern unsigned long GR_CDECL threadValueDJGPP;
#define getThreadValueFast() threadValueDJGPP #define getThreadValueFast() threadValueDJGPP
#endif /* DOS32 */ #endif /* DOS32 */

View File

@@ -19,7 +19,6 @@
** **
*/ */
/* NOTE: This file is compiled to naught if we aren't /* NOTE: This file is compiled to naught if we aren't
running under Win32 */ running under Win32 */
@@ -45,8 +44,8 @@ static DWORD tlsIndex;
static FxBool threadInit; static FxBool threadInit;
static FxBool criticalSectionInit; static FxBool criticalSectionInit;
void void
initThreadStorage( void ) initThreadStorage( void )
{ {
if ( !threadInit ) { if ( !threadInit ) {
threadInit = 1; threadInit = 1;
@@ -55,14 +54,14 @@ initThreadStorage( void )
if (_GlideRoot.tlsIndex == TLS_OUT_OF_INDEXES) if (_GlideRoot.tlsIndex == TLS_OUT_OF_INDEXES)
GrErrorCallback( "initThreadStorage: Failed to allocate TLS index.", FXTRUE ); GrErrorCallback( "initThreadStorage: Failed to allocate TLS index.", FXTRUE );
/* pray the index is lower than 64 */ /* pray the index is lower than 64 -- TLS_MINIMUM_AVAILABLE = 64 */
if ((_GlideRoot.tlsIndex < 0) || if (_GlideRoot.tlsIndex => TLS_MINIMUM_AVAILABLE)
(_GlideRoot.tlsIndex > 63)) /* TLS_MINIMUM_AVAILABLE = 64 */
GrErrorCallback( "initThreadStorage: TLS index higher than 64.", FXTRUE ); GrErrorCallback( "initThreadStorage: TLS index higher than 64.", FXTRUE );
#if !USE_STANDARD_TLS_FUNC #if !USE_STANDARD_TLS_FUNC
if ( hwcIsOSWin9x() ) { if (hwcIsOSWin9x()) {
_GlideRoot.tlsOffset = W95_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); _GlideRoot.tlsOffset = W95_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex);
} else { }
else {
_GlideRoot.tlsOffset = WNT_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex); _GlideRoot.tlsOffset = WNT_TLS_INDEX_TO_OFFSET(_GlideRoot.tlsIndex);
} }
#endif #endif
@@ -74,18 +73,18 @@ void setThreadValue( unsigned long value ) {
TlsSetValue( _GlideRoot.tlsIndex, (void*)value ); TlsSetValue( _GlideRoot.tlsIndex, (void*)value );
} }
unsigned long getThreadValueSLOW(void) unsigned long getThreadValueSLOW( void )
{ {
GR_CHECK_F( "getThreadValue", !threadInit, "Thread storage not initialized\n" ); GR_CHECK_F( "getThreadValue", !threadInit, "Thread storage not initialized\n" );
return getThreadValueFast(); return getThreadValueFast();
} }
#if USE_STANDARD_TLS_FUNC #if USE_STANDARD_TLS_FUNC
/* used in gdraw.c (grDrawTriangle) and xos.inc */ /* used in gdraw.c (grDrawTriangle) and xos.inc */
FxU32 getThreadValue(void) unsigned long getThreadValue(void)
{ {
return (FxU32)TlsGetValue(_GlideRoot.tlsIndex); return (unsigned long)TlsGetValue(_GlideRoot.tlsIndex);
} }
#endif #endif
@@ -123,7 +122,7 @@ void endCriticalSection( void ) {
#elif defined(macintosh) #elif defined(macintosh)
FxU32 _threadValueMacOS; unsigned long _threadValueMacOS;
void initThreadStorage(void) void initThreadStorage(void)
{ {
@@ -134,7 +133,7 @@ void setThreadValue( unsigned long value )
_threadValueMacOS = value; _threadValueMacOS = value;
} }
FxU32 getThreadValueSLOW( void ) unsigned long getThreadValueSLOW( void )
{ {
return _threadValueMacOS; return _threadValueMacOS;
} }
@@ -167,8 +166,6 @@ void initThreadStorage(void)
{ {
} }
void setThreadValue( unsigned long value ) void setThreadValue( unsigned long value )
{ {
threadValueLinux = value; threadValueLinux = value;
@@ -197,22 +194,22 @@ void endCriticalSection(void)
#elif (GLIDE_PLATFORM & GLIDE_OS_DOS32) #elif (GLIDE_PLATFORM & GLIDE_OS_DOS32)
FxU32 GR_CDECL threadValueDJGPP; unsigned long GR_CDECL threadValueDJGPP;
void initThreadStorage(void) void initThreadStorage(void)
{ {
} }
void setThreadValue( FxU32 value ) void setThreadValue( unsigned long value )
{ {
threadValueDJGPP = value; threadValueDJGPP = value;
} }
FxU32 getThreadValueSLOW( void ) unsigned long getThreadValueSLOW( void )
{ {
return threadValueDJGPP; return threadValueDJGPP;
} }
void initCriticalSection(void) void initCriticalSection(void)
{ {
} }