OLD | NEW |
1 //===- Unix/TimeValue.cpp - Unix TimeValue Implementation -------*- C++ -*-===// | 1 //===- Unix/TimeValue.cpp - Unix TimeValue Implementation -------*- C++ -*-===// |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the Unix specific portion of the TimeValue class. | 10 // This file implements the Unix specific portion of the TimeValue class. |
11 // | 11 // |
12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
13 | 13 |
14 //===----------------------------------------------------------------------===// | 14 //===----------------------------------------------------------------------===// |
15 //=== WARNING: Implementation here must contain only generic UNIX code that | 15 //=== WARNING: Implementation here must contain only generic UNIX code that |
16 //=== is guaranteed to work on *all* UNIX variants. | 16 //=== is guaranteed to work on *all* UNIX variants. |
17 //===----------------------------------------------------------------------===// | 17 //===----------------------------------------------------------------------===// |
18 | 18 |
19 #include "Unix.h" | 19 #include "Unix.h" |
20 | 20 |
| 21 // @LOCALMOD-START |
| 22 #ifndef timerclear |
| 23 // Newlib does not have the timer{clear,add,sub} macros |
| 24 #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) |
| 25 #endif |
| 26 // @LOCALMOD-END |
| 27 |
21 namespace llvm { | 28 namespace llvm { |
22 using namespace sys; | 29 using namespace sys; |
23 | 30 |
24 std::string TimeValue::str() const { | 31 std::string TimeValue::str() const { |
25 time_t OurTime = time_t(this->toEpochTime()); | 32 time_t OurTime = time_t(this->toEpochTime()); |
26 struct tm Storage; | 33 struct tm Storage; |
27 struct tm *LT = ::localtime_r(&OurTime, &Storage); | 34 struct tm *LT = ::localtime_r(&OurTime, &Storage); |
28 assert(LT); | 35 assert(LT); |
29 char Buffer1[sizeof("YYYY-MM-DD HH:MM:SS")]; | 36 char Buffer1[sizeof("YYYY-MM-DD HH:MM:SS")]; |
30 strftime(Buffer1, sizeof(Buffer1), "%Y-%m-%d %H:%M:%S", LT); | 37 strftime(Buffer1, sizeof(Buffer1), "%Y-%m-%d %H:%M:%S", LT); |
(...skipping 14 matching lines...) Expand all Loading... |
45 } | 52 } |
46 | 53 |
47 return TimeValue( | 54 return TimeValue( |
48 static_cast<TimeValue::SecondsType>( the_time.tv_sec + | 55 static_cast<TimeValue::SecondsType>( the_time.tv_sec + |
49 PosixZeroTimeSeconds ), | 56 PosixZeroTimeSeconds ), |
50 static_cast<TimeValue::NanoSecondsType>( the_time.tv_usec * | 57 static_cast<TimeValue::NanoSecondsType>( the_time.tv_usec * |
51 NANOSECONDS_PER_MICROSECOND ) ); | 58 NANOSECONDS_PER_MICROSECOND ) ); |
52 } | 59 } |
53 | 60 |
54 } | 61 } |
OLD | NEW |