diff --git a/Engine/source/console/compiler.cpp b/Engine/source/console/compiler.cpp index ba8a0c314..21a79704e 100644 --- a/Engine/source/console/compiler.cpp +++ b/Engine/source/console/compiler.cpp @@ -70,11 +70,42 @@ namespace Compiler //------------------------------------------------------------ +#ifdef TORQUE_CPU_X64 + // Fixed unsafe conversion from pointer to U32. @todo x64 revise + U32 u32toSTEId = 0; + typedef Map< U32, StringTableEntry > U32toSteMap; + U32toSteMap u32toSTEMap; + + StringTableEntry U32toSTE( U32 u ) + { + // @todo x64 Added thread-safe convertion. + const U32toSteMap::Iterator result = u32toSTEMap.find( u ); + AssertFatal( result != u32toSTEMap.end( ), + "Don't converted U32 to STE. See evalSTEtoU32()." ); + return result->value; + } + + U32 evalSTEtoU32( StringTableEntry ste, U32 ) + { + // @todo x64 Added thread-safe convertion. + u32toSTEMap.insert( u32toSTEId++, ste ); + return (u32toSTEId - 1); // pointer to inserted + } + +#else + + StringTableEntry U32toSTE(U32 u) + { + return *((StringTableEntry *) &u); + } + U32 evalSTEtoU32(StringTableEntry ste, U32) { return *((U32 *) &ste); } +#endif + U32 compileSTEtoU32(StringTableEntry ste, U32 ip) { if(ste) diff --git a/Engine/source/console/compiler.h b/Engine/source/console/compiler.h index 66e3966b9..8e497a630 100644 --- a/Engine/source/console/compiler.h +++ b/Engine/source/console/compiler.h @@ -218,10 +218,7 @@ namespace Compiler //------------------------------------------------------------ - inline StringTableEntry U32toSTE(U32 u) - { - return *((StringTableEntry *) &u); - } + StringTableEntry U32toSTE(U32 u); extern U32 (*STEtoU32)(StringTableEntry ste, U32 ip); diff --git a/Engine/source/console/console.h b/Engine/source/console/console.h index 3c5718c48..544ebc801 100644 --- a/Engine/source/console/console.h +++ b/Engine/source/console/console.h @@ -696,7 +696,7 @@ namespace Con extern void expandEscape(char *dest, const char *src); extern bool collapseEscape(char *buf); -extern S32 HashPointer(StringTableEntry ptr); +extern U32 HashPointer(StringTableEntry ptr); /// Extended information about a console function. diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index 250326460..2e91da6d7 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -262,9 +262,9 @@ void Dictionary::deleteVariables(const char *varString) } } -S32 HashPointer(StringTableEntry ptr) +U32 HashPointer(StringTableEntry ptr) { - return (S32)(((dsize_t)ptr) >> 2); + return (U32)(((dsize_t)ptr) >> 2); } Dictionary::Entry *Dictionary::lookup(StringTableEntry name) diff --git a/Engine/source/console/simDictionary.cpp b/Engine/source/console/simDictionary.cpp index 5065d0a08..dac603517 100644 --- a/Engine/source/console/simDictionary.cpp +++ b/Engine/source/console/simDictionary.cpp @@ -25,7 +25,7 @@ //---------------------------------------------------------------------------- //---------------------------------------------------------------------------- -extern S32 HashPointer(StringTableEntry e); +extern U32 HashPointer(StringTableEntry e); SimNameDictionary::SimNameDictionary() { diff --git a/Engine/source/core/stringTable.cpp b/Engine/source/core/stringTable.cpp index e94ca50e7..2340fd5af 100644 --- a/Engine/source/core/stringTable.cpp +++ b/Engine/source/core/stringTable.cpp @@ -59,7 +59,7 @@ U32 _StringTable::hashString(const char* str) char c; while((c = *str++) != 0) { ret <<= 1; - ret ^= sgHashTable[static_cast(c)]; + ret ^= sgHashTable[static_cast(c)]; } return ret; } @@ -73,7 +73,7 @@ U32 _StringTable::hashStringn(const char* str, S32 len) char c; while((c = *str++) != 0 && len--) { ret <<= 1; - ret ^= sgHashTable[static_cast(c)]; + ret ^= sgHashTable[static_cast(c)]; } return ret; } diff --git a/Engine/source/platform/platformIntrinsics.h b/Engine/source/platform/platformIntrinsics.h index fd2e11916..b63a987be 100644 --- a/Engine/source/platform/platformIntrinsics.h +++ b/Engine/source/platform/platformIntrinsics.h @@ -40,7 +40,7 @@ template< typename T > inline bool dCompareAndSwap( T* volatile& refPtr, T* oldPtr, T* newPtr ) { - return dCompareAndSwap( *reinterpret_cast< volatile U32* >( &refPtr ), ( U32 ) oldPtr, ( U32 ) newPtr ); + return dCompareAndSwap( *reinterpret_cast< volatile size_t* >( &refPtr ), ( size_t ) oldPtr, ( size_t ) newPtr ); } // Test-And-Set diff --git a/Engine/source/platform/typetraits.h b/Engine/source/platform/typetraits.h index a686ab782..4183a3f8f 100644 --- a/Engine/source/platform/typetraits.h +++ b/Engine/source/platform/typetraits.h @@ -222,11 +222,11 @@ struct _TypeTraits< T* > typedef _DestructPtr Destruct; template< typename A > - static bool isTaggedPtr( A* ptr ) { return ( U32( ptr ) & 0x1 ); } //TODO: 64bits + static bool isTaggedPtr( A* ptr ) { return ( size_t( ptr ) & 0x1 ); } //TODO: 64bits template< typename A > - static A* getTaggedPtr( A* ptr ) { return ( A* ) ( U32( ptr ) | 0x1 ); } //TODO: 64bits + static A* getTaggedPtr( A* ptr ) { return ( A* ) ( size_t( ptr ) | 0x1 ); } //TODO: 64bits template< typename A > - static A* getUntaggedPtr( A* ptr ) { return ( A* ) ( U32( ptr ) & 0xFFFFFFFE ); } //TODO: 64bit + static A* getUntaggedPtr( A* ptr ) { return ( A* ) ( size_t( ptr ) & (~0x1) ); } //TODO: 64bit }; template< typename T > diff --git a/Engine/source/ts/tsShape.cpp b/Engine/source/ts/tsShape.cpp index d01a871c5..7b160b670 100644 --- a/Engine/source/ts/tsShape.cpp +++ b/Engine/source/ts/tsShape.cpp @@ -1170,7 +1170,10 @@ void TSShape::assembleShape() skip = true; TSMesh * mesh = TSMesh::assembleMesh(meshType,skip); if (ptr32) + { ptr32[i] = skip ? 0 : (S32)mesh; + meshes.push_back(skip ? 0 : mesh); + } // fill in location of verts, tverts, and normals for detail levels if (mesh && meshType!=TSMesh::DecalMeshType) @@ -1198,7 +1201,6 @@ void TSShape::assembleShape() } } } - meshes.set(ptr32,numMeshes); tsalloc.checkGuard(); diff --git a/Engine/source/windowManager/win32/win32Window.cpp b/Engine/source/windowManager/win32/win32Window.cpp index c8e02f706..0bb7677df 100644 --- a/Engine/source/windowManager/win32/win32Window.cpp +++ b/Engine/source/windowManager/win32/win32Window.cpp @@ -661,7 +661,7 @@ void Win32Window::_unregisterWindowClass() LRESULT PASCAL Win32Window::WindowProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { // CodeReview [tom, 4/30/2007] The two casts here seem somewhat silly and redundant ? - Win32Window* window = (Win32Window*)((PlatformWindow*)GetWindowLong(hWnd, GWLP_USERDATA)); + Win32Window* window = (Win32Window*)((PlatformWindow*)GetWindowLongPtr(hWnd, GWLP_USERDATA)); const WindowId devId = window ? window->getWindowId() : 0; if (window && window->getOffscreenRender()) @@ -712,8 +712,8 @@ LRESULT PASCAL Win32Window::WindowProc( HWND hWnd, UINT message, WPARAM wParam, case WM_CREATE: // CodeReview [tom, 4/30/2007] Why don't we just cast this to a LONG // instead of having a ton of essentially pointless casts ? - SetWindowLong(hWnd, GWLP_USERDATA, - (LONG)((PlatformWindow*)((CREATESTRUCT*)lParam)->lpCreateParams)); + SetWindowLongPtr(hWnd, GWLP_USERDATA, + (LONG_PTR)((PlatformWindow*)((CREATESTRUCT*)lParam)->lpCreateParams)); break; case WM_SETFOCUS: diff --git a/Engine/source/windowManager/win32/win32WindowMgr.cpp b/Engine/source/windowManager/win32/win32WindowMgr.cpp index 448cb20e8..ef04c7fe1 100644 --- a/Engine/source/windowManager/win32/win32WindowMgr.cpp +++ b/Engine/source/windowManager/win32/win32WindowMgr.cpp @@ -136,7 +136,7 @@ void Win32WindowManager::buildMonitorsList() mMonitors.clear(); // Enumerate all monitors - EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (U32)(void*)&mMonitors); + EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (size_t)(void*)&mMonitors); } S32 Win32WindowManager::findFirstMatchingMonitor(const char* name) @@ -252,7 +252,7 @@ PlatformWindow *Win32WindowManager::createWindow(GFXDevice *device, const GFXVid w32w->setVideoMode(mode); // Associate our window struct with the HWND. - SetWindowLongPtrW(w32w->mWindowHandle, GWLP_USERDATA, (LONG)w32w); + SetWindowLongPtr(w32w->mWindowHandle, GWLP_USERDATA, (LONG_PTR)w32w); // Do some error checking. AssertFatal(w32w->mWindowHandle != NULL, "Win32WindowManager::createWindow - Could not create window!"); @@ -358,7 +358,7 @@ void Win32WindowManager::_process() // [tom, 4/30/2007] I think this should work, but leaving the above commented // out just in case this is actually fubared with multiple windows. - Win32Window* window = (Win32Window*)(GetWindowLong(msg.hwnd, GWLP_USERDATA)); + Win32Window* window = (Win32Window*)(GetWindowLongPtr(msg.hwnd, GWLP_USERDATA)); if(window) translated = window->translateMessage(msg); diff --git a/Engine/source/windowManager/win32/winDispatch.cpp b/Engine/source/windowManager/win32/winDispatch.cpp index 3ac7f12a2..0d26def4d 100644 --- a/Engine/source/windowManager/win32/winDispatch.cpp +++ b/Engine/source/windowManager/win32/winDispatch.cpp @@ -176,7 +176,7 @@ static bool _dispatch(HWND hWnd,UINT message,WPARAM wParam,WPARAM lParam) static S32 mouseNCState = -1; // -1 denotes unchanged, // 0 denotes changed but was hidden // 1 denotes changed but was visible - Win32Window* window = hWnd?(Win32Window*)GetWindowLong(hWnd, GWLP_USERDATA): 0; + Win32Window* window = hWnd?(Win32Window*)GetWindowLongPtr(hWnd, GWLP_USERDATA): 0; const WindowId devId = window ? window->getWindowId() : 0; // State tracking for focus/lose focus cursor management