Darwin/Lion fixes.
Integrate Linux and Unicode fixes from Matthaus.
This commit is contained in:
parent
d36f68fd66
commit
9609d1e2fd
@ -18,7 +18,7 @@ SET(CORE_SRCS
|
||||
Stream.h
|
||||
StdStream.h
|
||||
TextWriter.h TextWriter.cpp
|
||||
Timer.h
|
||||
Timer.h Timer.cpp
|
||||
Utils.h)
|
||||
|
||||
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
@ -763,19 +763,19 @@ bool debug::attachToDebugger()
|
||||
if (isDebuggerPresent() == FALSE) {
|
||||
Path process(1024);
|
||||
process.copy("\"");
|
||||
GetSystemDirectory(process.str() + 1, 1024 - 1);
|
||||
GetSystemDirectoryA(process.str() + 1, 1024 - 1);
|
||||
|
||||
process.appendSeparator();
|
||||
|
||||
process.appendFormat("VSJitDebugger.exe\" -p %lu", ::GetCurrentProcessId());
|
||||
|
||||
STARTUPINFO sSi;
|
||||
STARTUPINFOA sSi;
|
||||
memset(&sSi, 0, sizeof(sSi));
|
||||
|
||||
PROCESS_INFORMATION sPi;
|
||||
memset(&sPi, 0, sizeof(sPi));
|
||||
|
||||
BOOL b = CreateProcess(NULL, process.str(), NULL, NULL, FALSE, 0, NULL, NULL, &sSi, &sPi);
|
||||
BOOL b = CreateProcessA(NULL, process.str(), NULL, NULL, FALSE, 0, NULL, NULL, &sSi, &sPi);
|
||||
if (b != FALSE) {
|
||||
::WaitForSingleObject(sPi.hProcess, INFINITE);
|
||||
|
||||
@ -802,4 +802,4 @@ bool debug::attachToDebugger()
|
||||
#endif // NV_OS_WIN32
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#endif
|
||||
|
||||
#include <stdint.h> // uint8_t, int8_t, ... uintptr_t
|
||||
#include <cstddef> // operator new, size_t, NULL
|
||||
//#include <cstddef> // operator new, size_t, NULL
|
||||
|
||||
// Function linkage
|
||||
#define DLL_IMPORT
|
||||
|
44
src/nvcore/Timer.cpp
Normal file
44
src/nvcore/Timer.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
// This code is in the public domain -- castano@gmail.com
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
using namespace nv;
|
||||
|
||||
|
||||
#if NV_OS_WIN32
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h> // QueryPerformanceFrequency, QueryPerformanceCounter
|
||||
|
||||
|
||||
uint64 nv::systemClockFrequency()
|
||||
{
|
||||
uint64 frequency;
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*) &frequency);
|
||||
return frequency;
|
||||
}
|
||||
|
||||
uint64 nv::systemClock()
|
||||
{
|
||||
uint64 counter;
|
||||
QueryPerformanceCounter((LARGE_INTEGER*) &counter);
|
||||
return counter;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <time.h> // clock
|
||||
|
||||
uint64 nv::systemClockFrequency()
|
||||
{
|
||||
return CLOCKS_PER_SEC;
|
||||
}
|
||||
|
||||
uint64 nv::systemClock()
|
||||
{
|
||||
return clock();
|
||||
}
|
||||
|
||||
#endif
|
@ -6,60 +6,44 @@
|
||||
|
||||
#include "nvcore.h"
|
||||
|
||||
#if 1
|
||||
|
||||
#include <time.h> //clock
|
||||
|
||||
namespace nv {
|
||||
|
||||
#if NV_CC_MSVC
|
||||
NV_FORCEINLINE uint64 fastCpuClock() { return rdtsc(); }
|
||||
#elif NV_CC_GNUC && NV_CPU_X86
|
||||
NV_FORCEINLINE uint64 fastCpuClock() {
|
||||
uint64 val;
|
||||
__asm__ volatile (".byte 0x0f, 0x31" : "=A" (val));
|
||||
return val;
|
||||
}
|
||||
#elif NV_CC_GNUC && NV_CPU_X86_64
|
||||
NV_FORCEINLINE uint64 fastCpuClock() {
|
||||
uint hi, lo;
|
||||
__asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
|
||||
return uint64(lo) | (uint64(hi) << 32);
|
||||
}
|
||||
#else
|
||||
NV_FORCEINLINE uint64 fastCpuClock() { return 0; }
|
||||
#endif
|
||||
|
||||
uint64 systemClockFrequency();
|
||||
uint64 systemClock();
|
||||
|
||||
class NVCORE_CLASS Timer
|
||||
{
|
||||
public:
|
||||
Timer() {}
|
||||
|
||||
void start() { m_start = clock(); }
|
||||
void stop() { m_stop = clock(); }
|
||||
void start() { m_start = systemClock(); }
|
||||
void stop() { m_stop = systemClock(); }
|
||||
|
||||
float elapsed() const { return float(m_stop - m_start) / CLOCKS_PER_SEC; }
|
||||
float elapsed() const { return float(m_stop - m_start) / systemClockFrequency(); }
|
||||
|
||||
private:
|
||||
clock_t m_start;
|
||||
clock_t m_stop;
|
||||
uint64 m_start;
|
||||
uint64 m_stop;
|
||||
};
|
||||
|
||||
} // nv namespace
|
||||
|
||||
#else
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
class NVCORE_CLASS Timer
|
||||
{
|
||||
public:
|
||||
Timer() {
|
||||
// get the tick frequency from the OS
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*) &m_frequency);
|
||||
}
|
||||
|
||||
void start() { QueryPerformanceCounter((LARGE_INTEGER*) &m_start); }
|
||||
void stop() { QueryPerformanceCounter((LARGE_INTEGER*) &m_stop); }
|
||||
|
||||
int elapsed() const {
|
||||
return (int)1000 * ((double)m_stop.QuadPart - (double)m_start.QuadPart) / (double)m_frequency.QuadPart;
|
||||
}
|
||||
|
||||
private:
|
||||
LARGE_INTEGER m_frequency;
|
||||
LARGE_INTEGER m_start;
|
||||
LARGE_INTEGER m_stop;
|
||||
|
||||
};
|
||||
|
||||
#endif // 0
|
||||
|
||||
|
||||
|
||||
#endif // NV_CORE_TIMER_H
|
||||
|
@ -84,9 +84,7 @@
|
||||
// Compiler:
|
||||
// NV_CC_GNUC
|
||||
// NV_CC_MSVC
|
||||
// @@ NV_CC_MSVC6
|
||||
// @@ NV_CC_MSVC7
|
||||
// @@ NV_CC_MSVC8
|
||||
// NV_CC_CLANG
|
||||
|
||||
#if defined POSH_COMPILER_CLANG
|
||||
# define NV_CC_CLANG 1
|
||||
@ -148,7 +146,7 @@ typedef uint32 uint;
|
||||
#define NV_FORBID_COPY(C) \
|
||||
private: \
|
||||
C( const C & ); \
|
||||
C &operator=( const C & );
|
||||
C &operator=( const C & )
|
||||
|
||||
|
||||
// Disable dynamic allocation on the heap.
|
||||
@ -156,7 +154,7 @@ typedef uint32 uint;
|
||||
#define NV_FORBID_HEAPALLOC() \
|
||||
private: \
|
||||
void *operator new(size_t size); \
|
||||
void *operator new[](size_t size);
|
||||
void *operator new[](size_t size)
|
||||
//static void *operator new(size_t size); \
|
||||
//static void *operator new[](size_t size);
|
||||
|
||||
@ -218,7 +216,7 @@ NV_COMPILER_CHECK(sizeof(uint32) == 4);
|
||||
NV_STRING_JOIN2(AtStartup_, __LINE__)() { some_code; } \
|
||||
} \
|
||||
NV_STRING_JOIN3(AtStartup_, __LINE__, Instance); \
|
||||
};
|
||||
}
|
||||
|
||||
// Indicate the compiler that the parameter is not used to suppress compier warnings.
|
||||
#define NV_UNUSED(a) ((a)=(a))
|
||||
|
Loading…
Reference in New Issue
Block a user