Merge branch 'master' into console-func-refactor

Conflicts:
	Engine/source/app/net/net.cpp
	Engine/source/console/astNodes.cpp
	Engine/source/console/compiledEval.cpp
	Engine/source/console/console.h
	Engine/source/console/consoleInternal.h
	Engine/source/console/engineAPI.h
This commit is contained in:
Daniel Buckmaster 2014-10-14 14:40:17 +11:00
commit b507dc9555
6487 changed files with 315149 additions and 609761 deletions

View file

@ -191,9 +191,9 @@ INT CreateMiniDump( LPEXCEPTION_POINTERS ExceptionInfo)
//-----------------------------------------------------------------------------------------------------------------------------------------
// MiniDumpDialogProc - Used By DisplayMiniDumpDialog
//-----------------------------------------------------------------------------------------------------------------------------------------
const int ID_TEXT=200;
const int ID_USERTEXT=300;
const int ID_DONE=400;
const S32 ID_TEXT=200;
const S32 ID_USERTEXT=300;
const S32 ID_DONE=400;
BOOL CALLBACK MiniDumpDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
char text[128]= "";
@ -259,7 +259,7 @@ LRESULT DisplayMiniDumpDialog(HINSTANCE hinst, HWND hwndOwner)
*lpw++ = 0; // Predefined dialog box class (by default)
LPWSTR lpwsz = (LPWSTR)lpw;
int nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "MiniDump Crash Report", -1, lpwsz, 50);
S32 nchar = 1 + MultiByteToWideChar(CP_ACP, 0, "MiniDump Crash Report", -1, lpwsz, 50);
lpw += nchar;
//-----------------------------------------------------------------

View file

@ -48,7 +48,7 @@
#endif
// Entry for each Callstack-Entry
const int STACKWALK_MAX_NAMELEN = 1024; // max name length for symbols
const S32 STACKWALK_MAX_NAMELEN = 1024; // max name length for symbols
struct CallstackEntry
{
DWORD64 offset; // if 0, we have no valid entry
@ -393,7 +393,7 @@ bool StackWalker::ShowCallstack(HANDLE hThread, CONTEXT const & context, PReadPr
IMAGEHLP_SYMBOL64 *pSym = NULL;
IMAGEHLP_MODULE64 Module;
IMAGEHLP_LINE64 Line;
int frameNum;
S32 frameNum;
if (!m_modulesLoaded) LoadModules();
@ -687,7 +687,7 @@ bool StackWalker::GetModuleListTH32(HANDLE hProcess, DWORD pid)
return false;
keepGoing = !!pM32F( hSnap, &me );
int cnt = 0;
S32 cnt = 0;
while (keepGoing)
{
this->LoadModule(hProcess, me.szExePath, me.szModule, (DWORD64) me.modBaseAddr, me.modBaseSize);
@ -715,7 +715,7 @@ bool StackWalker::GetModuleListPSAPI(HANDLE hProcess)
char *tt = NULL;
char *tt2 = NULL;
const SIZE_T TTBUFLEN = 8096;
int cnt = 0;
S32 cnt = 0;
hMods = (HMODULE*) malloc(sizeof(HMODULE) * (TTBUFLEN / sizeof HMODULE));
tt = (char*) malloc(sizeof(char) * TTBUFLEN);

View file

@ -76,7 +76,7 @@ private:
DWORD m_dwProcessId;
bool m_modulesLoaded;
LPSTR m_szSymPath;
int m_options;
S32 m_options;
char * m_pOutputBuffer;
static BOOL __stdcall myReadProcMem(HANDLE hProcess, DWORD64 qwBaseAddress, PVOID lpBuffer, DWORD nSize, LPDWORD lpNumberOfBytesRead);

View file

@ -113,7 +113,7 @@ static UINT_PTR CALLBACK FolderHookProc(HWND hdlg, UINT uMsg, WPARAM wParam, LPA
SendMessage(hParent, CDM_HIDECONTROL, cmb1, 0);
SendMessage(hParent, CDM_HIDECONTROL, stc2, 0);
LONG oldProc = SetWindowLong(hParent, GWL_WNDPROC, (LONG)OKBtnFolderHackProc);
LONG oldProc = SetWindowLong(hParent, GWLP_WNDPROC, (LONG)OKBtnFolderHackProc);
SetProp(hParent, dT("OldWndProc"), (HANDLE)oldProc);
SetProp(hParent, dT("OFN"), (HANDLE)lpofn);
}

View file

@ -68,7 +68,7 @@ public:
// Neccesary because Thread::run() is provided as a non-threaded
// way to execute the thread's run function. So we have to keep
// track of the thread's lock here.
static unsigned int __stdcall ThreadRunHandler(void * arg)
static U32 __stdcall ThreadRunHandler(void * arg)
{
PlatformThreadData* mData = reinterpret_cast<PlatformThreadData*>(arg);
mData->mThreadID = GetCurrentThreadId();
@ -164,7 +164,7 @@ U32 Thread::getId()
void Thread::_setName( const char* name )
{
#if defined( TORQUE_DEBUG ) && defined( TORQUE_COMPILER_VISUALC ) && defined( TORQUE_OS_WIN32 )
#if defined( TORQUE_DEBUG ) && defined( TORQUE_COMPILER_VISUALC ) && defined( TORQUE_OS_WIN )
// See http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx

View file

@ -119,7 +119,7 @@ struct DXDIAG_INIT_PARAMS
struct IDxDiagContainer : public IUnknown
{
virtual HRESULT STDMETHODCALLTYPE GetNumberOfChildContaiiners( DWORD* pdwCount ) = 0;
virtual HRESULT STDMETHODCALLTYPE GetNumberOfChildContainers( DWORD* pdwCount ) = 0;
virtual HRESULT STDMETHODCALLTYPE EnumChildContainerNames( DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer ) = 0;
virtual HRESULT STDMETHODCALLTYPE GetChildContainer( LPCWSTR pwszContainer, IDxDiagContainer** ppInstance ) = 0;
virtual HRESULT STDMETHODCALLTYPE GetNumberOfProps( DWORD* pdwCount ) = 0;
@ -361,6 +361,28 @@ bool WMIVideoInfo::_queryPropertyDxDiag( const PVIQueryType queryType, const U32
IDxDiagContainer* displayDevicesContainer = 0;
IDxDiagContainer* deviceContainer = 0;
// Special case to deal with PVI_NumAdapters
if(queryType == PVI_NumAdapters)
{
DWORD count = 0;
String value;
if( mDxDiagProvider->GetRootContainer( &rootContainer ) == S_OK
&& rootContainer->GetChildContainer( L"DxDiag_DisplayDevices", &displayDevicesContainer ) == S_OK
&& displayDevicesContainer->GetNumberOfChildContainers( &count ) == S_OK )
{
value = String::ToString("%d", count);
}
if( rootContainer )
SAFE_RELEASE( rootContainer );
if( displayDevicesContainer )
SAFE_RELEASE( displayDevicesContainer );
*outValue = value;
return true;
}
WCHAR adapterIdString[ 2 ];
adapterIdString[ 0 ] = L'0' + adapterId;
adapterIdString[ 1 ] = L'\0';
@ -546,9 +568,20 @@ bool WMIVideoInfo::_queryPropertyWMI( const PVIQueryType queryType, const U32 ad
LONG longVal = v.lVal;
if( queryType == PVI_VRAM )
{
longVal = longVal >> 20; // Convert to megabytes
*outValue = String::ToString( (S32)longVal );
// While this value is reported as a signed integer, it is possible
// for video cards to have 2GB or more. In those cases the signed
// bit is set and will give us a negative number. Treating this
// as unsigned will allows us to handle video cards with up to
// 4GB of memory. After that we'll need a new solution from Microsoft.
*outValue = String::ToString( (U32)longVal );
}
else
{
*outValue = String::ToString( (S32)longVal );
}
break;
}

View file

@ -130,7 +130,7 @@ WinConsole::~WinConsole()
void WinConsole::printf(const char *s, ...)
{
// Get the line into a buffer.
static const int BufSize = 4096;
static const S32 BufSize = 4096;
static char buffer[4096];
DWORD bytes;
va_list args;

View file

@ -27,9 +27,6 @@
#ifndef _CONSOLE_H_
#include "console/console.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
class WinConsole
{

View file

@ -66,7 +66,8 @@ DInputDevice::DInputDevice( const DIDEVICEINSTANCE* dii )
switch ( GET_DIDEVICE_TYPE( mDeviceInstance.dwDevType ) )
{
// [rene, 12/09/2008] why do we turn a gamepad into a joystick here?
case DI8DEVTYPE_DRIVING:
case DI8DEVTYPE_GAMEPAD:
case DI8DEVTYPE_JOYSTICK:
deviceTypeName = "joystick";
@ -895,8 +896,8 @@ bool DInputDevice::buildEvent( DWORD offset, S32 newData, S32 oldData )
// Scale to the range -1.0 to 1.0:
if ( objInfo.mMin != DIPROPRANGE_NOMIN && objInfo.mMax != DIPROPRANGE_NOMAX )
{
float range = float( objInfo.mMax - objInfo.mMin );
newEvent.fValue = float( ( 2 * newData ) - objInfo.mMax - objInfo.mMin ) / range;
F32 range = F32( objInfo.mMax - objInfo.mMin );
newEvent.fValue = F32( ( 2 * newData ) - objInfo.mMax - objInfo.mMin ) / range;
}
else
newEvent.fValue = (F32)newData;
@ -991,7 +992,7 @@ bool DInputDevice::buildEvent( DWORD offset, S32 newData, S32 oldData )
}
if( clearkeys & POV_down)
{
newEvent.objInst = ( objInst == 0 ) ? SI_DPOV : SI_DPOV;
newEvent.objInst = ( objInst == 0 ) ? SI_DPOV : SI_DPOV2;
_Win32LogPOVInput(newEvent);
newEvent.postToSignal(Input::smInputEvent);
}
@ -1022,7 +1023,7 @@ bool DInputDevice::buildEvent( DWORD offset, S32 newData, S32 oldData )
}
if( setkeys & POV_down)
{
newEvent.objInst = ( objInst == 0 ) ? SI_DPOV : SI_DPOV;
newEvent.objInst = ( objInst == 0 ) ? SI_DPOV : SI_DPOV2;
_Win32LogPOVInput(newEvent);
newEvent.postToSignal(Input::smInputEvent);
}
@ -1040,7 +1041,7 @@ bool DInputDevice::buildEvent( DWORD offset, S32 newData, S32 oldData )
return true;
}
void DInputDevice::rumble(float x, float y)
void DInputDevice::rumble(F32 x, F32 y)
{
LONG rglDirection[2] = { 0, 0 };
DICONSTANTFORCE cf = { 0 };

View file

@ -29,9 +29,6 @@
#ifndef _PLATFORMINPUT_H_
#include "platform/platformInput.h"
#endif
#ifndef _EVENT_H_
#include "platform/event.h"
#endif
#define DIRECTINPUT_VERSION 0x0800
#include <dinput.h>
@ -120,7 +117,7 @@ class DInputDevice : public InputDevice
const char* getProductName();
// Constant Effect Force Feedback
void rumble( float x, float y );
void rumble( F32 x, F32 y );
// Console interface functions:
const char* getJoystickAxesString();

View file

@ -23,7 +23,6 @@
#include "platformWin32/platformWin32.h"
#include "platformWin32/winDirectInput.h"
#include "platformWin32/winDInputDevice.h"
#include "platform/event.h"
#include "console/console.h"
#include "console/consoleTypes.h"
#include "sim/actionMap.h"
@ -438,14 +437,14 @@ bool DInputManager::isXInputEnabled()
}
//------------------------------------------------------------------------------
bool DInputManager::isXInputConnected(int controllerID)
bool DInputManager::isXInputConnected(S32 controllerID)
{
return( mXInputStateNew[controllerID].bConnected );
}
int DInputManager::getXInputState(int controllerID, int property, bool current)
int DInputManager::getXInputState(S32 controllerID, S32 property, bool current)
{
int retVal;
S32 retVal;
switch(property)
{
@ -512,7 +511,7 @@ void DInputManager::deactivateXInput()
}
//------------------------------------------------------------------------------
bool DInputManager::rumble( const char *pDeviceName, float x, float y )
bool DInputManager::rumble( const char *pDeviceName, F32 x, F32 y )
{
// Determine the device
U32 deviceType;
@ -567,7 +566,7 @@ bool DInputManager::rumble( const char *pDeviceName, float x, float y )
}
}
void DInputManager::buildXInputEvent( U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, float fValue )
void DInputManager::buildXInputEvent( U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue )
{
InputEventInfo newEvent;
@ -587,7 +586,7 @@ void DInputManager::buildXInputEvent( U32 deviceInst, InputEventType objType, In
// "mXInputStateReset" is the exception and is true whenever DirectInput gets reset (because
// the user ALT-TABBED away, for example). That means that after every context switch,
// you will get a full set of updates on the "true" state of the controller.
inline void DInputManager::fireXInputConnectEvent( int controllerID, bool condition, bool connected )
inline void DInputManager::fireXInputConnectEvent( S32 controllerID, bool condition, bool connected )
{
if ( mXInputStateReset || condition )
{
@ -598,7 +597,7 @@ inline void DInputManager::fireXInputConnectEvent( int controllerID, bool condit
}
}
inline void DInputManager::fireXInputMoveEvent( int controllerID, bool condition, InputObjectInstances objInst, float fValue )
inline void DInputManager::fireXInputMoveEvent( S32 controllerID, bool condition, InputObjectInstances objInst, F32 fValue )
{
if ( mXInputStateReset || condition )
{
@ -621,7 +620,7 @@ inline void DInputManager::fireXInputMoveEvent( int controllerID, bool condition
}
}
inline void DInputManager::fireXInputButtonEvent( int controllerID, bool forceFire, int button, InputObjectInstances objInst )
inline void DInputManager::fireXInputButtonEvent( S32 controllerID, bool forceFire, S32 button, InputObjectInstances objInst )
{
if ( mXInputStateReset || forceFire || ((mXInputStateNew[controllerID].state.Gamepad.wButtons & button) != (mXInputStateOld[controllerID].state.Gamepad.wButtons & button)) )
{
@ -664,7 +663,7 @@ void DInputManager::processXInput( void )
if ( mfnXInputGetState )
{
for ( int i=0; i<4; i++ )
for ( S32 i=0; i<4; i++ )
{
// Calling XInputGetState on a disconnected controller takes a fair
// amount of time (probably because it tries to locate it), so we
@ -856,7 +855,7 @@ ConsoleFunction( isXInputConnected, bool, 2, 2, "( int controllerID )"
}
//------------------------------------------------------------------------------
ConsoleFunction( getXInputState, int, 3, 4, "( int controllerID, string property, bool current )"
ConsoleFunction( getXInputState, S32, 3, 4, "( int controllerID, string property, bool current )"
"@brief Queries the current state of a connected Xbox 360 controller.\n\n"
"XInput Properties:\n\n"
" - XI_THUMBLX, XI_THUMBLY - X and Y axes of the left thumbstick. \n"

View file

@ -85,10 +85,10 @@ class DInputManager : public InputManager
void unacquire( U8 deviceType, U8 deviceID );
// XInput worker functions
void buildXInputEvent( U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, float fValue );
void fireXInputConnectEvent( int controllerID, bool condition, bool connected );
void fireXInputMoveEvent( int controllerID, bool condition, InputObjectInstances objInst, float fValue );
void fireXInputButtonEvent( int controllerID, bool forceFire, int button, InputObjectInstances objInst );
void buildXInputEvent( U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue );
void fireXInputConnectEvent( S32 controllerID, bool condition, bool connected );
void fireXInputMoveEvent( S32 controllerID, bool condition, InputObjectInstances objInst, F32 fValue );
void fireXInputButtonEvent( S32 controllerID, bool forceFire, S32 button, InputObjectInstances objInst );
void processXInput();
public:
@ -120,13 +120,13 @@ class DInputManager : public InputManager
void deactivateXInput();
bool isXInputActive() { return( mXInputActive ); }
void resetXInput() { mXInputStateReset = true; }
bool isXInputConnected(int controllerID);
int getXInputState(int controllerID, int property, bool current);
bool isXInputConnected(S32 controllerID);
S32 getXInputState(S32 controllerID, S32 property, bool current);
// Console interface:
const char* getJoystickAxesString( U32 deviceID );
bool rumble( const char *pDeviceName, float x, float y );
bool rumble( const char *pDeviceName, F32 x, F32 y );
};
#endif // _H_WINDIRECTINPUT_

View file

@ -29,6 +29,7 @@
#include "core/strings/unicode.h"
#include "util/tempAlloc.h"
#include "core/util/safeDelete.h"
#include "core/volume.h"
// Microsoft VC++ has this POSIX header in the wrong directory
#if defined(TORQUE_COMPILER_VISUALC)
@ -247,7 +248,7 @@ File::~File()
// Sets capability appropriate to the openMode.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::open(const char *filename, const AccessMode openMode)
File::FileStatus File::open(const char *filename, const AccessMode openMode)
{
AssertFatal(NULL != filename, "File::open: NULL fname");
AssertWarn(INVALID_HANDLE_VALUE == (HANDLE)handle, "File::open: handle already valid");
@ -362,7 +363,7 @@ U32 File::getPosition() const
//
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::setPosition(S32 position, bool absolutePos)
File::FileStatus File::setPosition(S32 position, bool absolutePos)
{
AssertFatal(Closed != currentStatus, "File::setPosition: file closed");
AssertFatal(INVALID_HANDLE_VALUE != (HANDLE)handle, "File::setPosition: invalid file handle");
@ -424,7 +425,7 @@ U32 File::getSize() const
// It is an error to flush a read-only file.
// Returns the currentStatus of the file.
//-----------------------------------------------------------------------------
File::Status File::flush()
File::FileStatus File::flush()
{
AssertFatal(Closed != currentStatus, "File::flush: file closed");
AssertFatal(INVALID_HANDLE_VALUE != (HANDLE)handle, "File::flush: invalid file handle");
@ -441,7 +442,7 @@ File::Status File::flush()
//
// Returns the currentStatus
//-----------------------------------------------------------------------------
File::Status File::close()
File::FileStatus File::close()
{
// check if it's already closed...
if (Closed == currentStatus)
@ -460,7 +461,7 @@ File::Status File::close()
//-----------------------------------------------------------------------------
// Self-explanatory.
//-----------------------------------------------------------------------------
File::Status File::getStatus() const
File::FileStatus File::getStatus() const
{
return currentStatus;
}
@ -468,7 +469,7 @@ File::Status File::getStatus() const
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus when an error has been encountered.
//-----------------------------------------------------------------------------
File::Status File::setStatus()
File::FileStatus File::setStatus()
{
switch (GetLastError())
{
@ -488,7 +489,7 @@ File::Status File::setStatus()
//-----------------------------------------------------------------------------
// Sets and returns the currentStatus to status.
//-----------------------------------------------------------------------------
File::Status File::setStatus(File::Status status)
File::FileStatus File::setStatus(File::FileStatus status)
{
return currentStatus = status;
}
@ -499,7 +500,7 @@ File::Status File::setStatus(File::Status status)
// The number of bytes read is available in bytesRead if a non-Null pointer is
// provided.
//-----------------------------------------------------------------------------
File::Status File::read(U32 size, char *dst, U32 *bytesRead)
File::FileStatus File::read(U32 size, char *dst, U32 *bytesRead)
{
AssertFatal(Closed != currentStatus, "File::read: file closed");
AssertFatal(INVALID_HANDLE_VALUE != (HANDLE)handle, "File::read: invalid file handle");
@ -530,7 +531,7 @@ File::Status File::read(U32 size, char *dst, U32 *bytesRead)
// The number of bytes written is available in bytesWritten if a non-Null
// pointer is provided.
//-----------------------------------------------------------------------------
File::Status File::write(U32 size, const char *src, U32 *bytesWritten)
File::FileStatus File::write(U32 size, const char *src, U32 *bytesWritten)
{
AssertFatal(Closed != currentStatus, "File::write: file closed");
AssertFatal(INVALID_HANDLE_VALUE != (HANDLE)handle, "File::write: invalid file handle");
@ -946,7 +947,11 @@ bool Platform::isFile(const char *pFilePath)
FindClose(handle);
if(handle == INVALID_HANDLE_VALUE)
return false;
{
// Since file does not exist on disk see if it exists in a zip file loaded
return Torque::FS::IsFile(pFilePath);
}
// if the file is a Directory, Offline, System or Temporary then FALSE
if (findData.dwFileAttributes &
@ -1135,7 +1140,7 @@ void Platform::getVolumeNamesList( Vector<const char*>& out_rNameVector, bool bO
out_rNameVector.clear();
for(int i = 0; i < 32; i++ )
for(S32 i = 0; i < 32; i++ )
{
dMemset(driveLetter,0,12);
if( dwDrives & dwMask )

View file

@ -116,7 +116,7 @@ void PlatformFont::enumeratePlatformFonts( Vector<StringTableEntry>& fonts, UTF1
EnumFontFamilies( fontHDC, fontFamily, (FONTENUMPROC)EnumFamCallBack, (LPARAM)&fonts );
}
PlatformFont *createPlatformFont(const char *name, U32 size, U32 charset /* = TGE_ANSI_CHARSET */)
PlatformFont *createPlatformFont(const char *name, dsize_t size, U32 charset /* = TGE_ANSI_CHARSET */)
{
PlatformFont *retFont = new WinFont;
@ -139,7 +139,7 @@ WinFont::~WinFont()
}
}
bool WinFont::create(const char *name, U32 size, U32 charset /* = TGE_ANSI_CHARSET */)
bool WinFont::create(const char *name, dsize_t size, U32 charset /* = TGE_ANSI_CHARSET */)
{
if(name == NULL || size < 1)
return false;

View file

@ -24,7 +24,6 @@
#include "platform/platformInput.h"
#include "platformWin32/winDirectInput.h"
#include "platform/event.h"
#include "console/console.h"
#include "core/util/journal/process.h"
#include "windowManager/platformWindowMgr.h"

View file

@ -92,6 +92,23 @@ void Platform::setMathControlStateKnown()
}
}
#else
U32 Platform::getMathControlState( )
{
// @todo x64 See http://msdn.microsoft.com/en-us/library/c9676k6h.aspx
return 0;
}
void Platform::setMathControlState( U32 state )
{
// @todo x64 See http://msdn.microsoft.com/en-us/library/c9676k6h.aspx
}
void Platform::setMathControlStateKnown( )
{
// @todo x64 See http://msdn.microsoft.com/en-us/library/c9676k6h.aspx
}
#endif

View file

@ -23,26 +23,26 @@
#include "platformWin32/platformWin32.h"
#include <xmmintrin.h>
void* dMemcpy(void *dst, const void *src, unsigned size)
void* dMemcpy(void *dst, const void *src, dsize_t size)
{
return memcpy(dst,src,size);
}
//--------------------------------------
void* dMemmove(void *dst, const void *src, unsigned size)
void* dMemmove(void *dst, const void *src, dsize_t size)
{
return memmove(dst,src,size);
}
//--------------------------------------
void* dMemset(void *dst, S32 c, unsigned size)
void* dMemset(void *dst, S32 c, dsize_t size)
{
return memset(dst,c,size);
}
//--------------------------------------
S32 dMemcmp(const void *ptr1, const void *ptr2, unsigned len)
S32 dMemcmp(const void *ptr1, const void *ptr2, dsize_t len)
{
return memcmp(ptr1, ptr2, len);
}
@ -63,7 +63,7 @@ void dRealFree(void* p)
free(p);
}
void *dMalloc_aligned(dsize_t in_size, int alignment)
void *dMalloc_aligned(dsize_t in_size, S32 alignment)
{
return _mm_malloc(in_size, alignment);
}

View file

@ -0,0 +1,119 @@
// Original code is:
// Copyright (c) 2005 Intel Corporation
// All Rights Reserved
//
// CPUCount.cpp : Detects three forms of hardware multi-threading support across IA-32 platform
// The three forms of HW multithreading are: Multi-processor, Multi-core, and
// HyperThreading Technology.
// This application enumerates all the logical processors enabled by OS and BIOS,
// determine the HW topology of these enabled logical processors in the system
// using information provided by CPUID instruction.
// A multi-processing system can support any combination of the three forms of HW
// multi-threading support. The relevant topology can be identified using a
// three level decomposition of the "initial APIC ID" into
// Package_id, core_id, and SMT_id. Such decomposition provides a three-level map of
// the topology of hardware resources and
// allow multi-threaded software to manage shared hardware resources in
// the platform to reduce resource contention
// Multicore detection algorithm for processor and cache topology requires
// all leaf functions of CPUID instructions be available. System administrator
// must ensure BIOS settings is not configured to restrict CPUID functionalities.
//-------------------------------------------------------------------------------------------------
#include "platform/platform.h"
#if defined( TORQUE_OS_WIN )
#include "platform/platformCPUCount.h"
#include <windows.h>
#include <intrin.h>
#include <stdio.h>
#include <assert.h>
namespace CPUInfo {
// based on http://msdn.microsoft.com/en-us/library/ms683194.aspx
// Helper function to count set bits in the processor mask.
DWORD CountSetBits( ULONG_PTR bitMask )
{
DWORD LSHIFT = sizeof( ULONG_PTR ) * 8 - 1;
DWORD bitSetCount = 0;
ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT;
DWORD i;
for( i = 0; i <= LSHIFT; ++i )
{
bitSetCount += ((bitMask & bitTest) ? 1 : 0);
bitTest /= 2;
}
return bitSetCount;
}
EConfig CPUCount( U32& TotAvailLogical, U32& TotAvailCore, U32& PhysicalNum )
{
EConfig StatusFlag = CONFIG_UserConfigIssue;
TotAvailLogical = 0;
TotAvailCore = 0;
PhysicalNum = 0;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL;
DWORD returnLength = 0;
// get buffer length
DWORD rc = GetLogicalProcessorInformation( buffer, &returnLength );
buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)malloc( returnLength );
rc = GetLogicalProcessorInformation( buffer, &returnLength );
if( FALSE == rc )
{
free( buffer );
return StatusFlag;
}
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION ptr = buffer;
DWORD byteOffset = 0;
while( byteOffset + sizeof( SYSTEM_LOGICAL_PROCESSOR_INFORMATION ) <= returnLength )
{
switch( ptr->Relationship )
{
case RelationProcessorCore:
TotAvailCore++;
// A hyperthreaded core supplies more than one logical processor.
TotAvailLogical += CountSetBits( ptr->ProcessorMask );
break;
case RelationProcessorPackage:
// Logical processors share a physical package.
PhysicalNum++;
break;
default:
break;
}
byteOffset += sizeof( SYSTEM_LOGICAL_PROCESSOR_INFORMATION );
ptr++;
}
free( buffer );
StatusFlag = CONFIG_SingleCoreAndHTNotCapable;
if( TotAvailCore == 1 && TotAvailLogical > TotAvailCore )
StatusFlag = CONFIG_SingleCoreHTEnabled;
else if( TotAvailCore > 1 && TotAvailLogical == TotAvailCore )
StatusFlag = CONFIG_MultiCoreAndHTNotCapable;
else if( TotAvailCore > 1 && TotAvailLogical > TotAvailCore )
StatusFlag = CONFIG_MultiCoreAndHTEnabled;
return StatusFlag;
}
} // namespace CPUInfo
#endif

View file

@ -66,7 +66,7 @@ String Platform::localTimeToString( const LocalTime &lt )
TCHAR buffer[1024] = {0};
int result = 0;
S32 result = 0;
String outStr;

View file

@ -25,7 +25,10 @@
#include "core/stringTable.h"
#include "core/strings/unicode.h"
#ifndef TORQUE_OS_WIN64
typedef long SHANDLE_PTR;
#endif
#include <shlobj.h>
#include <windows.h>
#include <lmcons.h>

View file

@ -333,7 +333,7 @@ Path Win32File::getName() const
return mPath;
}
FileNode::Status Win32File::getStatus() const
FileNode::NodeStatus Win32File::getStatus() const
{
return mStatus;
}
@ -620,7 +620,7 @@ bool Win32Directory::getAttributes(Attributes* attr)
return true;
}
FileNode::Status Win32Directory::getStatus() const
FileNode::NodeStatus Win32Directory::getStatus() const
{
return mStatus;
}

View file

@ -65,7 +65,7 @@ public:
~Win32File();
Path getName() const;
Status getStatus() const;
NodeStatus getStatus() const;
bool getAttributes(Attributes*);
U64 getSize();
@ -86,7 +86,7 @@ private:
Path mPath;
String mName;
void *mHandle;
Status mStatus;
NodeStatus mStatus;
Win32File(const Path &path, String name);
@ -103,7 +103,7 @@ public:
~Win32Directory();
Path getName() const;
Status getStatus() const;
NodeStatus getStatus() const;
bool getAttributes(Attributes*);
bool open();
@ -118,7 +118,7 @@ private:
Path mPath;
String mName;
void *mHandle;
Status mStatus;
NodeStatus mStatus;
Win32Directory(const Path &path,String name);

View file

@ -21,7 +21,6 @@
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "platform/event.h"
#include "platformWin32/platformWin32.h"
#include "platformWin32/winConsole.h"
#include "platformWin32/winDirectInput.h"
@ -312,18 +311,10 @@ S32 main(S32 argc, const char **argv)
//--------------------------------------
#include "unit/test.h"
#include "app/mainLoop.h"
S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
{
#if 0
// Run a unit test.
StandardMainLoop::initCore();
UnitTesting::TestRun tr;
tr.test("Platform", true);
#else
Vector<char *> argv( __FILE__, __LINE__ );
char moduleName[256];
@ -351,7 +342,7 @@ S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
// Add the word to the argument list.
if (*word)
{
int len = ptr - word;
S32 len = ptr - word;
char *arg = (char *) dMalloc(len + 1);
dStrncpy(arg, word, len);
arg[len] = 0;
@ -367,19 +358,18 @@ S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
dFree(argv[j]);
return retVal;
#endif
}
#else //TORQUE_SHARED
extern "C"
{
bool torque_engineinit(int argc, const char **argv);
int torque_enginetick();
bool torque_engineinit(S32 argc, const char **argv);
S32 torque_enginetick();
bool torque_engineshutdown();
};
int TorqueMain(int argc, const char **argv)
S32 TorqueMain(int argc, const char **argv)
{
if (!torque_engineinit(argc, argv))
return 1;
@ -443,7 +433,7 @@ S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32)
// Add the word to the argument list.
if (*word)
{
int len = ptr - word;
S32 len = ptr - word;
char *arg = (char *) dMalloc(len + 1);
dStrncpy(arg, word, len);
arg[len] = 0;
@ -500,7 +490,7 @@ bool Platform::openWebBrowser( const char* webAddress )
return( false );
}
if ( RegQueryValueEx( regKey, dT(""), NULL, NULL, (unsigned char *)sWebKey, &size ) != ERROR_SUCCESS )
if ( RegQueryValueEx( regKey, dT(""), NULL, NULL, (U8 *)sWebKey, &size ) != ERROR_SUCCESS )
{
Con::errorf( ConsoleLogEntry::General, "Platform::openWebBrowser - Failed to query the open command registry key!!!" );
return( false );