зеркало из https://github.com/mozilla/gecko-dev.git
Bug 461841: Unshuffle system-specific definitions of PRMJ_Now. r=crowder
Every piece of the body of js/src/prmjtime.cpp's PRMJ_Now function was in a preprocessor conditional --- it was three entirely independent implementations shuffled together. Unshuffling them prepares the way for adding a new WinCE definition.
This commit is contained in:
Родитель
b6f597421e
Коммит
4d667f4d63
|
@ -265,6 +265,46 @@ static PRCallOnceType calibrationOnce = { 0 };
|
||||||
|
|
||||||
#endif /* XP_WIN */
|
#endif /* XP_WIN */
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(XP_OS2)
|
||||||
|
JSInt64
|
||||||
|
PRMJ_Now(void)
|
||||||
|
{
|
||||||
|
JSInt64 s, us, ms2us, s2us;
|
||||||
|
struct timeb b;
|
||||||
|
|
||||||
|
ftime(&b);
|
||||||
|
JSLL_UI2L(ms2us, PRMJ_USEC_PER_MSEC);
|
||||||
|
JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
|
||||||
|
JSLL_UI2L(s, b.time);
|
||||||
|
JSLL_UI2L(us, b.millitm);
|
||||||
|
JSLL_MUL(us, us, ms2us);
|
||||||
|
JSLL_MUL(s, s, s2us);
|
||||||
|
JSLL_ADD(s, s, us);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(XP_UNIX) || defined(XP_BEOS)
|
||||||
|
JSInt64
|
||||||
|
PRMJ_Now(void)
|
||||||
|
{
|
||||||
|
struct timeval tv;
|
||||||
|
JSInt64 s, us, s2us;
|
||||||
|
|
||||||
|
#ifdef _SVID_GETTOD /* Defined only on Solaris, see Solaris <sys/types.h> */
|
||||||
|
gettimeofday(&tv);
|
||||||
|
#else
|
||||||
|
gettimeofday(&tv, 0);
|
||||||
|
#endif /* _SVID_GETTOD */
|
||||||
|
JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
|
||||||
|
JSLL_UI2L(s, tv.tv_sec);
|
||||||
|
JSLL_UI2L(us, tv.tv_usec);
|
||||||
|
JSLL_MUL(s, s, s2us);
|
||||||
|
JSLL_ADD(s, s, us);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined(XP_WIN)
|
||||||
/*
|
/*
|
||||||
|
|
||||||
Win32 python-esque pseudo code
|
Win32 python-esque pseudo code
|
||||||
|
@ -331,11 +371,6 @@ def PRMJ_Now():
|
||||||
JSInt64
|
JSInt64
|
||||||
PRMJ_Now(void)
|
PRMJ_Now(void)
|
||||||
{
|
{
|
||||||
#ifdef XP_OS2
|
|
||||||
JSInt64 s, us, ms2us, s2us;
|
|
||||||
struct timeb b;
|
|
||||||
#endif
|
|
||||||
#ifdef XP_WIN
|
|
||||||
static int nCalls = 0;
|
static int nCalls = 0;
|
||||||
long double lowresTime, highresTimerValue;
|
long double lowresTime, highresTimerValue;
|
||||||
FILETIME ft;
|
FILETIME ft;
|
||||||
|
@ -344,24 +379,6 @@ PRMJ_Now(void)
|
||||||
JSBool needsCalibration = JS_FALSE;
|
JSBool needsCalibration = JS_FALSE;
|
||||||
JSInt64 returnedTime;
|
JSInt64 returnedTime;
|
||||||
long double cachedOffset = 0.0;
|
long double cachedOffset = 0.0;
|
||||||
#endif
|
|
||||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
|
||||||
struct timeval tv;
|
|
||||||
JSInt64 s, us, s2us;
|
|
||||||
#endif /* XP_UNIX */
|
|
||||||
|
|
||||||
#ifdef XP_OS2
|
|
||||||
ftime(&b);
|
|
||||||
JSLL_UI2L(ms2us, PRMJ_USEC_PER_MSEC);
|
|
||||||
JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
|
|
||||||
JSLL_UI2L(s, b.time);
|
|
||||||
JSLL_UI2L(us, b.millitm);
|
|
||||||
JSLL_MUL(us, us, ms2us);
|
|
||||||
JSLL_MUL(s, s, s2us);
|
|
||||||
JSLL_ADD(s, s, us);
|
|
||||||
return s;
|
|
||||||
#endif
|
|
||||||
#ifdef XP_WIN
|
|
||||||
|
|
||||||
/* To avoid regressing startup time (where high resolution is likely
|
/* To avoid regressing startup time (where high resolution is likely
|
||||||
not needed), give the old behavior for the first few calls.
|
not needed), give the old behavior for the first few calls.
|
||||||
|
@ -488,22 +505,10 @@ PRMJ_Now(void)
|
||||||
} while (needsCalibration);
|
} while (needsCalibration);
|
||||||
|
|
||||||
return returnedTime;
|
return returnedTime;
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
|
||||||
#ifdef _SVID_GETTOD /* Defined only on Solaris, see Solaris <sys/types.h> */
|
|
||||||
gettimeofday(&tv);
|
|
||||||
#else
|
|
||||||
gettimeofday(&tv, 0);
|
|
||||||
#endif /* _SVID_GETTOD */
|
|
||||||
JSLL_UI2L(s2us, PRMJ_USEC_PER_SEC);
|
|
||||||
JSLL_UI2L(s, tv.tv_sec);
|
|
||||||
JSLL_UI2L(us, tv.tv_usec);
|
|
||||||
JSLL_MUL(s, s, s2us);
|
|
||||||
JSLL_ADD(s, s, us);
|
|
||||||
return s;
|
|
||||||
#endif /* XP_UNIX */
|
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
#error "No implementation of PRMJ_Now was selected."
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Get the DST timezone offset for the time passed in */
|
/* Get the DST timezone offset for the time passed in */
|
||||||
JSInt64
|
JSInt64
|
||||||
|
|
Загрузка…
Ссылка в новой задаче