[6ecc079] | 1 | //
|
---|
[2a84d06d] | 2 | // Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
|
---|
[6ecc079] | 3 | //
|
---|
| 4 | // The contents of this file are covered under the licence agreement in the
|
---|
| 5 | // file "LICENCE" distributed with Cforall.
|
---|
| 6 | //
|
---|
[2a84d06d] | 7 | // time --
|
---|
[6ecc079] | 8 | //
|
---|
| 9 | // Author : Peter A. Buhr
|
---|
| 10 | // Created On : Wed Mar 14 23:18:57 2018
|
---|
| 11 | // Last Modified By : Peter A. Buhr
|
---|
[8ad6533] | 12 | // Last Modified On : Mon Apr 9 13:10:23 2018
|
---|
| 13 | // Update Count : 616
|
---|
[6ecc079] | 14 | //
|
---|
| 15 |
|
---|
| 16 | #pragma once
|
---|
| 17 |
|
---|
| 18 | // http://en.cppreference.com/w/cpp/header/chrono
|
---|
| 19 | // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0355r5.html#refcc
|
---|
| 20 |
|
---|
[2a84d06d] | 21 | #include <time.h> // timespec
|
---|
[6ecc079] | 22 | extern "C" {
|
---|
[2a84d06d] | 23 | #include <sys/time.h> // timeval
|
---|
[6ecc079] | 24 | }
|
---|
[2a84d06d] | 25 | #include <iostream> // istype/ostype
|
---|
[6ecc079] | 26 |
|
---|
[273cde6] | 27 | enum { TIMEGRAN = 1_000_000_000LL }; // nanosecond granularity, except for timeval
|
---|
[6ecc079] | 28 |
|
---|
| 29 |
|
---|
| 30 | //######################### Duration #########################
|
---|
| 31 |
|
---|
[643c6b9] | 32 | struct Duration { // private
|
---|
[bc03be3] | 33 | int64_t tv; // nanoseconds
|
---|
| 34 | }; // Duration
|
---|
[6ecc079] | 35 |
|
---|
| 36 | static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }
|
---|
| 37 | static inline void ?{}( Duration & dur, Duration d ) with( dur ) { tv = d.tv; }
|
---|
[643c6b9] | 38 |
|
---|
[2a84d06d] | 39 | static inline void ?{}( Duration & dur, zero_t ) with( dur ) { tv = 0; }
|
---|
| 40 | static inline Duration ?=?( Duration & dur, zero_t ) { return dur{ 0 }; }
|
---|
[6ecc079] | 41 |
|
---|
| 42 | static inline Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tv }; }
|
---|
| 43 | static inline Duration ?+?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv + rhs.tv }; }
|
---|
| 44 | static inline Duration ?+=?( Duration & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
|
---|
| 45 |
|
---|
| 46 | static inline Duration -?( Duration rhs ) with( rhs ) { return (Duration)@{ -tv }; }
|
---|
| 47 | static inline Duration ?-?( Duration & lhs, Duration rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
|
---|
| 48 | static inline Duration ?-=?( Duration & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
|
---|
| 49 |
|
---|
| 50 | static inline Duration ?*?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv * rhs }; }
|
---|
| 51 | static inline Duration ?*?( int64_t lhs, Duration rhs ) { return (Duration)@{ lhs * rhs.tv }; }
|
---|
| 52 | static inline Duration ?*=?( Duration & lhs, int64_t rhs ) { lhs = lhs * rhs; return lhs; }
|
---|
| 53 |
|
---|
| 54 | static inline int64_t ?/?( Duration lhs, Duration rhs ) { return lhs.tv / rhs.tv; }
|
---|
[8eb2018] | 55 | static inline Duration ?/?( Duration lhs, int64_t rhs ) { return (Duration)@{ lhs.tv / rhs }; }
|
---|
[6ecc079] | 56 | static inline Duration ?/=?( Duration & lhs, int64_t rhs ) { lhs = lhs / rhs; return lhs; }
|
---|
[643c6b9] | 57 | static inline double div( Duration lhs, Duration rhs ) { return (double)lhs.tv / (double)rhs.tv; }
|
---|
[6ecc079] | 58 |
|
---|
[2a84d06d] | 59 | static inline Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tv % rhs.tv }; }
|
---|
[9f652a1] | 60 | static inline Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; }
|
---|
[6ecc079] | 61 |
|
---|
| 62 | static inline _Bool ?==?( Duration lhs, Duration rhs ) { return lhs.tv == rhs.tv; }
|
---|
| 63 | static inline _Bool ?!=?( Duration lhs, Duration rhs ) { return lhs.tv != rhs.tv; }
|
---|
[2a84d06d] | 64 | static inline _Bool ?<? ( Duration lhs, Duration rhs ) { return lhs.tv < rhs.tv; }
|
---|
[6ecc079] | 65 | static inline _Bool ?<=?( Duration lhs, Duration rhs ) { return lhs.tv <= rhs.tv; }
|
---|
[2a84d06d] | 66 | static inline _Bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tv > rhs.tv; }
|
---|
[6ecc079] | 67 | static inline _Bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tv >= rhs.tv; }
|
---|
| 68 |
|
---|
[2a84d06d] | 69 | static inline _Bool ?==?( Duration lhs, zero_t ) { return lhs.tv == 0; }
|
---|
| 70 | static inline _Bool ?!=?( Duration lhs, zero_t ) { return lhs.tv != 0; }
|
---|
| 71 | static inline _Bool ?<? ( Duration lhs, zero_t ) { return lhs.tv < 0; }
|
---|
| 72 | static inline _Bool ?<=?( Duration lhs, zero_t ) { return lhs.tv <= 0; }
|
---|
| 73 | static inline _Bool ?>? ( Duration lhs, zero_t ) { return lhs.tv > 0; }
|
---|
| 74 | static inline _Bool ?>=?( Duration lhs, zero_t ) { return lhs.tv >= 0; }
|
---|
[6ecc079] | 75 |
|
---|
[bc03be3] | 76 | static inline Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; }
|
---|
[2a84d06d] | 77 |
|
---|
| 78 | forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
|
---|
| 79 |
|
---|
[bc03be3] | 80 | static inline Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; }
|
---|
| 81 | static inline Duration ?`us( int64_t usec ) { return (Duration)@{ usec * (TIMEGRAN / 1_000_000LL) }; }
|
---|
| 82 | static inline Duration ?`ms( int64_t msec ) { return (Duration)@{ msec * (TIMEGRAN / 1_000LL) }; }
|
---|
[643c6b9] | 83 | static inline Duration ?`s( int64_t sec ) { return (Duration)@{ sec * TIMEGRAN }; }
|
---|
| 84 | static inline Duration ?`s( double sec ) { return (Duration)@{ sec * TIMEGRAN }; }
|
---|
| 85 | static inline Duration ?`m( int64_t min ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; }
|
---|
| 86 | static inline Duration ?`m( double min ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; }
|
---|
| 87 | static inline Duration ?`h( int64_t hours ) { return (Duration)@{ hours * (60LL * 60LL * TIMEGRAN) }; }
|
---|
| 88 | static inline Duration ?`h( double hours ) { return (Duration)@{ hours * (60LL * 60LL * TIMEGRAN) }; }
|
---|
| 89 | static inline Duration ?`d( int64_t days ) { return (Duration)@{ days * (24LL * 60LL * 60LL * TIMEGRAN) }; }
|
---|
| 90 | static inline Duration ?`d( double days ) { return (Duration)@{ days * (24LL * 60LL * 60LL * TIMEGRAN) }; }
|
---|
| 91 | static inline Duration ?`w( int64_t weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }
|
---|
| 92 | static inline Duration ?`w( double weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 60LL * 60LL * TIMEGRAN) }; }
|
---|
| 93 |
|
---|
| 94 | static inline int64_t ?`ns( Duration dur ) { return dur.tv; }
|
---|
| 95 | static inline int64_t ?`us( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000LL); }
|
---|
| 96 | static inline int64_t ?`ms( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000LL); }
|
---|
| 97 | static inline int64_t ?`s( Duration dur ) { return dur.tv / TIMEGRAN; }
|
---|
| 98 | static inline int64_t ?`m( Duration dur ) { return dur.tv / (60LL * TIMEGRAN); }
|
---|
| 99 | static inline int64_t ?`h( Duration dur ) { return dur.tv / (60LL * 60LL * TIMEGRAN); }
|
---|
| 100 | static inline int64_t ?`d( Duration dur ) { return dur.tv / (24LL * 60LL * 60LL * TIMEGRAN); }
|
---|
| 101 | static inline int64_t ?`w( Duration dur ) { return dur.tv / (7LL * 24LL * 60LL * 60LL * TIMEGRAN); }
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | //######################### C timeval #########################
|
---|
[2a84d06d] | 105 |
|
---|
[643c6b9] | 106 | static inline void ?{}( timeval & t ) {}
|
---|
| 107 | static inline void ?{}( timeval & t, time_t sec, suseconds_t usec ) { t.tv_sec = sec; t.tv_usec = usec; }
|
---|
| 108 | static inline void ?{}( timeval & t, time_t sec ) { t{ sec, 0 }; }
|
---|
| 109 | static inline void ?{}( timeval & t, zero_t ) { t{ 0, 0 }; }
|
---|
| 110 | static inline timeval ?=?( timeval & t, zero_t ) { return t{ 0 }; }
|
---|
| 111 | static inline timeval ?+?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_usec + rhs.tv_usec }; }
|
---|
| 112 | static inline timeval ?-?( timeval & lhs, timeval rhs ) { return (timeval)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_usec - rhs.tv_usec }; }
|
---|
| 113 | static inline _Bool ?==?( timeval lhs, timeval rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_usec == rhs.tv_usec; }
|
---|
| 114 | static inline _Bool ?!=?( timeval lhs, timeval rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_usec != rhs.tv_usec; }
|
---|
[6ecc079] | 115 |
|
---|
| 116 |
|
---|
[643c6b9] | 117 | //######################### C timespec #########################
|
---|
[6ecc079] | 118 |
|
---|
[643c6b9] | 119 | static inline void ?{}( timespec & t ) {}
|
---|
| 120 | static inline void ?{}( timespec & t, time_t sec, __syscall_slong_t nsec ) { t.tv_sec = sec; t.tv_nsec = nsec; }
|
---|
| 121 | static inline void ?{}( timespec & t, time_t sec ) { t{ sec, 0}; }
|
---|
| 122 | static inline void ?{}( timespec & t, zero_t ) { t{ 0, 0 }; }
|
---|
| 123 | static inline timespec ?=?( timespec & t, zero_t ) { return t{ 0 }; }
|
---|
| 124 | static inline timespec ?+?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec + rhs.tv_sec, lhs.tv_nsec + rhs.tv_nsec }; }
|
---|
| 125 | static inline timespec ?-?( timespec & lhs, timespec rhs ) { return (timespec)@{ lhs.tv_sec - rhs.tv_sec, lhs.tv_nsec - rhs.tv_nsec }; }
|
---|
| 126 | static inline _Bool ?==?( timespec lhs, timespec rhs ) { return lhs.tv_sec == rhs.tv_sec && lhs.tv_nsec == rhs.tv_nsec; }
|
---|
| 127 | static inline _Bool ?!=?( timespec lhs, timespec rhs ) { return lhs.tv_sec != rhs.tv_sec || lhs.tv_nsec != rhs.tv_nsec; }
|
---|
[6ecc079] | 128 |
|
---|
| 129 |
|
---|
[8ad6533] | 130 | //######################### C itimerval #########################
|
---|
| 131 |
|
---|
| 132 | static inline void ?{}( itimerval & itv, Duration alarm ) with( itv ) {
|
---|
| 133 | // itimerval contains durations but but uses time data-structure timeval.
|
---|
| 134 | it_value{ alarm`s, (alarm % 1`s)`us }; // seconds, microseconds
|
---|
| 135 | it_interval{ 0 }; // 0 seconds, 0 microseconds
|
---|
| 136 | } // itimerval
|
---|
| 137 |
|
---|
| 138 | static inline void ?{}( itimerval & itv, Duration alarm, Duration interval ) with( itv ) {
|
---|
| 139 | // itimerval contains durations but but uses time data-structure timeval.
|
---|
| 140 | it_value{ alarm`s, (alarm % 1`s)`us }; // seconds, microseconds
|
---|
| 141 | it_interval{ interval`s, interval`us }; // seconds, microseconds
|
---|
| 142 | } // itimerval
|
---|
| 143 |
|
---|
| 144 |
|
---|
[643c6b9] | 145 | //######################### C time #########################
|
---|
[6ecc079] | 146 |
|
---|
[643c6b9] | 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 ); }
|
---|
[6ecc079] | 153 |
|
---|
| 154 |
|
---|
[643c6b9] | 155 | //######################### Time #########################
|
---|
[6ecc079] | 156 |
|
---|
[643c6b9] | 157 | struct Time { // private
|
---|
| 158 | uint64_t tv; // nanoseconds since UNIX epoch
|
---|
[8ad6533] | 159 | }; // Time
|
---|
[6ecc079] | 160 |
|
---|
[643c6b9] | 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
|
---|
[6ecc079] | 163 |
|
---|
[bc03be3] | 164 | static inline void ?{}( Time & t, zero_t ) { t.tv = 0; }
|
---|
| 165 | static inline Time ?=?( Time & t, zero_t ) { return t{ 0 }; }
|
---|
| 166 |
|
---|
[6ecc079] | 167 | static inline void ?{}( Time & time, timeval t ) with( time ) {
|
---|
| 168 | tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000;
|
---|
| 169 | } // Time
|
---|
| 170 |
|
---|
| 171 | static inline Time ?=?( Time & time, timeval t ) with( time ) {
|
---|
[273cde6] | 172 | tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
|
---|
[6ecc079] | 173 | return time;
|
---|
| 174 | } // ?=?
|
---|
| 175 |
|
---|
[bc03be3] | 176 | static inline void ?{}( Time & time, timespec t ) with( time ) {
|
---|
| 177 | tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
|
---|
| 178 | } // Time
|
---|
| 179 |
|
---|
[6ecc079] | 180 | static inline Time ?=?( Time & time, timespec t ) with( time ) {
|
---|
| 181 | tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
|
---|
| 182 | return time;
|
---|
| 183 | } // ?=?
|
---|
| 184 |
|
---|
| 185 | static inline Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
|
---|
| 186 | static inline Time ?+?( Duration lhs, Time rhs ) { return rhs + lhs; }
|
---|
| 187 | static inline Time ?+=?( Time & lhs, Duration rhs ) { lhs = lhs + rhs; return lhs; }
|
---|
| 188 |
|
---|
| 189 | static inline Duration ?-?( Time lhs, Time rhs ) { return (Duration)@{ lhs.tv - rhs.tv }; }
|
---|
| 190 | static inline Time ?-?( Time lhs, Duration rhs ) { return (Time)@{ lhs.tv - rhs.tv }; }
|
---|
| 191 | static inline Time ?-=?( Time & lhs, Duration rhs ) { lhs = lhs - rhs; return lhs; }
|
---|
| 192 | static inline _Bool ?==?( Time lhs, Time rhs ) { return lhs.tv == rhs.tv; }
|
---|
| 193 | static inline _Bool ?!=?( Time lhs, Time rhs ) { return lhs.tv != rhs.tv; }
|
---|
| 194 | static inline _Bool ?<?( Time lhs, Time rhs ) { return lhs.tv < rhs.tv; }
|
---|
| 195 | static inline _Bool ?<=?( Time lhs, Time rhs ) { return lhs.tv <= rhs.tv; }
|
---|
| 196 | static inline _Bool ?>?( Time lhs, Time rhs ) { return lhs.tv > rhs.tv; }
|
---|
| 197 | static inline _Bool ?>=?( Time lhs, Time rhs ) { return lhs.tv >= rhs.tv; }
|
---|
| 198 |
|
---|
[2a84d06d] | 199 | char * yy_mm_dd( Time time, char * buf );
|
---|
[643c6b9] | 200 | static inline char * ?`ymd( Time time, char * buf ) { // short form
|
---|
[2a84d06d] | 201 | return yy_mm_dd( time, buf );
|
---|
| 202 | } // ymd
|
---|
| 203 |
|
---|
| 204 | char * mm_dd_yy( Time time, char * buf );
|
---|
[643c6b9] | 205 | static inline char * ?`mdy( Time time, char * buf ) { // short form
|
---|
[2a84d06d] | 206 | return mm_dd_yy( time, buf );
|
---|
| 207 | } // mdy
|
---|
| 208 |
|
---|
| 209 | char * dd_mm_yy( Time time, char * buf );
|
---|
[643c6b9] | 210 | static inline char * ?`dmy( Time time, char * buf ) { // short form
|
---|
[2a84d06d] | 211 | return dd_mm_yy( time, buf );;
|
---|
| 212 | } // dmy
|
---|
| 213 |
|
---|
| 214 | size_t strftime( char * buf, size_t size, const char * fmt, Time time );
|
---|
| 215 |
|
---|
| 216 | forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
|
---|
| 217 |
|
---|
[273cde6] | 218 | //------------------------- timeval (cont) -------------------------
|
---|
| 219 |
|
---|
| 220 | static inline void ?{}( timeval & t, Time time ) with( t, time ) {
|
---|
| 221 | tv_sec = tv / TIMEGRAN; // seconds
|
---|
| 222 | tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds
|
---|
| 223 | } // ?{}
|
---|
| 224 |
|
---|
| 225 | //------------------------- timespec (cont) -------------------------
|
---|
| 226 |
|
---|
| 227 | static inline void ?{}( timespec & t, Time time ) with( t, time ) {
|
---|
| 228 | tv_sec = tv / TIMEGRAN; // seconds
|
---|
| 229 | tv_nsec = tv % TIMEGRAN; // nanoseconds
|
---|
| 230 | } // ?{}
|
---|
| 231 |
|
---|
[6ecc079] | 232 |
|
---|
| 233 | //######################### Clock #########################
|
---|
| 234 |
|
---|
[643c6b9] | 235 | struct Clock { // private
|
---|
[6ecc079] | 236 | Duration offset; // for virtual clock: contains offset from real-time
|
---|
| 237 | int clocktype; // implementation only -1 (virtual), CLOCK_REALTIME
|
---|
| 238 | };
|
---|
| 239 |
|
---|
[2a84d06d] | 240 | static inline void resetClock( Clock & clk ) with( clk ) {
|
---|
| 241 | clocktype = CLOCK_REALTIME_COARSE;
|
---|
[6ecc079] | 242 | } // Clock::resetClock
|
---|
| 243 |
|
---|
[2a84d06d] | 244 | static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {
|
---|
[6ecc079] | 245 | clocktype = -1;
|
---|
[643c6b9] | 246 | offset = adj + timezone`s; // timezone (global) is (UTC - local time) in seconds
|
---|
[6ecc079] | 247 | } // resetClock
|
---|
| 248 |
|
---|
[2a84d06d] | 249 | static inline void ?{}( Clock & clk ) {
|
---|
[6ecc079] | 250 | resetClock( clk );
|
---|
| 251 | } // Clock
|
---|
| 252 |
|
---|
[2a84d06d] | 253 | static inline void ?{}( Clock & clk, Duration adj ) {
|
---|
[6ecc079] | 254 | resetClock( clk, adj );
|
---|
| 255 | } // Clock
|
---|
| 256 |
|
---|
[2a84d06d] | 257 | static inline Duration getRes() {
|
---|
[6ecc079] | 258 | struct timespec res;
|
---|
[2a84d06d] | 259 | clock_getres( CLOCK_REALTIME_COARSE, &res );
|
---|
[8eb2018] | 260 | return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
|
---|
[6ecc079] | 261 | } // getRes
|
---|
| 262 |
|
---|
[2a84d06d] | 263 | static inline Time getTimeNsec() { // with nanoseconds
|
---|
[6ecc079] | 264 | timespec curr;
|
---|
| 265 | clock_gettime( CLOCK_REALTIME_COARSE, &curr );
|
---|
| 266 | return (Time){ curr };
|
---|
| 267 | } // getTime
|
---|
| 268 |
|
---|
[2a84d06d] | 269 | static inline Time getTime() { // without nanoseconds
|
---|
| 270 | timespec curr;
|
---|
| 271 | clock_gettime( CLOCK_REALTIME_COARSE, &curr );
|
---|
| 272 | curr.tv_nsec = 0;
|
---|
| 273 | return (Time){ curr };
|
---|
| 274 | } // getTime
|
---|
| 275 |
|
---|
| 276 | static inline Time getTime( Clock & clk ) with( clk ) {
|
---|
[6ecc079] | 277 | return getTime() + offset;
|
---|
| 278 | } // getTime
|
---|
| 279 |
|
---|
[2a84d06d] | 280 | static inline Time ?()( Clock & clk ) with( clk ) { // alternative syntax
|
---|
[6ecc079] | 281 | return getTime() + offset;
|
---|
| 282 | } // getTime
|
---|
| 283 |
|
---|
[2a84d06d] | 284 | static inline timeval getTime( Clock & clk ) {
|
---|
[6ecc079] | 285 | return (timeval){ clk() };
|
---|
| 286 | } // getTime
|
---|
| 287 |
|
---|
[2a84d06d] | 288 | static inline tm getTime( Clock & clk ) with( clk ) {
|
---|
[6ecc079] | 289 | tm ret;
|
---|
| 290 | localtime_r( getTime( clk ).tv_sec, &ret );
|
---|
| 291 | return ret;
|
---|
| 292 | } // getTime
|
---|
| 293 |
|
---|
| 294 | // Local Variables: //
|
---|
| 295 | // mode: c //
|
---|
| 296 | // tab-width: 4 //
|
---|
| 297 | // End: //
|
---|