Changes in libcfa/src/clock.hfa [54b3fde:4834563]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/clock.hfa
r54b3fde r4834563 10 10 // Created On : Thu Apr 12 14:36:06 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 13 21:21:13 201913 // Update Count : 812 // Last Modified On : Mon Jan 6 12:49:58 2020 13 // Update Count : 9 14 14 // 15 15 16 16 #include <time.hfa> 17 18 17 19 18 //######################### C time ######################### … … 26 25 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); } 27 26 28 29 27 //######################### Clock ######################### 30 28 31 29 struct Clock { // private 32 30 Duration offset; // for virtual clock: contains offset from real-time 33 int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME34 31 }; 35 32 36 33 static inline { 37 void resetClock( Clock & clk ) with( clk ) {38 clocktype = CLOCK_REALTIME_COARSE;39 } // Clock::resetClock40 41 34 void resetClock( Clock & clk, Duration adj ) with( clk ) { 42 clocktype = -1;43 35 offset = adj + __timezone`s; // timezone (global) is (UTC - local time) in seconds 44 36 } // resetClock 45 37 46 void ?{}( Clock & clk ) { resetClock( clk ); }47 38 void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); } 48 39 … … 89 80 return ret; 90 81 } // getTime 82 83 Time getCPUTime() { 84 timespec ts; 85 clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts ); 86 return (Time){ ts }; 87 } // getCPUTime 91 88 } // distribution 92 89
Note: See TracChangeset
for help on using the changeset viewer.