Changeset bbe1a87 for src/libcfa/clock
- Timestamp:
- Jul 3, 2018, 9:07:31 AM (7 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:
- 9459c01, e3b2474
- Parents:
- 4c3ee8d
- File:
-
- 1 edited
-
src/libcfa/clock (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/clock
r4c3ee8d rbbe1a87 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jun 26 14:11:44201813 // Update Count : 612 // 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 inlineDuration getResNsec() {49 struct timespec res;50 clock_getres( CLOCK_REALTIME, &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 inlineDuration getRes() {55 struct timespec res;56 clock_getres( CLOCK_REALTIME_COARSE, &res );57 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;58 } // getRes55 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 getTimeNsec() {// with nanoseconds61 timespec curr;62 clock_gettime( CLOCK_REALTIME, &curr );63 return (Time){ curr };64 } // getTime61 Time getTimeNsec() { // with nanoseconds 62 timespec curr; 63 clock_gettime( CLOCK_REALTIME, &curr ); 64 return (Time){ curr }; 65 } // getTime 65 66 66 static inline Time getTime() {// without nanoseconds67 timespec curr;68 clock_gettime( CLOCK_REALTIME_COARSE, &curr );69 curr.tv_nsec = 0;70 return (Time){ curr };71 } // getTime67 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 72 73 73 static inlineTime getTime( Clock & clk ) with( clk ) {74 return getTime() + offset;75 } // getTime74 Time getTime( Clock & clk ) with( clk ) { 75 return getTime() + offset; 76 } // getTime 76 77 77 static inline Time ?()( Clock & clk ) with( clk ) {// alternative syntax78 return getTime() + offset;79 } // getTime78 Time ?()( Clock & clk ) with( clk ) { // alternative syntax 79 return getTime() + offset; 80 } // getTime 80 81 81 static inlinetimeval getTime( Clock & clk ) {82 return (timeval){ clk() };83 } // getTime82 timeval getTime( Clock & clk ) { 83 return (timeval){ clk() }; 84 } // getTime 84 85 85 static inline tm getTime( Clock & clk ) with( clk ) { 86 tm ret; 87 localtime_r( getTime( clk ).tv_sec, &ret ); 88 return ret; 89 } // getTime 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 90 92 91 93 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.