aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/Kernel
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-09-04 14:32:18 -0700
committerBrad Davis <[email protected]>2014-09-04 14:32:18 -0700
commit32dc394487af8e4fb1b43fb852f1d5448eaf7f31 (patch)
treebe53f49e96e8e2bba1dada04197cf508b60b4eaf /LibOVR/Src/Kernel
parent85d370840fa4d49a63331a203460fe763288d417 (diff)
Updating to windows 0.4.2
Diffstat (limited to 'LibOVR/Src/Kernel')
-rw-r--r--LibOVR/Src/Kernel/OVR_Atomic.cpp4
-rw-r--r--LibOVR/Src/Kernel/OVR_Atomic.h28
-rw-r--r--LibOVR/Src/Kernel/OVR_FileFILE.cpp4
-rw-r--r--LibOVR/Src/Kernel/OVR_Lockless.cpp9
-rw-r--r--LibOVR/Src/Kernel/OVR_Lockless.h14
-rw-r--r--LibOVR/Src/Kernel/OVR_Log.cpp2
-rw-r--r--LibOVR/Src/Kernel/OVR_SharedMemory.cpp2
-rw-r--r--LibOVR/Src/Kernel/OVR_SharedMemory.h20
-rw-r--r--LibOVR/Src/Kernel/OVR_Std.cpp10
-rw-r--r--LibOVR/Src/Kernel/OVR_Std.h6
-rw-r--r--LibOVR/Src/Kernel/OVR_String.h1
-rw-r--r--LibOVR/Src/Kernel/OVR_System.cpp20
-rw-r--r--LibOVR/Src/Kernel/OVR_System.h2
-rw-r--r--LibOVR/Src/Kernel/OVR_Threads.h6
-rw-r--r--LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp3
-rw-r--r--LibOVR/Src/Kernel/OVR_Timer.cpp24
-rw-r--r--LibOVR/Src/Kernel/OVR_Types.h74
17 files changed, 148 insertions, 81 deletions
diff --git a/LibOVR/Src/Kernel/OVR_Atomic.cpp b/LibOVR/Src/Kernel/OVR_Atomic.cpp
index 9ea6e76..079792e 100644
--- a/LibOVR/Src/Kernel/OVR_Atomic.cpp
+++ b/LibOVR/Src/Kernel/OVR_Atomic.cpp
@@ -107,7 +107,7 @@ Lock* SharedLock::GetLockAddRef()
do {
oldUseCount = UseCount;
- if (oldUseCount == LockInitMarker)
+ if (oldUseCount == (int)LockInitMarker)
continue;
if (oldUseCount == 0)
@@ -137,7 +137,7 @@ void SharedLock::ReleaseLock(Lock* plock)
do {
oldUseCount = UseCount;
- OVR_ASSERT(oldUseCount != LockInitMarker);
+ OVR_ASSERT(oldUseCount != (int)LockInitMarker);
if (oldUseCount == 1)
{
diff --git a/LibOVR/Src/Kernel/OVR_Atomic.h b/LibOVR/Src/Kernel/OVR_Atomic.h
index 6ef862d..47e76e0 100644
--- a/LibOVR/Src/Kernel/OVR_Atomic.h
+++ b/LibOVR/Src/Kernel/OVR_Atomic.h
@@ -42,6 +42,10 @@ limitations under the License.
#include <pthread.h>
#endif
+#ifdef OVR_CC_MSVC
+#include <intrin.h>
+#pragma intrinsic(_ReadBarrier, _WriteBarrier, _ReadWriteBarrier)
+#endif
namespace OVR {
@@ -118,7 +122,6 @@ struct AtomicOpsRawBase
struct AcquireSync { inline AcquireSync() { } ~AcquireSync() { asm volatile("dmb\n"); } };
struct ReleaseSync { inline ReleaseSync() { asm volatile("dmb\n"); } };
-
#elif defined(OVR_CC_GNU) && (__GNUC__ >= 4)
// __sync functions are already full sync
struct FullSync { inline FullSync() { } };
@@ -138,7 +141,7 @@ struct AtomicOpsRaw_4ByteImpl : public AtomicOpsRawBase
// *** Thread - Safe Atomic Versions.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
// Use special defined for VC6, where volatile is not used and
// InterlockedCompareExchange is declared incorrectly.
@@ -403,7 +406,7 @@ struct AtomicOpsRaw_8ByteImpl : public AtomicOpsRawBase
typedef uint64_t T;
// *** Thread - Safe OS specific versions.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
// This is only for 64-bit systems.
typedef LONG64 T;
@@ -537,7 +540,22 @@ struct AtomicOpsRaw_DefImpl : public O
#else
inline static void Store_Release(volatile O_T* p, O_T val) { O_ReleaseSync sync; OVR_UNUSED(sync); *p = val; }
#endif
- inline static O_T Load_Acquire(const volatile O_T* p) { O_AcquireSync sync; OVR_UNUSED(sync); return *p; }
+ inline static O_T Load_Acquire(const volatile O_T* p)
+ {
+ O_AcquireSync sync;
+ OVR_UNUSED(sync);
+
+#if defined(OVR_CC_MSVC)
+ _ReadBarrier(); // Compiler fence and load barrier
+#elif defined(OVR_CC_INTEL)
+ __memory_barrier(); // Compiler fence
+#else
+ // GCC-compatible:
+ asm volatile ("" : : : "memory"); // Compiler fence
+#endif
+
+ return *p;
+ }
};
@@ -819,7 +837,7 @@ public:
inline void Unlock() { }
// Windows.
-#elif defined(OVR_OS_WIN32)
+#elif defined(OVR_OS_WIN32)
CRITICAL_SECTION cs;
public:
diff --git a/LibOVR/Src/Kernel/OVR_FileFILE.cpp b/LibOVR/Src/Kernel/OVR_FileFILE.cpp
index 86096a9..b2a6f68 100644
--- a/LibOVR/Src/Kernel/OVR_FileFILE.cpp
+++ b/LibOVR/Src/Kernel/OVR_FileFILE.cpp
@@ -219,7 +219,7 @@ void FILEFile::init()
else if (OpenFlags & Open_Write)
omode = "r+b";
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
SysErrorModeDisabler disabler(FileName.ToCStr());
#endif
@@ -574,7 +574,7 @@ Ptr<File> FileFILEOpen(const String& path, int flags, int mode)
// Helper function: obtain file information time.
bool SysFile::GetFileStat(FileStat* pfileStat, const String& path)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
// 64-bit implementation on Windows.
struct __stat64 fileStat;
// Stat returns 0 for success.
diff --git a/LibOVR/Src/Kernel/OVR_Lockless.cpp b/LibOVR/Src/Kernel/OVR_Lockless.cpp
index 67c9260..c227cec 100644
--- a/LibOVR/Src/Kernel/OVR_Lockless.cpp
+++ b/LibOVR/Src/Kernel/OVR_Lockless.cpp
@@ -37,7 +37,7 @@ namespace OVR { namespace LocklessTest {
const int TestIterations = 10000000;
-// Use volatile dummys to force compiler to do spinning.
+// Use volatile dummies to force compiler to do spinning.
volatile int Dummy1;
int Unused1[32];
volatile int Dummy2;
@@ -89,7 +89,7 @@ struct TestData
volatile bool FirstItemWritten = false;
-LocklessUpdater<TestData> TestDataUpdater;
+LocklessUpdater<TestData, TestData> TestDataUpdater;
// Use this lock to verify that testing algorithm is otherwise correct...
Lock TestLock;
@@ -213,13 +213,10 @@ void StartLocklessTest()
producerThread->Start();
consumerThread->Start();
- /*
while (!producerThread->IsFinished() && consumerThread->IsFinished())
{
Thread::MSleep(500);
- } */
-
- // TBD: Cleanup
+ }
}
diff --git a/LibOVR/Src/Kernel/OVR_Lockless.h b/LibOVR/Src/Kernel/OVR_Lockless.h
index 72b6b31..400b198 100644
--- a/LibOVR/Src/Kernel/OVR_Lockless.h
+++ b/LibOVR/Src/Kernel/OVR_Lockless.h
@@ -59,7 +59,7 @@ public:
OVR_COMPILER_ASSERT(sizeof(T) <= sizeof(SlotType));
}
- T GetState() const
+ T GetState() const
{
// Copy the state out, then retry with the alternate slot
// if we determine that our copy may have been partially
@@ -71,9 +71,9 @@ public:
{
// We are adding 0, only using these as atomic memory barriers, so it
// is ok to cast off the const, allowing GetState() to remain const.
- end = UpdateEnd.ExchangeAdd_Sync(0);
+ end = UpdateEnd.Load_Acquire();
state = Slots[ end & 1 ];
- begin = UpdateBegin.ExchangeAdd_Sync(0);
+ begin = UpdateBegin.Load_Acquire();
if ( begin == end ) {
break;
}
@@ -81,7 +81,7 @@ public:
// The producer is potentially blocked while only having partially
// written the update, so copy out the other slot.
state = Slots[ (begin & 1) ^ 1 ];
- final = UpdateBegin.ExchangeAdd_NoSync(0);
+ final = UpdateBegin.Load_Acquire();
if ( final == begin ) {
break;
}
@@ -100,9 +100,9 @@ public:
UpdateEnd.ExchangeAdd_Sync(1);
}
- mutable AtomicInt<int> UpdateBegin;
- mutable AtomicInt<int> UpdateEnd;
- SlotType Slots[2];
+ AtomicInt<int> UpdateBegin;
+ AtomicInt<int> UpdateEnd;
+ SlotType Slots[2];
};
diff --git a/LibOVR/Src/Kernel/OVR_Log.cpp b/LibOVR/Src/Kernel/OVR_Log.cpp
index c81845e..7266497 100644
--- a/LibOVR/Src/Kernel/OVR_Log.cpp
+++ b/LibOVR/Src/Kernel/OVR_Log.cpp
@@ -29,7 +29,7 @@ limitations under the License.
#include <stdarg.h>
#include <stdio.h>
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#elif defined(OVR_OS_ANDROID)
diff --git a/LibOVR/Src/Kernel/OVR_SharedMemory.cpp b/LibOVR/Src/Kernel/OVR_SharedMemory.cpp
index b314e58..edb7931 100644
--- a/LibOVR/Src/Kernel/OVR_SharedMemory.cpp
+++ b/LibOVR/Src/Kernel/OVR_SharedMemory.cpp
@@ -30,8 +30,6 @@ limitations under the License.
#include "OVR_String.h"
#include "OVR_Array.h"
-#undef new
-
#if defined(OVR_OS_WIN32) && !defined(OVR_FAKE_SHAREDMEMORY)
#include <Sddl.h> // ConvertStringSecurityDescriptorToSecurityDescriptor
#endif // OVR_OS_WIN32
diff --git a/LibOVR/Src/Kernel/OVR_SharedMemory.h b/LibOVR/Src/Kernel/OVR_SharedMemory.h
index d18b583..f0ecbe6 100644
--- a/LibOVR/Src/Kernel/OVR_SharedMemory.h
+++ b/LibOVR/Src/Kernel/OVR_SharedMemory.h
@@ -155,14 +155,18 @@ protected:
{
// Configure open parameters based on read-only mode
SharedMemory::OpenParameters params;
- params.globalName = name;
- // FIXME: This is a hack. We currently need to open this for read-write even when just reading from
- // it because the LocklessUpdater class technically writes to it (increments by 0).
- //params.accessMode = readOnly ? SharedMemory::AccessMode_ReadOnly : SharedMemory::AccessMode_ReadWrite;
- //params.remoteMode = SharedMemory::RemoteMode_ReadOnly;
- params.accessMode = SharedMemory::AccessMode_ReadWrite;
- params.remoteMode = SharedMemory::RemoteMode_ReadWrite;
- params.minSizeBytes = RegionSize;
+
+ // FIXME: This is a hack. We currently need to allow clients to open this for read-write even
+ // though they only need read-only access. This is because in the first 0.4 release the
+ // LocklessUpdater class technically writes to it (increments by 0) to read from the space.
+ // This was quickly corrected in 0.4.1 and we are waiting for the right time to disallow write
+ // access when everyone upgrades to 0.4.1+.
+ //params.remoteMode = SharedMemory::RemoteMode_ReadOnly;
+ params.remoteMode = SharedMemory::RemoteMode_ReadWrite;
+
+ params.globalName = name;
+ params.accessMode = readOnly ? SharedMemory::AccessMode_ReadOnly : SharedMemory::AccessMode_ReadWrite;
+ params.minSizeBytes = RegionSize;
params.openMode = readOnly ? SharedMemory::OpenMode_OpenOnly : SharedMemory::OpenMode_CreateOrOpen;
// Attempt to open the shared memory file
diff --git a/LibOVR/Src/Kernel/OVR_Std.cpp b/LibOVR/Src/Kernel/OVR_Std.cpp
index 5f47015..f9d1645 100644
--- a/LibOVR/Src/Kernel/OVR_Std.cpp
+++ b/LibOVR/Src/Kernel/OVR_Std.cpp
@@ -37,7 +37,7 @@ namespace OVR {
// Case insensitive compare implemented in platform-specific way.
int OVR_CDECL OVR_stricmp(const char* a, const char* b)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400)
return ::_stricmp(a, b);
#else
@@ -51,7 +51,7 @@ int OVR_CDECL OVR_stricmp(const char* a, const char* b)
int OVR_CDECL OVR_strnicmp(const char* a, const char* b, size_t count)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400)
return ::_strnicmp(a, b, count);
#else
@@ -122,7 +122,7 @@ wchar_t* OVR_CDECL OVR_wcscat(wchar_t* dest, size_t destsize, const wchar_t* src
size_t OVR_CDECL OVR_wcslen(const wchar_t* str)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
return wcslen(str);
#else
size_t i = 0;
@@ -134,7 +134,7 @@ size_t OVR_CDECL OVR_wcslen(const wchar_t* str)
int OVR_CDECL OVR_wcscmp(const wchar_t* a, const wchar_t* b)
{
-#if defined(OVR_OS_WIN32) || defined(OVR_OS_LINUX)
+#if defined(OVR_OS_WIN32) || defined(OVR_OS_LINUX)
return wcscmp(a, b);
#else
// not supported, use custom implementation
@@ -161,7 +161,7 @@ int OVR_CDECL OVR_wcscmp(const wchar_t* a, const wchar_t* b)
int OVR_CDECL OVR_wcsicmp(const wchar_t* a, const wchar_t* b)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400)
return ::_wcsicmp(a, b);
#else
diff --git a/LibOVR/Src/Kernel/OVR_Std.h b/LibOVR/Src/Kernel/OVR_Std.h
index d421ca7..cc2de04 100644
--- a/LibOVR/Src/Kernel/OVR_Std.h
+++ b/LibOVR/Src/Kernel/OVR_Std.h
@@ -46,7 +46,7 @@ limitations under the License.
namespace OVR {
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
inline char* OVR_CDECL OVR_itoa(int val, char *dest, size_t destsize, int radix)
{
#if defined(OVR_MSVC_SAFESTRING)
@@ -352,7 +352,7 @@ int OVR_CDECL OVR_wcsicmp(const wchar_t* a, const wchar_t* b);
inline int OVR_CDECL OVR_wcsicoll(const wchar_t* a, const wchar_t* b)
{
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
#if defined(OVR_CC_MSVC) && (OVR_CC_MSVC >= 1400)
return ::_wcsicoll(a, b);
#else
@@ -366,7 +366,7 @@ inline int OVR_CDECL OVR_wcsicoll(const wchar_t* a, const wchar_t* b)
inline int OVR_CDECL OVR_wcscoll(const wchar_t* a, const wchar_t* b)
{
-#if defined(OVR_OS_WIN32) || defined(OVR_OS_LINUX)
+#if defined(OVR_OS_WIN32) || defined(OVR_OS_LINUX)
return wcscoll(a, b);
#else
// not supported, use regular wcscmp
diff --git a/LibOVR/Src/Kernel/OVR_String.h b/LibOVR/Src/Kernel/OVR_String.h
index 25c4b68..850118a 100644
--- a/LibOVR/Src/Kernel/OVR_String.h
+++ b/LibOVR/Src/Kernel/OVR_String.h
@@ -192,6 +192,7 @@ public:
// Returns number of characters
size_t GetLength() const;
+ int GetLengthI() const { return (int)GetLength(); }
// Returns character at the specified index
uint32_t GetCharAt(size_t index) const;
diff --git a/LibOVR/Src/Kernel/OVR_System.cpp b/LibOVR/Src/Kernel/OVR_System.cpp
index 8fb93b5..1b8d801 100644
--- a/LibOVR/Src/Kernel/OVR_System.cpp
+++ b/LibOVR/Src/Kernel/OVR_System.cpp
@@ -51,25 +51,25 @@ void SystemSingletonInternal::PushDestroyCallbacks()
}
void System::DirectDisplayInitialize()
-{
+{
#ifdef OVR_OS_WIN32
// Set up display code for Windows
Win32::DisplayShim::GetInstance();
- // This code will look for the first display. If it's a display
- // that's extending the destkop, the code will assume we're in
- // compatibility mode. Compatibility mode prevents shim loading
- // and renders only to extended Rifts.
- // If we find a display and it's application exclusive,
- // we load the shim so we can render to it.
- // If no display is available, we revert to whatever the
- // driver tells us we're in
+ // This code will look for the first display. If it's a display
+ // that's extending the destkop, the code will assume we're in
+ // compatibility mode. Compatibility mode prevents shim loading
+ // and renders only to extended Rifts.
+ // If we find a display and it's application exclusive,
+ // we load the shim so we can render to it.
+ // If no display is available, we revert to whatever the
+ // driver tells us we're in
bool anyExtendedRifts = anyRiftsInExtendedMode() || Display::InCompatibilityMode( false );
Win32::DisplayShim::GetInstance().Initialize(anyExtendedRifts);
#endif
- }
+}
// Initializes System core, installing allocator.
void System::Init(Log* log, Allocator *palloc)
diff --git a/LibOVR/Src/Kernel/OVR_System.h b/LibOVR/Src/Kernel/OVR_System.h
index 3bc2254..66ecfe9 100644
--- a/LibOVR/Src/Kernel/OVR_System.h
+++ b/LibOVR/Src/Kernel/OVR_System.h
@@ -111,7 +111,7 @@ template<class T> OVR::AtomicPtr<T> OVR::SystemSingletonBase<T>::SingletonInstan
friend class OVR::SystemSingletonBase<T>; \
private: \
T(); \
- ~T(); \
+ virtual ~T(); \
virtual void OnSystemDestroy();
// Place this in the singleton class source file
diff --git a/LibOVR/Src/Kernel/OVR_Threads.h b/LibOVR/Src/Kernel/OVR_Threads.h
index 0ecc152..301b84f 100644
--- a/LibOVR/Src/Kernel/OVR_Threads.h
+++ b/LibOVR/Src/Kernel/OVR_Threads.h
@@ -325,13 +325,13 @@ public:
// and set to the return value if Run function after the thread is finished.
inline int GetExitCode() const { return ExitCode; }
// Returns an OS handle
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
void* GetOSHandle() const { return ThreadHandle; }
#else
pthread_t GetOSHandle() const { return ThreadHandle; }
#endif
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
ThreadId GetThreadId() const { return IdValue; }
#else
ThreadId GetThreadId() const { return (ThreadId)GetOSHandle(); }
@@ -369,7 +369,7 @@ protected:
int Processor;
ThreadPriority Priority;
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
void* ThreadHandle;
volatile ThreadId IdValue;
diff --git a/LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp b/LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp
index 25c4d2b..c1a368a 100644
--- a/LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp
+++ b/LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp
@@ -886,9 +886,8 @@ bool Thread::Start(ThreadState initialState)
ExitCode = 0;
SuspendCount = 0;
ThreadFlags = (initialState == Running) ? 0 : OVR_THREAD_START_SUSPENDED;
-
ThreadHandle = (HANDLE) _beginthreadex(0, (unsigned)StackSize,
- Thread_Win32StartFn, this, 0, (unsigned*)&IdValue);
+ Thread_Win32StartFn, this, 0, (unsigned*)&IdValue);
// Failed? Fail the function
if (ThreadHandle == 0)
diff --git a/LibOVR/Src/Kernel/OVR_Timer.cpp b/LibOVR/Src/Kernel/OVR_Timer.cpp
index 5269106..50f4c1f 100644
--- a/LibOVR/Src/Kernel/OVR_Timer.cpp
+++ b/LibOVR/Src/Kernel/OVR_Timer.cpp
@@ -27,7 +27,7 @@ limitations under the License.
#include "OVR_Timer.h"
#include "OVR_Log.h"
-#if defined (OVR_OS_WIN32)
+#if defined (OVR_OS_WIN32)
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <MMSystem.h>
@@ -99,7 +99,7 @@ uint64_t Timer::GetTicksNanos()
//------------------------------------------------------------------------
// *** Win32 Specific Timer
-#elif defined (OVR_OS_WIN32)
+#elif defined (OVR_OS_WIN32)
// This helper class implements high-resolution wrapper that combines timeGetTime() output
@@ -154,7 +154,6 @@ PerformanceTimer Win32_PerfTimer;
void PerformanceTimer::Initialize()
{
-
MMRESULT mmr = timeBeginPeriod(1);
OVR_ASSERT(TIMERR_NOERROR == mmr);
OVR_UNUSED(mmr);
@@ -164,13 +163,16 @@ void PerformanceTimer::Initialize()
getFrequency();
// Set Vista flag. On Vista, we can just use QPC() without all the extra work
- UsingVista = false;
- OSVERSIONINFOA vi;
- vi.dwOSVersionInfoSize = sizeof(vi);
- if (GetVersionExA(&vi))
- {
- UsingVista = vi.dwMajorVersion >= 6;
- }
+ OSVERSIONINFOEX ver;
+ ZeroMemory(&ver, sizeof(OSVERSIONINFOEX));
+ ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+ ver.dwMajorVersion = 6; // Vista+
+
+ DWORDLONG condMask = 0;
+ VER_SET_CONDITION(condMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
+
+ // VerifyVersionInfo returns true if the OS meets the conditions set above
+ UsingVista = VerifyVersionInfo(&ver, VER_MAJORVERSION, condMask) != 0;
OVR_DEBUG_LOG(("Performance timer Vista flag = %d", (int)UsingVista));
}
@@ -178,7 +180,6 @@ void PerformanceTimer::Initialize()
void PerformanceTimer::Shutdown()
{
DeleteCriticalSection(&TimeCS);
-
MMRESULT mmr = timeEndPeriod(1);
OVR_ASSERT(TIMERR_NOERROR == mmr);
OVR_UNUSED(mmr);
@@ -211,6 +212,7 @@ uint64_t PerformanceTimer::GetTimeNanos()
// Get raw value and perf counter "At the same time".
QueryPerformanceCounter(&li);
+
DWORD mmTimeMs = timeGetTime();
if (OldMMTimeMs > mmTimeMs)
MMTimeWrapCounter++;
diff --git a/LibOVR/Src/Kernel/OVR_Types.h b/LibOVR/Src/Kernel/OVR_Types.h
index 9126f78..ce8053d 100644
--- a/LibOVR/Src/Kernel/OVR_Types.h
+++ b/LibOVR/Src/Kernel/OVR_Types.h
@@ -30,6 +30,7 @@ limitations under the License.
#include "OVR_Compiler.h"
+
// Unsupported compiler configurations
#if _MSC_VER == 0x1600
# if _MSC_FULL_VER < 160040219
@@ -163,16 +164,6 @@ limitations under the License.
# define _CRTDBG_MAP_ALLOC
# include <stdlib.h>
# include <crtdbg.h>
-
-#if 0
-// Uncomment this to help debug memory leaks under Visual Studio in OVR apps only.
-// This shouldn't be defined in customer releases.
-# ifndef OVR_DEFINE_NEW
-# define OVR_DEFINE_NEW new(__FILE__, __LINE__)
-# define new OVR_DEFINE_NEW
-# endif
-#endif
-
#endif
@@ -205,7 +196,7 @@ typedef size_t UPInt;
typedef ptrdiff_t SPInt;
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
typedef char SByte; // 8 bit Integer (Byte)
typedef unsigned char UByte;
@@ -241,6 +232,15 @@ typedef int64_t SInt64;
typedef uint64_t UInt64;
#endif
+
+
+//osx PID is a signed int32 (already defined to pid_t in OSX framework)
+//linux PID is a signed int32 (already defined)
+//win32 PID is an unsigned int64
+#ifdef OVR_OS_WIN32
+//process ID representation
+typedef unsigned long pid_t;
+#endif
struct OVR_GUID
{
@@ -306,7 +306,7 @@ struct OVR_GUID
#define OVR_BIG_ENDIAN 2
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
// ***** Win32
@@ -508,7 +508,7 @@ struct OVR_GUID
#else
// Microsoft Win32 specific debugging support
-#if defined(OVR_OS_WIN32)
+#if defined(OVR_OS_WIN32)
# ifdef OVR_CPU_X86
# if defined(__cplusplus_cli)
# define OVR_DEBUG_BREAK do { __debugbreak(); } while(0)
@@ -578,6 +578,29 @@ struct OVR_GUID
#endif
+// ***** OVR_PROCESSOR_PAUSE
+//
+// Yields the processor for other hyperthreads, usually for the purpose of implementing spins and spin locks.
+//
+// Example usage:
+// while(!finished())
+// OVR_PROCESSOR_PAUSE();
+
+#if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)
+ #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG)
+ #define OVR_PROCESSOR_PAUSE() asm volatile("pause" ::: "memory") // Consumes 38-40 clocks on current Intel x86 and x64 hardware.
+ #elif defined(OVR_CC_MSVC)
+ #include <emmintrin.h>
+ #pragma intrinsic(_mm_pause) // Maps to asm pause.
+ #define OVR_PROCESSOR_PAUSE _mm_pause
+ #else
+ #define OVR_PROCESSOR_PAUSE()
+ #endif
+#else
+ #define OVR_PROCESSOR_PAUSE()
+#endif
+
+
// ------------------------------------------------------------------------
// ***** OVR_ARRAY_COUNT
//
@@ -720,5 +743,30 @@ struct OVR_GUID
//
+//-----------------------------------------------------------------------------------
+// ***** Find normal allocations
+//
+// Our allocations are all supposed to go through the OVR System Allocator, so that
+// they can be run through a game's own preferred allocator. Occasionally we will
+// accidentally introduce new code that doesn't adhere to this contract. And it
+// then becomes difficult to track down these normal allocations. This piece of
+// code makes it easy to check for normal allocations by asserting whenever they
+// happen in our code.
+
+//#define OVR_FIND_NORMAL_ALLOCATIONS
+#ifdef OVR_FIND_NORMAL_ALLOCATIONS
+
+inline void* operator new (size_t size, const char* filename, int line)
+{
+ void* ptr = new char[size];
+ OVR_ASSERT(false);
+ return ptr;
+}
+
+#define new new(__FILE__, __LINE__)
+
+#endif // OVR_FIND_NORMAL_ALLOCATIONS
+
+
#endif // OVR_Types_h