Changeset e93f1d2 for src/libcfa
- Timestamp:
- Apr 13, 2018, 11:16:36 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 5f08961d, deaef5b
- Parents:
- 01963df (diff), bd5cf7c (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. - Location:
- src/libcfa
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
r01963df re93f1d2 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : Sun Apr 8 23:49:34 201814 ## Update Count : 2 2713 ## Last Modified On : Thu Apr 12 14:38:34 2018 14 ## Update Count : 231 15 15 ############################################################################### 16 16 … … 100 100 math \ 101 101 gmp \ 102 time_t.h \ 103 clock \ 102 104 bits/align.h \ 103 105 bits/containers.h \ -
src/libcfa/Makefile.in
r01963df re93f1d2 264 264 containers/result containers/vector concurrency/coroutine \ 265 265 concurrency/thread concurrency/kernel concurrency/monitor \ 266 ${shell find stdhdr -type f -printf "%p "} math gmp \267 bits/align.h bits/containers.h bits/defs.h bits/debug.h \266 ${shell find stdhdr -type f -printf "%p "} math gmp time_t.h \ 267 clock bits/align.h bits/containers.h bits/defs.h bits/debug.h \ 268 268 bits/locks.h concurrency/invoke.h 269 269 HEADERS = $(nobase_cfa_include_HEADERS) … … 437 437 math \ 438 438 gmp \ 439 time_t.h \ 440 clock \ 439 441 bits/align.h \ 440 442 bits/containers.h \ -
src/libcfa/concurrency/kernel
r01963df re93f1d2 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 23 17:08:20201813 // Update Count : 312 // Last Modified On : Tue Apr 10 14:46:49 2018 13 // Update Count : 10 14 14 // 15 15 … … 19 19 20 20 #include "invoke.h" 21 #include "time "21 #include "time_t.h" 22 22 23 23 extern "C" { -
src/libcfa/concurrency/kernel.c
r01963df re93f1d2 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 30 18:26:11201813 // Update Count : 2 312 // Last Modified On : Mon Apr 9 16:11:46 2018 13 // Update Count : 24 14 14 // 15 15 … … 25 25 26 26 //CFA Includes 27 #include "time" 27 28 #include "kernel_private.h" 28 29 #include "preemption.h" -
src/libcfa/iostream
r01963df re93f1d2 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jan 25 13:08:39201813 // Update Count : 1 4912 // Last Modified On : Thu Apr 12 14:34:37 2018 13 // Update Count : 150 14 14 // 15 15 … … 159 159 forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC ); 160 160 161 162 #include <time_t.h> // Duration (constructors) / Time (constructors) 163 164 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur ); 165 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time ); 166 167 161 168 // Local Variables: // 162 169 // mode: c // -
src/libcfa/time
r01963df re93f1d2 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 9 13:10:23201813 // Update Count : 6 1612 // Last Modified On : Fri Apr 13 07:51:52 2018 13 // Update Count : 634 14 14 // 15 15 … … 23 23 #include <sys/time.h> // timeval 24 24 } 25 #include < iostream> // istype/ostype25 #include <time_t.h> // Duration/Time types 26 26 27 27 enum { TIMEGRAN = 1_000_000_000LL }; // nanosecond granularity, except for timeval … … 30 30 //######################### Duration ######################### 31 31 32 struct Duration { // private33 int64_t tv; // nanoseconds34 }; // Duration35 36 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }37 32 static inline void ?{}( Duration & dur, Duration d ) with( dur ) { tv = d.tv; } 38 33 39 static inline void ?{}( Duration & dur, zero_t ) with( dur ) { tv = 0; }40 34 static inline Duration ?=?( Duration & dur, zero_t ) { return dur{ 0 }; } 41 35 … … 75 69 76 70 static inline Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; } 77 78 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );79 71 80 72 static inline Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; } … … 143 135 144 136 145 //######################### C time #########################146 147 static inline char * ctime( time_t tp ) { char * buf = ctime( &tp ); buf[24] = '\0'; return buf; }148 static inline char * ctime_r( time_t tp, char * buf ) { ctime_r( &tp, buf ); buf[24] = '\0'; return buf; }149 static inline tm * gmtime( time_t tp ) { return gmtime( &tp ); }150 static inline tm * gmtime_r( time_t tp, tm * result ) { return gmtime_r( &tp, result ); }151 static inline tm * localtime( time_t tp ) { return localtime( &tp ); }152 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }153 154 155 137 //######################### Time ######################### 156 138 157 struct Time { // private 158 uint64_t tv; // nanoseconds since UNIX epoch 159 }; // Time 160 161 static inline void ?{}( Time & t ) with( t ) { tv = 0; } // fast 162 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 ); // slow 163 164 static inline void ?{}( Time & t, zero_t ) { t.tv = 0; } 165 static inline Time ?=?( Time & t, zero_t ) { return t{ 0 }; } 166 167 static inline void ?{}( Time & time, timeval t ) with( time ) { 168 tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; 169 } // Time 139 static inline void ?{}( Time & time, Time t ) with( time ) { tv = t.tv; } 140 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 ); 141 static inline void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; } 142 143 static inline Time ?=?( Time & time, zero_t ) { return time{ 0 }; } 170 144 171 145 static inline Time ?=?( Time & time, timeval t ) with( time ) { … … 214 188 size_t strftime( char * buf, size_t size, const char * fmt, Time time ); 215 189 216 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );217 218 190 //------------------------- timeval (cont) ------------------------- 219 191 … … 230 202 } // ?{} 231 203 232 233 //######################### Clock #########################234 235 struct Clock { // private236 Duration offset; // for virtual clock: contains offset from real-time237 int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME238 };239 240 static inline void resetClock( Clock & clk ) with( clk ) {241 clocktype = CLOCK_REALTIME_COARSE;242 } // Clock::resetClock243 244 static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {245 clocktype = -1;246 offset = adj + timezone`s; // timezone (global) is (UTC - local time) in seconds247 } // resetClock248 249 static inline void ?{}( Clock & clk ) {250 resetClock( clk );251 } // Clock252 253 static inline void ?{}( Clock & clk, Duration adj ) {254 resetClock( clk, adj );255 } // Clock256 257 static inline Duration getRes() {258 struct timespec res;259 clock_getres( CLOCK_REALTIME_COARSE, &res );260 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;261 } // getRes262 263 static inline Time getTimeNsec() { // with nanoseconds264 timespec curr;265 clock_gettime( CLOCK_REALTIME_COARSE, &curr );266 return (Time){ curr };267 } // getTime268 269 static inline Time getTime() { // without nanoseconds270 timespec curr;271 clock_gettime( CLOCK_REALTIME_COARSE, &curr );272 curr.tv_nsec = 0;273 return (Time){ curr };274 } // getTime275 276 static inline Time getTime( Clock & clk ) with( clk ) {277 return getTime() + offset;278 } // getTime279 280 static inline Time ?()( Clock & clk ) with( clk ) { // alternative syntax281 return getTime() + offset;282 } // getTime283 284 static inline timeval getTime( Clock & clk ) {285 return (timeval){ clk() };286 } // getTime287 288 static inline tm getTime( Clock & clk ) with( clk ) {289 tm ret;290 localtime_r( getTime( clk ).tv_sec, &ret );291 return ret;292 } // getTime293 294 204 // Local Variables: // 295 205 // mode: c // -
src/libcfa/time.c
r01963df re93f1d2 10 10 // Created On : Tue Mar 27 13:33:14 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Apr 1 17:30:08201813 // Update Count : 2 112 // Last Modified On : Thu Apr 12 14:41:00 2018 13 // Update Count : 22 14 14 // 15 15 16 16 #include "time" 17 #include "iostream" 17 18 #include <stdio.h> // snprintf 18 19
Note:
See TracChangeset
for help on using the changeset viewer.