[llvm-commits] CVS: llvm/lib/System/Unix/TimeValue.cpp
Reid Spencer
reid at x10sys.com
Sun Nov 14 20:37:23 PST 2004
Changes in directory llvm/lib/System/Unix:
TimeValue.cpp updated: 1.2 -> 1.3
---
Log message:
Consolidate the implementation of TimeValue::now() for Unix to use the
seemingly ubiquitous gettimeofday(3) call.
---
Diffs of the changes: (+13 -0)
Index: llvm/lib/System/Unix/TimeValue.cpp
diff -u llvm/lib/System/Unix/TimeValue.cpp:1.2 llvm/lib/System/Unix/TimeValue.cpp:1.3
--- llvm/lib/System/Unix/TimeValue.cpp:1.2 Sun Nov 14 16:10:08 2004
+++ llvm/lib/System/Unix/TimeValue.cpp Sun Nov 14 22:36:35 2004
@@ -19,6 +19,7 @@
#include "Unix.h"
#include <time.h>
+#include <sys/time.h>
namespace llvm {
using namespace sys;
@@ -34,5 +35,17 @@
return result.substr(0,24);
}
+TimeValue TimeValue::now() {
+ struct timeval the_time;
+ ::timerclear(&the_time);
+ if (0 != ::gettimeofday(&the_time,0))
+ ThrowErrno("Couldn't obtain time of day");
+
+ return TimeValue(
+ static_cast<TimeValue::SecondsType>( the_time.tv_sec ),
+ static_cast<TimeValue::NanoSecondsType>( the_time.tv_usec *
+ NANOSECONDS_PER_MICROSECOND ) );
+}
+
}
// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
More information about the llvm-commits
mailing list