Changeset 10a97ad for src/libcfa
- Timestamp:
- Apr 12, 2018, 8:53:12 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
- Children:
- 07b8001
- Parents:
- 2ae8507
- Location:
- src/libcfa
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
r2ae8507 r10a97ad 11 11 ## Created On : Sun May 31 08:54:01 2015 12 12 ## Last Modified By : Peter A. Buhr 13 ## Last Modified On : T ue Apr 10 15:20:28201814 ## Update Count : 23 013 ## Last Modified On : Thu Apr 12 14:38:34 2018 14 ## Update Count : 231 15 15 ############################################################################### 16 16 … … 101 101 gmp \ 102 102 time_t.h \ 103 clock \ 103 104 bits/align.h \ 104 105 bits/containers.h \ -
src/libcfa/Makefile.in
r2ae8507 r10a97ad 265 265 concurrency/thread concurrency/kernel concurrency/monitor \ 266 266 ${shell find stdhdr -type f -printf "%p "} math gmp time_t.h \ 267 bits/align.h bits/containers.h bits/defs.h bits/debug.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) … … 438 438 gmp \ 439 439 time_t.h \ 440 clock \ 440 441 bits/align.h \ 441 442 bits/containers.h \ -
src/libcfa/iostream
r2ae8507 r10a97ad 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
r2ae8507 r10a97ad 10 10 // Created On : Wed Mar 14 23:18:57 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Apr 10 17:25:34201813 // Update Count : 62 212 // Last Modified On : Thu Apr 12 16:53:35 2018 13 // Update Count : 629 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 28 28 29 #include <time_t.h> // Duration (constructors) / Time (constructors)30 29 31 30 //######################### Duration ######################### … … 68 67 69 68 static inline Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; } 70 71 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );72 69 73 70 static inline Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; } … … 136 133 137 134 138 //######################### C time #########################139 140 static inline char * ctime( time_t tp ) { char * buf = ctime( &tp ); buf[24] = '\0'; return buf; }141 static inline char * ctime_r( time_t tp, char * buf ) { ctime_r( &tp, buf ); buf[24] = '\0'; return buf; }142 static inline tm * gmtime( time_t tp ) { return gmtime( &tp ); }143 static inline tm * gmtime_r( time_t tp, tm * result ) { return gmtime_r( &tp, result ); }144 static inline tm * localtime( time_t tp ) { return localtime( &tp ); }145 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }146 147 148 135 //######################### Time ######################### 149 136 … … 199 186 size_t strftime( char * buf, size_t size, const char * fmt, Time time ); 200 187 201 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );202 203 188 //------------------------- timeval (cont) ------------------------- 204 189 … … 215 200 } // ?{} 216 201 217 218 //######################### Clock #########################219 220 struct Clock { // private221 Duration offset; // for virtual clock: contains offset from real-time222 int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME223 };224 225 static inline void resetClock( Clock & clk ) with( clk ) {226 clocktype = CLOCK_REALTIME_COARSE;227 } // Clock::resetClock228 229 static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {230 clocktype = -1;231 offset = adj + timezone`s; // timezone (global) is (UTC - local time) in seconds232 } // resetClock233 234 static inline void ?{}( Clock & clk ) { resetClock( clk ); }235 static inline void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }236 237 static inline Duration getRes() {238 struct timespec res;239 clock_getres( CLOCK_REALTIME_COARSE, &res );240 return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;241 } // getRes242 243 static inline Time getTimeNsec() { // with nanoseconds244 timespec curr;245 clock_gettime( CLOCK_REALTIME_COARSE, &curr );246 return (Time){ curr };247 } // getTime248 249 static inline Time getTime() { // without nanoseconds250 timespec curr;251 clock_gettime( CLOCK_REALTIME_COARSE, &curr );252 curr.tv_nsec = 0;253 return (Time){ curr };254 } // getTime255 256 static inline Time getTime( Clock & clk ) with( clk ) {257 return getTime() + offset;258 } // getTime259 260 static inline Time ?()( Clock & clk ) with( clk ) { // alternative syntax261 return getTime() + offset;262 } // getTime263 264 static inline timeval getTime( Clock & clk ) {265 return (timeval){ clk() };266 } // getTime267 268 static inline tm getTime( Clock & clk ) with( clk ) {269 tm ret;270 localtime_r( getTime( clk ).tv_sec, &ret );271 return ret;272 } // getTime273 274 202 // Local Variables: // 275 203 // mode: c // -
src/libcfa/time.c
r2ae8507 r10a97ad 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.