Changes in src/libcfa/clock [bbe1a87:10a97adb]
- File:
-
- 1 edited
-
src/libcfa/clock (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/clock
rbbe1a87 r10a97adb 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 2 21:40:01 201813 // Update Count : 712 // Last Modified On : Thu Apr 12 16:53:31 2018 13 // Update Count : 3 14 14 // 15 15 … … 34 34 }; 35 35 36 static inline { 37 void resetClock( Clock & clk ) with( clk ) { 38 clocktype = CLOCK_REALTIME_COARSE; 39 } // Clock::resetClock 36 static inline void resetClock( Clock & clk ) with( clk ) { 37 clocktype = CLOCK_REALTIME_COARSE; 38 } // Clock::resetClock 40 39 41 void resetClock( Clock & clk, Duration adj ) with( clk ) {42 clocktype = -1;43 offset = adj + __timezone`s;// timezone (global) is (UTC - local time) in seconds44 } // resetClock40 static inline void resetClock( Clock & clk, Duration adj ) with( clk ) { 41 clocktype = -1; 42 offset = adj + timezone`s; // timezone (global) is (UTC - local time) in seconds 43 } // resetClock 45 44 46 void ?{}( Clock & clk ) { resetClock( clk ); }47 void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }45 static inline void ?{}( Clock & clk ) { resetClock( clk ); } 46 static inline void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); } 48 47 49 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 } // getRes48 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 } // getRes 54 53 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 54 static inline Time getTimeNsec() { // with nanoseconds 55 timespec curr; 56 clock_gettime( CLOCK_REALTIME_COARSE, &curr ); 57 return (Time){ curr }; 58 } // getTime 60 59 61 Time getTimeNsec() { // with nanoseconds 62 timespec curr; 63 clock_gettime( CLOCK_REALTIME, &curr ); 64 return (Time){ curr }; 65 } // getTime 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 66 66 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 67 static inline Time getTime( Clock & clk ) with( clk ) { 68 return getTime() + offset; 69 } // getTime 73 70 74 Time getTime( Clock & clk ) with( clk ) { 75 return getTime() + offset;76 } // getTime71 static inline Time ?()( Clock & clk ) with( clk ) { // alternative syntax 72 return getTime() + offset; 73 } // getTime 77 74 78 Time ?()( Clock & clk ) with( clk ) { // alternative syntax 79 return getTime() + offset;80 } // getTime75 static inline timeval getTime( Clock & clk ) { 76 return (timeval){ clk() }; 77 } // getTime 81 78 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 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 92 84 93 85 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.