mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 858927 - Move the mozilla::TimeStamp into mozglue. r=glandium
This commit is contained in:
parent
0977cb9515
commit
aace26e2a9
@ -2449,6 +2449,28 @@ AC_PROG_GCC_TRADITIONAL
|
|||||||
AC_FUNC_MEMCMP
|
AC_FUNC_MEMCMP
|
||||||
AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r])
|
AC_CHECK_FUNCS([getc_unlocked _getc_nolock gmtime_r localtime_r])
|
||||||
|
|
||||||
|
dnl check for clock_gettime(), the CLOCK_MONOTONIC clock
|
||||||
|
AC_CACHE_CHECK(for clock_gettime(CLOCK_MONOTONIC),
|
||||||
|
ac_cv_clock_monotonic,
|
||||||
|
[for libs in "" -lrt; do
|
||||||
|
_SAVE_LIBS="$LIBS"
|
||||||
|
LIBS="$LIBS $libs"
|
||||||
|
AC_TRY_LINK([#include <time.h>],
|
||||||
|
[ struct timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts); ],
|
||||||
|
ac_cv_clock_monotonic=$libs
|
||||||
|
LIBS="$_SAVE_LIBS"
|
||||||
|
break,
|
||||||
|
ac_cv_clock_monotonic=no)
|
||||||
|
LIBS="$_SAVE_LIBS"
|
||||||
|
done])
|
||||||
|
if test "$ac_cv_clock_monotonic" != "no"; then
|
||||||
|
HAVE_CLOCK_MONOTONIC=1
|
||||||
|
REALTIME_LIBS=$ac_cv_clock_monotonic
|
||||||
|
AC_DEFINE(HAVE_CLOCK_MONOTONIC)
|
||||||
|
AC_SUBST(HAVE_CLOCK_MONOTONIC)
|
||||||
|
AC_SUBST_LIST(REALTIME_LIBS)
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Checks for math functions.
|
dnl Checks for math functions.
|
||||||
dnl ========================================================
|
dnl ========================================================
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "prenv.h"
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
@ -45,13 +46,13 @@ struct TimeStampInitialization
|
|||||||
|
|
||||||
static TimeStampInitialization sInitOnce;
|
static TimeStampInitialization sInitOnce;
|
||||||
|
|
||||||
TimeStamp
|
MFBT_API TimeStamp
|
||||||
TimeStamp::ProcessCreation(bool& aIsInconsistent)
|
TimeStamp::ProcessCreation(bool& aIsInconsistent)
|
||||||
{
|
{
|
||||||
aIsInconsistent = false;
|
aIsInconsistent = false;
|
||||||
|
|
||||||
if (sInitOnce.mProcessCreation.IsNull()) {
|
if (sInitOnce.mProcessCreation.IsNull()) {
|
||||||
char* mozAppRestart = PR_GetEnv("MOZ_APP_RESTART");
|
char* mozAppRestart = getenv("MOZ_APP_RESTART");
|
||||||
TimeStamp ts;
|
TimeStamp ts;
|
||||||
|
|
||||||
/* When calling PR_SetEnv() with an empty value the existing variable may
|
/* When calling PR_SetEnv() with an empty value the existing variable may
|
@ -12,8 +12,7 @@
|
|||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "mozilla/FloatingPoint.h"
|
#include "mozilla/FloatingPoint.h"
|
||||||
#include "mozilla/TypeTraits.h"
|
#include "mozilla/TypeTraits.h"
|
||||||
#include "nscore.h"
|
#include "mozilla/Types.h"
|
||||||
#include "nsDebug.h"
|
|
||||||
|
|
||||||
namespace IPC {
|
namespace IPC {
|
||||||
template<typename T> struct ParamTraits;
|
template<typename T> struct ParamTraits;
|
||||||
@ -39,10 +38,10 @@ class TimeStamp;
|
|||||||
class BaseTimeDurationPlatformUtils
|
class BaseTimeDurationPlatformUtils
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static double ToSeconds(int64_t aTicks);
|
static MFBT_API double ToSeconds(int64_t aTicks);
|
||||||
static double ToSecondsSigDigits(int64_t aTicks);
|
static MFBT_API double ToSecondsSigDigits(int64_t aTicks);
|
||||||
static int64_t TicksFromMilliseconds(double aMilliseconds);
|
static MFBT_API int64_t TicksFromMilliseconds(double aMilliseconds);
|
||||||
static int64_t ResolutionInTicks();
|
static MFBT_API int64_t ResolutionInTicks();
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,7 +205,6 @@ public:
|
|||||||
BaseTimeDuration operator*(const uint64_t aMultiplier) const
|
BaseTimeDuration operator*(const uint64_t aMultiplier) const
|
||||||
{
|
{
|
||||||
if (aMultiplier > INT64_MAX) {
|
if (aMultiplier > INT64_MAX) {
|
||||||
NS_WARNING("Out-of-range multiplier when multiplying BaseTimeDuration");
|
|
||||||
return Forever();
|
return Forever();
|
||||||
}
|
}
|
||||||
return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier));
|
return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier));
|
||||||
@ -428,8 +426,8 @@ public:
|
|||||||
* lower precision, usually 15.6 ms, but with very good performance benefit.
|
* lower precision, usually 15.6 ms, but with very good performance benefit.
|
||||||
* Use it for measurements of longer times, like >200ms timeouts.
|
* Use it for measurements of longer times, like >200ms timeouts.
|
||||||
*/
|
*/
|
||||||
static TimeStamp Now() { return Now(true); }
|
static MFBT_API TimeStamp Now() { return Now(true); }
|
||||||
static TimeStamp NowLoRes() { return Now(false); }
|
static MFBT_API TimeStamp NowLoRes() { return Now(false); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a timestamp representing the time when the current process was
|
* Return a timestamp representing the time when the current process was
|
||||||
@ -443,14 +441,14 @@ public:
|
|||||||
* @returns A timestamp representing the time when the process was created,
|
* @returns A timestamp representing the time when the process was created,
|
||||||
* this timestamp is always valid even when errors are reported
|
* this timestamp is always valid even when errors are reported
|
||||||
*/
|
*/
|
||||||
static TimeStamp ProcessCreation(bool& aIsInconsistent);
|
static MFBT_API TimeStamp ProcessCreation(bool& aIsInconsistent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Records a process restart. After this call ProcessCreation() will return
|
* Records a process restart. After this call ProcessCreation() will return
|
||||||
* the time when the browser was restarted instead of the actual time when
|
* the time when the browser was restarted instead of the actual time when
|
||||||
* the process was created.
|
* the process was created.
|
||||||
*/
|
*/
|
||||||
static void RecordProcessRestart();
|
static MFBT_API void RecordProcessRestart();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute the difference between two timestamps. Both must be non-null.
|
* Compute the difference between two timestamps. Both must be non-null.
|
||||||
@ -536,8 +534,8 @@ public:
|
|||||||
// two TimeStamps, or scaling TimeStamps, is nonsense and must never
|
// two TimeStamps, or scaling TimeStamps, is nonsense and must never
|
||||||
// be allowed.
|
// be allowed.
|
||||||
|
|
||||||
static nsresult Startup();
|
static MFBT_API void Startup();
|
||||||
static void Shutdown();
|
static MFBT_API void Shutdown();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct IPC::ParamTraits<mozilla::TimeStamp>;
|
friend struct IPC::ParamTraits<mozilla::TimeStamp>;
|
||||||
@ -545,7 +543,7 @@ private:
|
|||||||
|
|
||||||
MOZ_IMPLICIT TimeStamp(TimeStampValue aValue) : mValue(aValue) {}
|
MOZ_IMPLICIT TimeStamp(TimeStampValue aValue) : mValue(aValue) {}
|
||||||
|
|
||||||
static TimeStamp Now(bool aHighResolution);
|
static MFBT_API TimeStamp Now(bool aHighResolution);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the uptime of the current process in microseconds. The result
|
* Computes the uptime of the current process in microseconds. The result
|
||||||
@ -555,7 +553,7 @@ private:
|
|||||||
* @returns The number of microseconds since the calling process was started
|
* @returns The number of microseconds since the calling process was started
|
||||||
* or 0 if an error was encountered while computing the uptime
|
* or 0 if an error was encountered while computing the uptime
|
||||||
*/
|
*/
|
||||||
static uint64_t ComputeProcessUptime();
|
static MFBT_API uint64_t ComputeProcessUptime();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When built with PRIntervalTime, a value of 0 means this instance
|
* When built with PRIntervalTime, a value of 0 means this instance
|
@ -23,7 +23,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "nsDebug.h"
|
|
||||||
|
|
||||||
// Estimate of the smallest duration of time we can measure.
|
// Estimate of the smallest duration of time we can measure.
|
||||||
static uint64_t sResolution;
|
static uint64_t sResolution;
|
||||||
@ -120,11 +119,11 @@ BaseTimeDurationPlatformUtils::ResolutionInTicks()
|
|||||||
return static_cast<int64_t>(sResolution);
|
return static_cast<int64_t>(sResolution);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TimeStamp::Startup()
|
TimeStamp::Startup()
|
||||||
{
|
{
|
||||||
if (gInitialized) {
|
if (gInitialized) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mach_timebase_info_data_t timebaseInfo;
|
mach_timebase_info_data_t timebaseInfo;
|
||||||
@ -133,7 +132,7 @@ TimeStamp::Startup()
|
|||||||
// to cache the result.
|
// to cache the result.
|
||||||
kern_return_t kr = mach_timebase_info(&timebaseInfo);
|
kern_return_t kr = mach_timebase_info(&timebaseInfo);
|
||||||
if (kr != KERN_SUCCESS) {
|
if (kr != KERN_SUCCESS) {
|
||||||
NS_RUNTIMEABORT("mach_timebase_info failed");
|
MOZ_RELEASE_ASSERT(false, "mach_timebase_info failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
sNsPerTick = double(timebaseInfo.numer) / timebaseInfo.denom;
|
sNsPerTick = double(timebaseInfo.numer) / timebaseInfo.denom;
|
||||||
@ -149,7 +148,7 @@ TimeStamp::Startup()
|
|||||||
|
|
||||||
gInitialized = true;
|
gInitialized = true;
|
||||||
|
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
@ -48,10 +48,7 @@
|
|||||||
|
|
||||||
#include "mozilla/Snprintf.h"
|
#include "mozilla/Snprintf.h"
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "nsCRT.h"
|
#include <pthread.h>
|
||||||
#include "prprf.h"
|
|
||||||
#include "prthread.h"
|
|
||||||
#include "nsDebug.h"
|
|
||||||
|
|
||||||
// Estimate of the smallest duration of time we can measure.
|
// Estimate of the smallest duration of time we can measure.
|
||||||
static uint64_t sResolution;
|
static uint64_t sResolution;
|
||||||
@ -171,16 +168,16 @@ BaseTimeDurationPlatformUtils::ResolutionInTicks()
|
|||||||
|
|
||||||
static bool gInitialized = false;
|
static bool gInitialized = false;
|
||||||
|
|
||||||
nsresult
|
void
|
||||||
TimeStamp::Startup()
|
TimeStamp::Startup()
|
||||||
{
|
{
|
||||||
if (gInitialized) {
|
if (gInitialized) {
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timespec dummy;
|
struct timespec dummy;
|
||||||
if (clock_gettime(CLOCK_MONOTONIC, &dummy) != 0) {
|
if (clock_gettime(CLOCK_MONOTONIC, &dummy) != 0) {
|
||||||
NS_RUNTIMEABORT("CLOCK_MONOTONIC is absent!");
|
MOZ_CRASH("CLOCK_MONOTONIC is absent!");
|
||||||
}
|
}
|
||||||
|
|
||||||
sResolution = ClockResolutionNs();
|
sResolution = ClockResolutionNs();
|
||||||
@ -194,7 +191,7 @@ TimeStamp::Startup()
|
|||||||
|
|
||||||
gInitialized = true;
|
gInitialized = true;
|
||||||
|
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -259,7 +256,7 @@ JiffiesSinceBoot(const char* aFile)
|
|||||||
// process uptime. This value will be stored at the address pointed by aTime;
|
// process uptime. This value will be stored at the address pointed by aTime;
|
||||||
// if an error occurred 0 will be stored instead.
|
// if an error occurred 0 will be stored instead.
|
||||||
|
|
||||||
static void
|
static void*
|
||||||
ComputeProcessUptimeThread(void* aTime)
|
ComputeProcessUptimeThread(void* aTime)
|
||||||
{
|
{
|
||||||
uint64_t* uptime = static_cast<uint64_t*>(aTime);
|
uint64_t* uptime = static_cast<uint64_t*>(aTime);
|
||||||
@ -268,7 +265,7 @@ ComputeProcessUptimeThread(void* aTime)
|
|||||||
*uptime = 0;
|
*uptime = 0;
|
||||||
|
|
||||||
if (!hz) {
|
if (!hz) {
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char threadStat[40];
|
char threadStat[40];
|
||||||
@ -278,10 +275,11 @@ ComputeProcessUptimeThread(void* aTime)
|
|||||||
uint64_t selfJiffies = JiffiesSinceBoot("/proc/self/stat");
|
uint64_t selfJiffies = JiffiesSinceBoot("/proc/self/stat");
|
||||||
|
|
||||||
if (!threadJiffies || !selfJiffies) {
|
if (!threadJiffies || !selfJiffies) {
|
||||||
return;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
*uptime = ((threadJiffies - selfJiffies) * kNsPerSec) / hz;
|
*uptime = ((threadJiffies - selfJiffies) * kNsPerSec) / hz;
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Computes and returns the process uptime in us on Linux & its derivatives.
|
// Computes and returns the process uptime in us on Linux & its derivatives.
|
||||||
@ -291,15 +289,14 @@ uint64_t
|
|||||||
TimeStamp::ComputeProcessUptime()
|
TimeStamp::ComputeProcessUptime()
|
||||||
{
|
{
|
||||||
uint64_t uptime = 0;
|
uint64_t uptime = 0;
|
||||||
PRThread* thread = PR_CreateThread(PR_USER_THREAD,
|
pthread_t uptime_pthread;
|
||||||
ComputeProcessUptimeThread,
|
|
||||||
&uptime,
|
|
||||||
PR_PRIORITY_NORMAL,
|
|
||||||
PR_GLOBAL_THREAD,
|
|
||||||
PR_JOINABLE_THREAD,
|
|
||||||
0);
|
|
||||||
|
|
||||||
PR_JoinThread(thread);
|
if (pthread_create(&uptime_pthread, nullptr, ComputeProcessUptimeThread, &uptime)) {
|
||||||
|
MOZ_CRASH("Failed to create process uptime thread.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pthread_join(uptime_pthread, NULL);
|
||||||
|
|
||||||
return uptime / kNsPerUs;
|
return uptime / kNsPerUs;
|
||||||
}
|
}
|
@ -8,37 +8,30 @@
|
|||||||
// values of GetTickCount().
|
// values of GetTickCount().
|
||||||
|
|
||||||
#include "mozilla/MathAlgorithms.h"
|
#include "mozilla/MathAlgorithms.h"
|
||||||
#include "mozilla/Mutex.h"
|
|
||||||
#include "mozilla/TimeStamp.h"
|
#include "mozilla/TimeStamp.h"
|
||||||
#include "nsWindowsHelpers.h"
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <intrin.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "nsCRT.h"
|
// To enable logging define to your favorite logging API
|
||||||
#include "mozilla/Logging.h"
|
#define LOG(x)
|
||||||
#include "prprf.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <intrin.h>
|
class AutoCriticalSection
|
||||||
|
|
||||||
// Log module for mozilla::TimeStamp for Windows logging...
|
|
||||||
//
|
|
||||||
// To enable logging (see prlog.h for full details):
|
|
||||||
//
|
|
||||||
// set NSPR_LOG_MODULES=TimeStampWindows:5
|
|
||||||
// set NSPR_LOG_FILE=nspr.log
|
|
||||||
//
|
|
||||||
// this enables LogLevel::Debug level information and places all output in
|
|
||||||
// the file nspr.log
|
|
||||||
static PRLogModuleInfo*
|
|
||||||
GetTimeStampLog()
|
|
||||||
{
|
{
|
||||||
static PRLogModuleInfo* sLog;
|
public:
|
||||||
if (!sLog) {
|
AutoCriticalSection(LPCRITICAL_SECTION aSection)
|
||||||
sLog = PR_NewLogModule("TimeStampWindows");
|
: mSection(aSection)
|
||||||
|
{
|
||||||
|
::EnterCriticalSection(mSection);
|
||||||
}
|
}
|
||||||
return sLog;
|
~AutoCriticalSection()
|
||||||
|
{
|
||||||
|
::LeaveCriticalSection(mSection);
|
||||||
}
|
}
|
||||||
#define LOG(x) MOZ_LOG(GetTimeStampLog(), mozilla::LogLevel::Debug, x)
|
private:
|
||||||
|
LPCRITICAL_SECTION mSection;
|
||||||
|
};
|
||||||
|
|
||||||
// Estimate of the smallest duration of time we can measure.
|
// Estimate of the smallest duration of time we can measure.
|
||||||
static volatile ULONGLONG sResolution;
|
static volatile ULONGLONG sResolution;
|
||||||
@ -293,7 +286,7 @@ InitResolution()
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// TimeStampValue implementation
|
// TimeStampValue implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
MFBT_API
|
||||||
TimeStampValue::TimeStampValue(ULONGLONG aGTC, ULONGLONG aQPC, bool aHasQPC)
|
TimeStampValue::TimeStampValue(ULONGLONG aGTC, ULONGLONG aQPC, bool aHasQPC)
|
||||||
: mGTC(aGTC)
|
: mGTC(aGTC)
|
||||||
, mQPC(aQPC)
|
, mQPC(aQPC)
|
||||||
@ -302,7 +295,7 @@ TimeStampValue::TimeStampValue(ULONGLONG aGTC, ULONGLONG aQPC, bool aHasQPC)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStampValue&
|
MFBT_API TimeStampValue&
|
||||||
TimeStampValue::operator+=(const int64_t aOther)
|
TimeStampValue::operator+=(const int64_t aOther)
|
||||||
{
|
{
|
||||||
mGTC += aOther;
|
mGTC += aOther;
|
||||||
@ -310,7 +303,7 @@ TimeStampValue::operator+=(const int64_t aOther)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStampValue&
|
MFBT_API TimeStampValue&
|
||||||
TimeStampValue::operator-=(const int64_t aOther)
|
TimeStampValue::operator-=(const int64_t aOther)
|
||||||
{
|
{
|
||||||
mGTC -= aOther;
|
mGTC -= aOther;
|
||||||
@ -320,7 +313,7 @@ TimeStampValue::operator-=(const int64_t aOther)
|
|||||||
|
|
||||||
// If the duration is less then two seconds, perform check of QPC stability
|
// If the duration is less then two seconds, perform check of QPC stability
|
||||||
// by comparing both GTC and QPC calculated durations of this and aOther.
|
// by comparing both GTC and QPC calculated durations of this and aOther.
|
||||||
uint64_t
|
MFBT_API uint64_t
|
||||||
TimeStampValue::CheckQPC(const TimeStampValue& aOther) const
|
TimeStampValue::CheckQPC(const TimeStampValue& aOther) const
|
||||||
{
|
{
|
||||||
uint64_t deltaGTC = mGTC - aOther.mGTC;
|
uint64_t deltaGTC = mGTC - aOther.mGTC;
|
||||||
@ -394,7 +387,7 @@ TimeStampValue::CheckQPC(const TimeStampValue& aOther) const
|
|||||||
return deltaGTC;
|
return deltaGTC;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t
|
MFBT_API uint64_t
|
||||||
TimeStampValue::operator-(const TimeStampValue& aOther) const
|
TimeStampValue::operator-(const TimeStampValue& aOther) const
|
||||||
{
|
{
|
||||||
if (mIsNull && aOther.mIsNull) {
|
if (mIsNull && aOther.mIsNull) {
|
||||||
@ -408,14 +401,14 @@ TimeStampValue::operator-(const TimeStampValue& aOther) const
|
|||||||
// TimeDuration and TimeStamp implementation
|
// TimeDuration and TimeStamp implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
double
|
MFBT_API double
|
||||||
BaseTimeDurationPlatformUtils::ToSeconds(int64_t aTicks)
|
BaseTimeDurationPlatformUtils::ToSeconds(int64_t aTicks)
|
||||||
{
|
{
|
||||||
// Converting before arithmetic avoids blocked store forward
|
// Converting before arithmetic avoids blocked store forward
|
||||||
return double(aTicks) / (double(sFrequencyPerSec) * 1000.0);
|
return double(aTicks) / (double(sFrequencyPerSec) * 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
MFBT_API double
|
||||||
BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks)
|
BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks)
|
||||||
{
|
{
|
||||||
// don't report a value < mResolution ...
|
// don't report a value < mResolution ...
|
||||||
@ -427,7 +420,7 @@ BaseTimeDurationPlatformUtils::ToSecondsSigDigits(int64_t aTicks)
|
|||||||
return double(valueSigDigs) / kNsPerSecd;
|
return double(valueSigDigs) / kNsPerSecd;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t
|
MFBT_API int64_t
|
||||||
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
|
BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
|
||||||
{
|
{
|
||||||
double result = ms2mt(aMilliseconds);
|
double result = ms2mt(aMilliseconds);
|
||||||
@ -440,7 +433,7 @@ BaseTimeDurationPlatformUtils::TicksFromMilliseconds(double aMilliseconds)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t
|
MFBT_API int64_t
|
||||||
BaseTimeDurationPlatformUtils::ResolutionInTicks()
|
BaseTimeDurationPlatformUtils::ResolutionInTicks()
|
||||||
{
|
{
|
||||||
return static_cast<int64_t>(sResolution);
|
return static_cast<int64_t>(sResolution);
|
||||||
@ -482,7 +475,7 @@ HasStableTSC()
|
|||||||
return regs[3] & (1 << 8);
|
return regs[3] & (1 << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
MFBT_API void
|
||||||
TimeStamp::Startup()
|
TimeStamp::Startup()
|
||||||
{
|
{
|
||||||
// Decide which implementation to use for the high-performance timer.
|
// Decide which implementation to use for the high-performance timer.
|
||||||
@ -508,7 +501,7 @@ TimeStamp::Startup()
|
|||||||
InitResolution();
|
InitResolution();
|
||||||
|
|
||||||
LOG(("TimeStamp: using GetTickCount"));
|
LOG(("TimeStamp: using GetTickCount"));
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sFrequencyPerSec = freq.QuadPart;
|
sFrequencyPerSec = freq.QuadPart;
|
||||||
@ -517,16 +510,16 @@ TimeStamp::Startup()
|
|||||||
InitThresholds();
|
InitThresholds();
|
||||||
InitResolution();
|
InitResolution();
|
||||||
|
|
||||||
return NS_OK;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
MFBT_API void
|
||||||
TimeStamp::Shutdown()
|
TimeStamp::Shutdown()
|
||||||
{
|
{
|
||||||
DeleteCriticalSection(&sTimeStampLock);
|
DeleteCriticalSection(&sTimeStampLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeStamp
|
MFBT_API TimeStamp
|
||||||
TimeStamp::Now(bool aHighResolution)
|
TimeStamp::Now(bool aHighResolution)
|
||||||
{
|
{
|
||||||
// sUseQPC is volatile
|
// sUseQPC is volatile
|
||||||
@ -541,7 +534,7 @@ TimeStamp::Now(bool aHighResolution)
|
|||||||
// Computes and returns the process uptime in microseconds.
|
// Computes and returns the process uptime in microseconds.
|
||||||
// Returns 0 if an error was encountered.
|
// Returns 0 if an error was encountered.
|
||||||
|
|
||||||
uint64_t
|
MFBT_API uint64_t
|
||||||
TimeStamp::ComputeProcessUptime()
|
TimeStamp::ComputeProcessUptime()
|
||||||
{
|
{
|
||||||
SYSTEMTIME nowSys;
|
SYSTEMTIME nowSys;
|
@ -7,6 +7,8 @@
|
|||||||
#ifndef mozilla_TimeStamp_windows_h
|
#ifndef mozilla_TimeStamp_windows_h
|
||||||
#define mozilla_TimeStamp_windows_h
|
#define mozilla_TimeStamp_windows_h
|
||||||
|
|
||||||
|
#include "mozilla/Types.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
class TimeStamp;
|
class TimeStamp;
|
||||||
@ -23,9 +25,9 @@ class TimeStampValue
|
|||||||
bool mHasQPC;
|
bool mHasQPC;
|
||||||
bool mIsNull;
|
bool mIsNull;
|
||||||
|
|
||||||
TimeStampValue(uint64_t aGTC, uint64_t aQPC, bool aHasQPC);
|
MFBT_API TimeStampValue(uint64_t aGTC, uint64_t aQPC, bool aHasQPC);
|
||||||
|
|
||||||
uint64_t CheckQPC(const TimeStampValue& aOther) const;
|
MFBT_API uint64_t CheckQPC(const TimeStampValue& aOther) const;
|
||||||
|
|
||||||
struct _SomethingVeryRandomHere;
|
struct _SomethingVeryRandomHere;
|
||||||
MOZ_CONSTEXPR TimeStampValue(_SomethingVeryRandomHere* aNullValue)
|
MOZ_CONSTEXPR TimeStampValue(_SomethingVeryRandomHere* aNullValue)
|
||||||
@ -37,7 +39,7 @@ class TimeStampValue
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint64_t operator-(const TimeStampValue& aOther) const;
|
MFBT_API uint64_t operator-(const TimeStampValue& aOther) const;
|
||||||
|
|
||||||
TimeStampValue operator+(const int64_t aOther) const
|
TimeStampValue operator+(const int64_t aOther) const
|
||||||
{
|
{
|
||||||
@ -47,8 +49,8 @@ public:
|
|||||||
{
|
{
|
||||||
return TimeStampValue(mGTC - aOther, mQPC - aOther, mHasQPC);
|
return TimeStampValue(mGTC - aOther, mQPC - aOther, mHasQPC);
|
||||||
}
|
}
|
||||||
TimeStampValue& operator+=(const int64_t aOther);
|
MFBT_API TimeStampValue& operator+=(const int64_t aOther);
|
||||||
TimeStampValue& operator-=(const int64_t aOther);
|
MFBT_API TimeStampValue& operator-=(const int64_t aOther);
|
||||||
|
|
||||||
bool operator<(const TimeStampValue& aOther) const
|
bool operator<(const TimeStampValue& aOther) const
|
||||||
{
|
{
|
35
mozglue/misc/moz.build
Normal file
35
mozglue/misc/moz.build
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
FINAL_LIBRARY = 'mozglue'
|
||||||
|
|
||||||
|
EXPORTS.mozilla += [
|
||||||
|
'TimeStamp.h',
|
||||||
|
]
|
||||||
|
|
||||||
|
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||||
|
EXPORTS.mozilla += [
|
||||||
|
'TimeStamp_windows.h',
|
||||||
|
]
|
||||||
|
|
||||||
|
SOURCES += [
|
||||||
|
'TimeStamp.cpp',
|
||||||
|
]
|
||||||
|
|
||||||
|
OS_LIBS += CONFIG['REALTIME_LIBS']
|
||||||
|
|
||||||
|
DEFINES['IMPL_MFBT'] = True
|
||||||
|
|
||||||
|
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||||
|
SOURCES += [
|
||||||
|
'TimeStamp_windows.cpp',
|
||||||
|
]
|
||||||
|
elif CONFIG['HAVE_CLOCK_MONOTONIC']:
|
||||||
|
SOURCES += [
|
||||||
|
'TimeStamp_posix.cpp',
|
||||||
|
]
|
||||||
|
elif CONFIG['OS_ARCH'] == 'Darwin':
|
||||||
|
SOURCES += [
|
||||||
|
'TimeStamp_darwin.cpp',
|
||||||
|
]
|
||||||
|
elif CONFIG['COMPILE_ENVIRONMENT']:
|
||||||
|
error('No TimeStamp implementation on this platform. Build will not succeed')
|
||||||
|
|
||||||
|
FAIL_ON_WARNINGS = True
|
@ -10,7 +10,10 @@ if CONFIG['MOZ_LINKER']:
|
|||||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
|
||||||
DIRS += ['android']
|
DIRS += ['android']
|
||||||
|
|
||||||
DIRS += ['build']
|
DIRS += [
|
||||||
|
'build',
|
||||||
|
'misc',
|
||||||
|
]
|
||||||
|
|
||||||
if CONFIG['MOZ_CRT']:
|
if CONFIG['MOZ_CRT']:
|
||||||
DIRS += ['crt']
|
DIRS += ['crt']
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
#include "prio.h"
|
#include "prio.h"
|
||||||
#include "private/pprio.h"
|
#include "private/pprio.h"
|
||||||
|
#include "nsDebug.h"
|
||||||
|
#include "nscore.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@ if CONFIG['OS_ARCH'] == 'WINNT':
|
|||||||
'nsIWindowsRegKey.idl',
|
'nsIWindowsRegKey.idl',
|
||||||
]
|
]
|
||||||
EXPORTS += ['nsWindowsRegKey.h']
|
EXPORTS += ['nsWindowsRegKey.h']
|
||||||
EXPORTS.mozilla += ['TimeStamp_windows.h']
|
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'nsWindowsRegKey.cpp'
|
'nsWindowsRegKey.cpp'
|
||||||
]
|
]
|
||||||
@ -63,7 +62,6 @@ EXPORTS += [
|
|||||||
|
|
||||||
EXPORTS.mozilla += [
|
EXPORTS.mozilla += [
|
||||||
'StickyTimeDuration.h',
|
'StickyTimeDuration.h',
|
||||||
'TimeStamp.h',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
UNIFIED_SOURCES += [
|
UNIFIED_SOURCES += [
|
||||||
@ -81,7 +79,6 @@ UNIFIED_SOURCES += [
|
|||||||
'nsSupportsArrayEnumerator.cpp',
|
'nsSupportsArrayEnumerator.cpp',
|
||||||
'nsSupportsPrimitives.cpp',
|
'nsSupportsPrimitives.cpp',
|
||||||
'nsVariant.cpp',
|
'nsVariant.cpp',
|
||||||
'TimeStamp.cpp',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# These two files cannot be built in unified mode because they use the
|
# These two files cannot be built in unified mode because they use the
|
||||||
@ -91,21 +88,6 @@ SOURCES += [
|
|||||||
'nsStaticNameTable.cpp',
|
'nsStaticNameTable.cpp',
|
||||||
]
|
]
|
||||||
|
|
||||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
|
||||||
SOURCES += [
|
|
||||||
'TimeStamp_windows.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['HAVE_CLOCK_MONOTONIC']:
|
|
||||||
SOURCES += [
|
|
||||||
'TimeStamp_posix.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['OS_ARCH'] == 'Darwin':
|
|
||||||
SOURCES += [
|
|
||||||
'TimeStamp_darwin.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['COMPILE_ENVIRONMENT']:
|
|
||||||
error('No TimeStamp implementation on this platform. Build will not succeed')
|
|
||||||
|
|
||||||
EXTRA_COMPONENTS += [
|
EXTRA_COMPONENTS += [
|
||||||
'nsINIProcessor.js',
|
'nsINIProcessor.js',
|
||||||
'nsINIProcessor.manifest',
|
'nsINIProcessor.manifest',
|
||||||
|
@ -43,20 +43,7 @@ xpcom_ds_src = [
|
|||||||
'nsStringEnumerator.cpp',
|
'nsStringEnumerator.cpp',
|
||||||
'nsSupportsPrimitives.cpp',
|
'nsSupportsPrimitives.cpp',
|
||||||
]
|
]
|
||||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
|
||||||
xpcom_ds_src += [
|
|
||||||
'TimeStamp_windows.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['HAVE_CLOCK_MONOTONIC']:
|
|
||||||
xpcom_ds_src += [
|
|
||||||
'TimeStamp_posix.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['OS_ARCH'] == 'Darwin':
|
|
||||||
xpcom_ds_src += [
|
|
||||||
'TimeStamp_darwin.cpp',
|
|
||||||
]
|
|
||||||
elif CONFIG['COMPILE_ENVIRONMENT']:
|
|
||||||
error('No TimeStamp implementation on this platform. Build will not succeed')
|
|
||||||
src_list += [
|
src_list += [
|
||||||
'/xpcom/ds/%s' % s for s in xpcom_ds_src
|
'/xpcom/ds/%s' % s for s in xpcom_ds_src
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user