X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/ba379fdc102753d6be2c4d937058fe40257329fe..14957cd040308e3eeec43d26bae5d76da13fcd85:/runtime/TimeoutChecker.cpp?ds=sidebyside diff --git a/runtime/TimeoutChecker.cpp b/runtime/TimeoutChecker.cpp index 75bf37f..81a096a 100644 --- a/runtime/TimeoutChecker.cpp +++ b/runtime/TimeoutChecker.cpp @@ -33,20 +33,16 @@ #include "CallFrame.h" #include "JSGlobalObject.h" -#if PLATFORM(DARWIN) +#if OS(DARWIN) #include -#endif - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if PLATFORM(WIN_OS) +#elif OS(WINDOWS) #include +#else +#include "CurrentTime.h" #endif -#if PLATFORM(QT) -#include +#if PLATFORM(BREWMP) +#include #endif using namespace std; @@ -62,7 +58,7 @@ static const int intervalBetweenChecks = 1000; // Returns the time the current thread has spent executing, in milliseconds. static inline unsigned getCPUTime() { -#if PLATFORM(DARWIN) +#if OS(DARWIN) mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT; thread_basic_info_data_t info; @@ -75,15 +71,7 @@ static inline unsigned getCPUTime() time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000; return time; -#elif HAVE(SYS_TIME_H) - // FIXME: This should probably use getrusage with the RUSAGE_THREAD flag. - struct timeval tv; - gettimeofday(&tv, 0); - return tv.tv_sec * 1000 + tv.tv_usec / 1000; -#elif PLATFORM(QT) - QDateTime t = QDateTime::currentDateTime(); - return t.toTime_t() * 1000 + t.time().msec(); -#elif PLATFORM(WIN_OS) +#elif OS(WINDOWS) union { FILETIME fileTime; unsigned long long fileTimeAsLong; @@ -96,8 +84,24 @@ static inline unsigned getCPUTime() GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime); return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000; +#elif OS(SYMBIAN) + RThread current; + TTimeIntervalMicroSeconds cpuTime; + + TInt err = current.GetCpuTime(cpuTime); + ASSERT_WITH_MESSAGE(err == KErrNone, "GetCpuTime failed with %d", err); + return cpuTime.Int64() / 1000; +#elif PLATFORM(BREWMP) + // This function returns a continuously and linearly increasing millisecond + // timer from the time the device was powered on. + // There is only one thread in BREW, so this is enough. + return GETUPTIMEMS(); #else -#error Platform does not have getCurrentTime function + // FIXME: We should return the time the current thread has spent executing. + + // use a relative time from first call in order to avoid an overflow + static double firstTime = currentTime(); + return static_cast ((currentTime() - firstTime) * 1000); #endif }