Changeset e3b2474 for src/libcfa/clock
- Timestamp:
- Jul 3, 2018, 3:25:56 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 638ac26
- Parents:
- c653b37 (diff), bbe1a87 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/clock
rc653b37 re3b2474 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Apr 12 16:53:31 201813 // Update Count : 312 // Last Modified On : Mon Jul 2 21:40:01 2018 13 // Update Count : 7 14 14 // 15 15 … … 34 34 }; 35 35 36 static inline void resetClock( Clock & clk ) with( clk ) { 37 clocktype = CLOCK_REALTIME_COARSE; 38 } // Clock::resetClock 36 static inline { 37 void resetClock( Clock & clk ) with( clk ) { 38 clocktype = CLOCK_REALTIME_COARSE; 39 } // Clock::resetClock 39 40 40 static inlinevoid resetClock( Clock & clk, Duration adj ) with( clk ) {41 clocktype = -1;42 offset = adj + timezone`s;// timezone (global) is (UTC - local time) in seconds43 } // resetClock41 void resetClock( Clock & clk, Duration adj ) with( clk ) { 42 clocktype = -1; 43 offset = adj + __timezone`s; // timezone (global) is (UTC - local time) in seconds 44 } // resetClock 44 45 45 static inlinevoid ?{}( Clock & clk ) { resetClock( clk ); }46 static inlinevoid ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }46 void ?{}( Clock & clk ) { resetClock( clk ); } 47 void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); } 47 48 48 static inline Duration getRes() {49 struct timespec res;50 clock_getres( CLOCK_REALTIME_COARSE, &res );51 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;52 } // getRes49 Duration getResNsec() { 50 struct timespec res; 51 clock_getres( CLOCK_REALTIME, &res ); 52 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns; 53 } // getRes 53 54 54 static inline Time getTimeNsec() { // with nanoseconds 55 timespec curr;56 clock_gettime( CLOCK_REALTIME_COARSE, &curr);57 return (Time){ curr };58 } // getTime 55 Duration getRes() { 56 struct timespec res; 57 clock_getres( CLOCK_REALTIME_COARSE, &res ); 58 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns; 59 } // getRes 59 60 60 static inline Time getTime() { // without nanoseconds 61 timespec curr; 62 clock_gettime( CLOCK_REALTIME_COARSE, &curr ); 63 curr.tv_nsec = 0; 64 return (Time){ curr }; 65 } // getTime 61 Time getTimeNsec() { // with nanoseconds 62 timespec curr; 63 clock_gettime( CLOCK_REALTIME, &curr ); 64 return (Time){ curr }; 65 } // getTime 66 66 67 static inline Time getTime( Clock & clk ) with( clk ) { 68 return getTime() + offset; 69 } // getTime 67 Time getTime() { // without nanoseconds 68 timespec curr; 69 clock_gettime( CLOCK_REALTIME_COARSE, &curr ); 70 curr.tv_nsec = 0; 71 return (Time){ curr }; 72 } // getTime 70 73 71 static inline Time ?()( Clock & clk ) with( clk ) { // alternative syntax 72 return getTime() + offset;73 } // getTime74 Time getTime( Clock & clk ) with( clk ) { 75 return getTime() + offset; 76 } // getTime 74 77 75 static inline timeval getTime( Clock & clk ) { 76 return (timeval){ clk() };77 } // getTime78 Time ?()( Clock & clk ) with( clk ) { // alternative syntax 79 return getTime() + offset; 80 } // getTime 78 81 79 static inline tm getTime( Clock & clk ) with( clk ) { 80 tm ret; 81 localtime_r( getTime( clk ).tv_sec, &ret ); 82 return ret; 83 } // getTime 82 timeval getTime( Clock & clk ) { 83 return (timeval){ clk() }; 84 } // getTime 85 86 tm getTime( Clock & clk ) with( clk ) { 87 tm ret; 88 localtime_r( getTime( clk ).tv_sec, &ret ); 89 return ret; 90 } // getTime 91 } // distribution 84 92 85 93 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.