Revert to gettimeofday on posix systems. I give up.
Temporary fix for OSX in JitIL.cpp This revision should build on OSX again. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6457 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
63c35bf14a
commit
a3c46990f6
|
@ -493,15 +493,9 @@ namespace Common
|
||||||
if (timeout != INFINITE)
|
if (timeout != INFINITE)
|
||||||
{
|
{
|
||||||
memset(&wait, 0, sizeof(wait));
|
memset(&wait, 0, sizeof(wait));
|
||||||
#ifdef USE_GETTIMEOFDAY
|
|
||||||
struct timeval now;
|
struct timeval now;
|
||||||
gettimeofday(&now, NULL);
|
gettimeofday(&now, NULL);
|
||||||
wait.tv_nsec = (now.tv_usec + (timeout % 1000)) * 1000;
|
wait.tv_nsec = (now.tv_usec + (timeout % 1000)) * 1000;
|
||||||
#else
|
|
||||||
struct timespec now;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC_RAW, &now);
|
|
||||||
wait.tv_nsec = now.tv_nsec + (timeout % 1000) * 1000000;
|
|
||||||
#endif
|
|
||||||
wait.tv_sec = now.tv_sec + (timeout / 1000);
|
wait.tv_sec = now.tv_sec + (timeout / 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,14 +60,10 @@
|
||||||
#define INFINITE 0xffffffff
|
#define INFINITE 0xffffffff
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//for (clock_gettime|gettimeofday) and struct time(spec|val)
|
//for gettimeofday and struct time(spec|val)
|
||||||
#include <unistd.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#if !defined(_POSIX_TIMERS) || _POSIX_TIMERS == 0 || !defined(_POSIX_MONOTONIC_CLOCK)
|
|
||||||
#define USE_GETTIMEOFDAY
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
|
|
|
@ -22,12 +22,8 @@
|
||||||
#include <mmsystem.h>
|
#include <mmsystem.h>
|
||||||
#include <sys/timeb.h>
|
#include <sys/timeb.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
|
||||||
#if !defined(_POSIX_TIMERS) || _POSIX_TIMERS == 0 || !defined(_POSIX_MONOTONIC_CLOCK)
|
|
||||||
#define USE_GETTIMEOFDAY
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
|
@ -40,14 +36,11 @@ u32 Timer::GetTimeMs()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return timeGetTime();
|
return timeGetTime();
|
||||||
#elif defined USE_GETTIMEOFDAY
|
#else
|
||||||
|
printf("using gettimeofday\n");
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
(void)gettimeofday(&t, NULL);
|
(void)gettimeofday(&t, NULL);
|
||||||
return ((u32)(t.tv_sec * 1000 + t.tv_usec / 1000));
|
return ((u32)(t.tv_sec * 1000 + t.tv_usec / 1000));
|
||||||
#else
|
|
||||||
struct timespec t;
|
|
||||||
(void)clock_gettime(CLOCK_MONOTONIC_RAW, &t);
|
|
||||||
return ((u32)(t.tv_sec * 1000 + t.tv_nsec / 1000000));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,14 +206,10 @@ std::string Timer::GetTimeFormatted()
|
||||||
struct timeb tp;
|
struct timeb tp;
|
||||||
(void)::ftime(&tp);
|
(void)::ftime(&tp);
|
||||||
sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);
|
sprintf(formattedTime, "%s:%03i", tmp, tp.millitm);
|
||||||
#elif defined USE_GETTIMEOFDAY
|
#else
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
(void)gettimeofday(&t, NULL);
|
(void)gettimeofday(&t, NULL);
|
||||||
sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
|
sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_usec / 1000));
|
||||||
#else
|
|
||||||
struct timespec t;
|
|
||||||
(void)clock_gettime(CLOCK_REALTIME, &t);
|
|
||||||
sprintf(formattedTime, "%s:%03d", tmp, (int)(t.tv_nsec / 1000000));
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return std::string(formattedTime);
|
return std::string(formattedTime);
|
||||||
|
@ -233,12 +222,9 @@ double Timer::GetDoubleTime()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
struct timeb tp;
|
struct timeb tp;
|
||||||
(void)::ftime(&tp);
|
(void)::ftime(&tp);
|
||||||
#elif defined USE_GETTIMEOFDAY
|
#else
|
||||||
struct timeval t;
|
struct timeval t;
|
||||||
(void)gettimeofday(&t, NULL);
|
(void)gettimeofday(&t, NULL);
|
||||||
#else
|
|
||||||
struct timespec t;
|
|
||||||
(void)clock_gettime(CLOCK_REALTIME, &t);
|
|
||||||
#endif
|
#endif
|
||||||
// Get continuous timestamp
|
// Get continuous timestamp
|
||||||
u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970();
|
u64 TmpSeconds = Common::Timer::GetTimeSinceJan1970();
|
||||||
|
@ -253,10 +239,8 @@ double Timer::GetDoubleTime()
|
||||||
u32 Seconds = (u32)TmpSeconds;
|
u32 Seconds = (u32)TmpSeconds;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
double ms = tp.millitm / 1000.0 / 1000.0;
|
double ms = tp.millitm / 1000.0 / 1000.0;
|
||||||
#elif defined USE_GETTIMEOFDAY
|
|
||||||
double ms = t.tv_usec / 1000000.0;
|
|
||||||
#else
|
#else
|
||||||
double ms = t.tv_nsec / 1000000000.0;
|
double ms = t.tv_usec / 1000000.0;
|
||||||
#endif
|
#endif
|
||||||
double TmpTime = Seconds + ms;
|
double TmpTime = Seconds + ms;
|
||||||
|
|
||||||
|
|
|
@ -165,11 +165,16 @@ ps_adds1
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
static inline uint64_t __rdtsc()
|
static inline uint64_t __rdtsc()
|
||||||
{
|
{
|
||||||
|
#ifdef __linux__
|
||||||
uint32_t lo, hi;
|
uint32_t lo, hi;
|
||||||
__asm__ __volatile__ ("xorl %%eax,%%eax \n cpuid"
|
__asm__ __volatile__ ("xorl %%eax,%%eax \n cpuid"
|
||||||
::: "%rax", "%rbx", "%rcx", "%rdx");
|
::: "%rax", "%rbx", "%rcx", "%rdx");
|
||||||
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
|
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
|
||||||
return (uint64_t)hi << 32 | lo;
|
return (uint64_t)hi << 32 | lo;
|
||||||
|
#else
|
||||||
|
// TODO: Figure out what is wrong with clobbering the rbx register on OSX
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue