aboutsummaryrefslogtreecommitdiffstats
path: root/test/spass/clock.c
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2014-11-24 16:31:33 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2014-11-24 16:31:33 +0100
commit794ae6fb64e89175b40288369011f4fc51e0ac53 (patch)
tree3e0d562f15ae2e2ecbbfc4388a2010c7597d47bf /test/spass/clock.c
parent6fb31c8a00e67f5a91983fe92f6df95d5f54a0c1 (diff)
downloadcompcert-kvx-794ae6fb64e89175b40288369011f4fc51e0ac53.tar.gz
compcert-kvx-794ae6fb64e89175b40288369011f4fc51e0ac53.zip
Use gettimeofday() instead of obsolete ftime().
(Patch by Daniel Dickman.)
Diffstat (limited to 'test/spass/clock.c')
-rw-r--r--test/spass/clock.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/test/spass/clock.c b/test/spass/clock.c
index 7106669a..d9472338 100644
--- a/test/spass/clock.c
+++ b/test/spass/clock.c
@@ -104,7 +104,7 @@ void clock_StartCounter(CLOCK_CLOCKS ClockCounter)
**********************************************************/
{
#ifndef CLOCK_NO_TIMING
- ftime(&(clock_Counters[ClockCounter]));
+ gettimeofday(&(clock_Counters[ClockCounter]), NULL);
#endif
}
@@ -121,7 +121,7 @@ void clock_StopPassedTime(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
+ gettimeofday(&newtime, NULL);
clock_Akku[ClockCounter] = clock_GetSeconds(ClockCounter);
#endif
}
@@ -139,7 +139,7 @@ void clock_StopAddPassedTime(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
+ gettimeofday(&newtime, NULL);
clock_Akku[ClockCounter] += clock_GetSeconds(ClockCounter);
#endif
}
@@ -157,13 +157,21 @@ float clock_GetSeconds(CLOCK_CLOCKS ClockCounter)
{
#ifndef CLOCK_NO_TIMING
CLOCK_TMS newtime;
- ftime(&newtime);
- return ((float) (newtime.time - clock_Counters[ClockCounter].time)
- + (((newtime.millitm - clock_Counters[ClockCounter].millitm))
- /(float)1000));
-#else
+ time_t seconds_passed;
+ long microseconds_passed;
+
+ gettimeofday(&newtime, NULL);
+
+ seconds_passed = newtime.tv_sec - clock_Counters[ClockCounter].tv_sec;
+ microseconds_passed = newtime.tv_usec - clock_Counters[ClockCounter].tv_usec;
+
+ return ((float) seconds_passed
+ + (microseconds_passed /(float)1000000));
+
+#else /* CLOCK_NO_TIMING */
return 0;
-#endif
+#endif /* ! CLOCK_NO_TIMING */
+
}
#ifdef WIN