Changeset e3b2474 for src/libcfa/clock


Ignore:
Timestamp:
Jul 3, 2018, 3:25:56 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
638ac26
Parents:
c653b37 (diff), bbe1a87 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/clock

    rc653b37 re3b2474  
    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 : Mon Jul  2 21:40:01 2018
     13// Update Count     : 7
    1414//
    1515
     
    3434};
    3535
    36 static inline void resetClock( Clock & clk ) with( clk ) {
    37         clocktype = CLOCK_REALTIME_COARSE;
    38 } // Clock::resetClock
     36static inline {
     37        void resetClock( Clock & clk ) with( clk ) {
     38                clocktype = CLOCK_REALTIME_COARSE;
     39        } // Clock::resetClock
    3940
    40 static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {
    41         clocktype = -1;
    42         offset = adj + timezone`s;                                                      // timezone (global) is (UTC - local time) in seconds
    43 } // resetClock
     41        void resetClock( Clock & clk, Duration adj ) with( clk ) {
     42                clocktype = -1;
     43                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
     44        } // resetClock
    4445
    45 static inline void ?{}( Clock & clk ) { resetClock( clk ); }
    46 static inline void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
     46        void ?{}( Clock & clk ) { resetClock( clk ); }
     47        void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
    4748
    48 static inline Duration getRes() {
    49         struct timespec res;
    50         clock_getres( CLOCK_REALTIME_COARSE, &res );
    51         return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
    52 } // getRes
     49        Duration getResNsec() {
     50                struct timespec res;
     51                clock_getres( CLOCK_REALTIME, &res );
     52                return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
     53        } // getRes
    5354
    54 static inline Time getTimeNsec() {                                              // with nanoseconds
    55         timespec curr;
    56         clock_gettime( CLOCK_REALTIME_COARSE, &curr );
    57         return (Time){ curr };
    58 } // getTime
     55        Duration getRes() {
     56                struct timespec res;
     57                clock_getres( CLOCK_REALTIME_COARSE, &res );
     58                return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
     59        } // getRes
    5960
    60 static inline Time getTime() {                                                  // without nanoseconds
    61         timespec curr;
    62         clock_gettime( CLOCK_REALTIME_COARSE, &curr );
    63         curr.tv_nsec = 0;
    64         return (Time){ curr };
    65 } // getTime
     61        Time getTimeNsec() {                                                            // with nanoseconds
     62                timespec curr;
     63                clock_gettime( CLOCK_REALTIME, &curr );
     64                return (Time){ curr };
     65        } // getTime
    6666
    67 static inline Time getTime( Clock & clk ) with( clk ) {
    68         return getTime() + offset;
    69 } // getTime
     67        Time getTime() {                                                                        // without nanoseconds
     68                timespec curr;
     69                clock_gettime( CLOCK_REALTIME_COARSE, &curr );
     70                curr.tv_nsec = 0;
     71                return (Time){ curr };
     72        } // getTime
    7073
    71 static inline Time ?()( Clock & clk ) with( clk ) {             // alternative syntax
    72         return getTime() + offset;
    73 } // getTime
     74        Time getTime( Clock & clk ) with( clk ) {
     75                return getTime() + offset;
     76        } // getTime
    7477
    75 static inline timeval getTime( Clock & clk ) {
    76         return (timeval){ clk() };
    77 } // getTime
     78        Time ?()( Clock & clk ) with( clk ) {                           // alternative syntax
     79                return getTime() + offset;
     80        } // getTime
    7881
    79 static inline tm getTime( Clock & clk ) with( clk ) {
    80         tm ret;
    81         localtime_r( getTime( clk ).tv_sec, &ret );
    82         return ret;
    83 } // getTime
     82        timeval getTime( Clock & clk ) {
     83                return (timeval){ clk() };
     84        } // getTime
     85
     86        tm getTime( Clock & clk ) with( clk ) {
     87                tm ret;
     88                localtime_r( getTime( clk ).tv_sec, &ret );
     89                return ret;
     90        } // getTime
     91} // distribution
    8492
    8593// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.