Changeset 22cf65e


Ignore:
Timestamp:
Jun 30, 2018, 6:47:55 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
fe3cd36
Parents:
73de175
Message:

add getResNsec, make getTimeNsec use more accurate clock, temporary fix for ambiguous timezone

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/clock

    r73de175 r22cf65e  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Apr 12 16:53:31 2018
    13 // Update Count     : 3
     12// Last Modified On : Tue Jun 26 14:11:44 2018
     13// Update Count     : 6
    1414//
    1515
     
    4040static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {
    4141        clocktype = -1;
    42         offset = adj + timezone`s;                                                      // timezone (global) is (UTC - local time) in seconds
     42        offset = adj + __timezone`s;                                                    // timezone (global) is (UTC - local time) in seconds
    4343} // resetClock
    4444
    4545static inline void ?{}( Clock & clk ) { resetClock( clk ); }
    4646static inline void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
     47
     48static inline Duration getResNsec() {
     49        struct timespec res;
     50        clock_getres( CLOCK_REALTIME, &res );
     51        return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
     52} // getRes
    4753
    4854static inline Duration getRes() {
     
    5460static inline Time getTimeNsec() {                                              // with nanoseconds
    5561        timespec curr;
    56         clock_gettime( CLOCK_REALTIME_COARSE, &curr );
     62        clock_gettime( CLOCK_REALTIME, &curr );
    5763        return (Time){ curr };
    5864} // getTime
Note: See TracChangeset for help on using the changeset viewer.