blob: c0cd30b487902a83216174cafea00b3edd40f605 [file] [log] [blame]
Reid Spencer9926c312004-09-24 23:25:19 +00001//===- Linux/TimeValue.cpp - Linux TimeValue Implementation -----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Reid Spencer and is distributed under the
6// University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file provides the Linux specific implementation of the TimeValue class.
11//
12//===----------------------------------------------------------------------===//
13
14// Include the generic Unix implementation
15#include "../Unix/Unix.h"
16#include <sys/time.h>
17
18namespace llvm {
19using namespace sys;
20
21//===----------------------------------------------------------------------===//
22//=== WARNING: Implementation here must contain only Linux specific code
23//=== and must not be generic UNIX code (see ../Unix/TimeValue.cpp)
24//===----------------------------------------------------------------------===//
25
26void TimeValue::now() {
27 struct timeval the_time;
28 timerclear(&the_time);
29 if (0 != ::gettimeofday(&the_time,0))
30 ThrowErrno("Couldn't obtain time of day");
31
32 this->set( static_cast<TimeValue::SecondsType>( the_time.tv_sec ),
Reid Spencer1fc194c2004-09-25 05:03:22 +000033 static_cast<TimeValue::NanoSecondsType>( the_time.tv_usec *
34 NANOSECONDS_PER_MICROSECOND ) );
Reid Spencer9926c312004-09-24 23:25:19 +000035}
36// vim: sw=2 smartindent smarttab tw=80 autoindent expandtab
37
38}