summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/tclCmdMZ.c4
-rw-r--r--generic/tclInt.h1
-rw-r--r--generic/tclInterp.c43
-rw-r--r--generic/tclTimer.c14
4 files changed, 50 insertions, 12 deletions
diff --git a/generic/tclCmdMZ.c b/generic/tclCmdMZ.c
index 885a0bc..cf7c686 100644
--- a/generic/tclCmdMZ.c
+++ b/generic/tclCmdMZ.c
@@ -4141,7 +4141,7 @@ Tcl_TimeObjCmd(
objPtr = objv[1];
i = count;
#ifndef TCL_WIDE_CLICKS
- Tcl_GetTime(&start);
+ TclpGetMonotonicTime(&start);
#else
start = TclpGetWideClicks();
#endif
@@ -4152,7 +4152,7 @@ Tcl_TimeObjCmd(
}
}
#ifndef TCL_WIDE_CLICKS
- Tcl_GetTime(&stop);
+ TclpGetMonotonicTime(&stop);
totalMicroSec = ((double) (stop.sec - start.sec)) * 1.0e6
+ (stop.usec - start.usec);
#else
diff --git a/generic/tclInt.h b/generic/tclInt.h
index da1b5c5..bb67ba0 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -3183,6 +3183,7 @@ MODULE_SCOPE void TclpThreadSetMasterTSD(void *tsdKeyPtr, void *ptr);
MODULE_SCOPE void * TclpThreadGetMasterTSD(void *tsdKeyPtr);
MODULE_SCOPE void TclErrorStackResetIf(Tcl_Interp *interp, const char *msg, int length);
+MODULE_SCOPE int TclpGetMonotonicTime(Tcl_Time *timePtr);
/*
*----------------------------------------------------------------
diff --git a/generic/tclInterp.c b/generic/tclInterp.c
index a2de658..6c7ab64 100644
--- a/generic/tclInterp.c
+++ b/generic/tclInterp.c
@@ -3393,7 +3393,7 @@ Tcl_LimitCheck(
(ticker % iPtr->limit.timeGranularity == 0))) {
Tcl_Time now;
- Tcl_GetTime(&now);
+ TclpGetMonotonicTime(&now);
if (iPtr->limit.time.sec < now.sec ||
(iPtr->limit.time.sec == now.sec &&
iPtr->limit.time.usec < now.usec)) {
@@ -3948,7 +3948,25 @@ Tcl_LimitSetTime(
Tcl_Time *timeLimitPtr)
{
Interp *iPtr = (Interp *) interp;
- Tcl_Time nextMoment;
+ Tcl_Time nextMoment, mono, real, limit;
+
+ if (TclpGetMonotonicTime(&mono)) {
+ Tcl_GetTime(&real);
+ limit = *timeLimitPtr;
+ limit.sec -= real.sec;
+ limit.usec -= real.usec;
+ if (limit.usec < 0) {
+ limit.sec -= 1;
+ limit.usec += 1000000;
+ }
+ limit.sec += mono.sec;
+ limit.usec += mono.usec;
+ if (limit.usec >= 1000000) {
+ limit.sec += 1;
+ limit.usec -= 1000000;
+ }
+ timeLimitPtr = &limit;
+ }
memcpy(&iPtr->limit.time, timeLimitPtr, sizeof(Tcl_Time));
if (iPtr->limit.timeEvent != NULL) {
@@ -4033,7 +4051,26 @@ Tcl_LimitGetTime(
Tcl_Time *timeLimitPtr)
{
Interp *iPtr = (Interp *) interp;
-
+ Tcl_Time mono, real, limit;
+
+ if (TclpGetMonotonicTime(&mono)) {
+ Tcl_GetTime(&real);
+ limit = iPtr->limit.time;
+ limit.sec -= mono.sec;
+ limit.usec -= mono.usec;
+ if (limit.usec < 0) {
+ limit.sec -= 1;
+ limit.usec += 1000000;
+ }
+ limit.sec += real.sec;
+ limit.usec += real.usec;
+ if (limit.usec >= 1000000) {
+ limit.sec += 1;
+ limit.usec -= 1000000;
+ }
+ memcpy(timeLimitPtr, &limit, sizeof(Tcl_Time));
+ return;
+ }
memcpy(timeLimitPtr, &iPtr->limit.time, sizeof(Tcl_Time));
}
diff --git a/generic/tclTimer.c b/generic/tclTimer.c
index 6d3938b..adc36ce 100644
--- a/generic/tclTimer.c
+++ b/generic/tclTimer.c
@@ -259,7 +259,7 @@ Tcl_CreateTimerHandler(
* Compute when the event should fire.
*/
- Tcl_GetTime(&time);
+ TclpGetMonotonicTime(&time);
time.sec += milliseconds/1000;
time.usec += (milliseconds%1000)*1000;
if (time.usec >= 1000000) {
@@ -417,7 +417,7 @@ TimerSetupProc(
* Compute the timeout for the next timer on the list.
*/
- Tcl_GetTime(&blockTime);
+ TclpGetMonotonicTime(&blockTime);
blockTime.sec = tsdPtr->firstTimerHandlerPtr->time.sec - blockTime.sec;
blockTime.usec = tsdPtr->firstTimerHandlerPtr->time.usec -
blockTime.usec;
@@ -468,7 +468,7 @@ TimerCheckProc(
* Compute the timeout for the next timer on the list.
*/
- Tcl_GetTime(&blockTime);
+ TclpGetMonotonicTime(&blockTime);
blockTime.sec = tsdPtr->firstTimerHandlerPtr->time.sec - blockTime.sec;
blockTime.usec = tsdPtr->firstTimerHandlerPtr->time.usec -
blockTime.usec;
@@ -564,7 +564,7 @@ TimerHandlerEventProc(
tsdPtr->timerPending = 0;
currentTimerId = tsdPtr->lastTimerId;
- Tcl_GetTime(&time);
+ TclpGetMonotonicTime(&time);
while (1) {
nextPtrPtr = &tsdPtr->firstTimerHandlerPtr;
timerHandlerPtr = tsdPtr->firstTimerHandlerPtr;
@@ -872,7 +872,7 @@ Tcl_AfterObjCmd(
afterPtr->id = tsdPtr->afterId;
tsdPtr->afterId += 1;
- Tcl_GetTime(&wakeup);
+ TclpGetMonotonicTime(&wakeup);
wakeup.sec += (long)(ms / 1000);
wakeup.usec += ((long)(ms % 1000)) * 1000;
if (wakeup.usec > 1000000) {
@@ -1017,7 +1017,7 @@ AfterDelay(
Tcl_Time endTime, now;
Tcl_WideInt diff;
- Tcl_GetTime(&now);
+ TclpGetMonotonicTime(&now);
endTime = now;
endTime.sec += (long)(ms/1000);
endTime.usec += ((int)(ms%1000))*1000;
@@ -1083,7 +1083,7 @@ AfterDelay(
return TCL_ERROR;
}
}
- Tcl_GetTime(&now);
+ TclpGetMonotonicTime(&now);
} while (TCL_TIME_BEFORE(now, endTime));
return TCL_OK;
}