summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixTime.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclUnixTime.c')
-rw-r--r--unix/tclUnixTime.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/unix/tclUnixTime.c b/unix/tclUnixTime.c
index adeacb68..e0c7ac8 100644
--- a/unix/tclUnixTime.c
+++ b/unix/tclUnixTime.c
@@ -61,6 +61,23 @@ Tcl_ScaleTimeProc *tclScaleTimeProcPtr = NativeScaleTime;
void *tclTimeClientData = NULL;
/*
+ * Inlined version of Tcl_GetTime.
+ */
+
+static inline void
+GetTime(
+ Tcl_Time *timePtr)
+{
+ tclGetTimeProcPtr(timePtr, tclTimeClientData);
+}
+
+static inline int
+IsTimeNative(void)
+{
+ return tclGetTimeProcPtr == NativeGetTime;
+}
+
+/*
*----------------------------------------------------------------------
*
* TclpGetSeconds --
@@ -105,8 +122,8 @@ TclpGetMicroseconds(void)
{
Tcl_Time time;
- tclGetTimeProcPtr(&time, tclTimeClientData);
- return ((long long)time.sec)*1000000 + time.usec;
+ GetTime(&time);
+ return ((long long) time.sec)*1000000 + time.usec;
}
/*
@@ -134,10 +151,10 @@ TclpGetClicks(void)
unsigned long now;
#ifdef NO_GETTOD
- if (tclGetTimeProcPtr != NativeGetTime) {
+ if (!IsTimeNative()) {
Tcl_Time time;
- tclGetTimeProcPtr(&time, tclTimeClientData);
+ GetTime(&time);
now = time.sec*1000000 + time.usec;
} else {
/*
@@ -147,12 +164,12 @@ TclpGetClicks(void)
now = (unsigned long) times(&dummy);
}
-#else
+#else /* !NO_GETTOD */
Tcl_Time time;
- tclGetTimeProcPtr(&time, tclTimeClientData);
+ GetTime(&time);
now = time.sec*1000000 + time.usec;
-#endif
+#endif /* NO_GETTOD */
return now;
}
@@ -182,17 +199,17 @@ TclpGetWideClicks(void)
{
long long now;
- if (tclGetTimeProcPtr != NativeGetTime) {
+ if (!IsTimeNative()) {
Tcl_Time time;
- tclGetTimeProcPtr(&time, tclTimeClientData);
- now = ((long long)time.sec)*1000000 + time.usec;
+ GetTime(&time);
+ now = ((long long) time.sec)*1000000 + time.usec;
} else {
#ifdef MAC_OSX_TCL
now = (long long) (mach_absolute_time() & INT64_MAX);
#else
#error Wide high-resolution clicks not implemented on this platform
-#endif
+#endif /* MAC_OSX_TCL */
}
return now;
@@ -221,7 +238,7 @@ TclpWideClicksToNanoseconds(
{
double nsec;
- if (tclGetTimeProcPtr != NativeGetTime) {
+ if (!IsTimeNative()) {
nsec = clicks * 1000;
} else {
#ifdef MAC_OSX_TCL
@@ -239,7 +256,7 @@ TclpWideClicksToNanoseconds(
}
#else
#error Wide high-resolution clicks not implemented on this platform
-#endif
+#endif /* MAC_OSX_TCL */
}
return nsec;
@@ -266,7 +283,7 @@ TclpWideClicksToNanoseconds(
double
TclpWideClickInMicrosec(void)
{
- if (tclGetTimeProcPtr != NativeGetTime) {
+ if (!IsTimeNative()) {
return 1.0;
} else {
#ifdef MAC_OSX_TCL
@@ -286,7 +303,7 @@ TclpWideClickInMicrosec(void)
}
#else
#error Wide high-resolution clicks not implemented on this platform
-#endif
+#endif /* MAC_OSX_TCL */
}
}
#endif /* TCL_WIDE_CLICKS */
@@ -315,7 +332,7 @@ void
Tcl_GetTime(
Tcl_Time *timePtr) /* Location to store time information. */
{
- tclGetTimeProcPtr(timePtr, tclTimeClientData);
+ GetTime(timePtr);
}
/*
@@ -578,7 +595,7 @@ SetTZIfNecessary(void)
} else {
ckfree(lastTZ);
}
- lastTZ = (char *)ckalloc(strlen(newTZ) + 1);
+ lastTZ = (char *) ckalloc(strlen(newTZ) + 1);
strcpy(lastTZ, newTZ);
}
Tcl_MutexUnlock(&tmMutex);