Changeset a4b0aa4


Ignore:
Timestamp:
Apr 15, 2021, 11:45:52 AM (5 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
8cfa4ef
Parents:
a017ee7 (diff), 9344f0e (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:software/cfa/cfa-cc

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/clock.hfa

    ra017ee7 ra4b0aa4  
    1010// Created On       : Thu Apr 12 14:36:06 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jan  6 12:49:58 2020
    13 // Update Count     : 9
     12// Last Modified On : Wed Apr 14 17:48:25 2021
     13// Update Count     : 20
    1414//
    1515
     
    3232
    3333static inline {
    34         void resetClock( Clock & clk, Duration adj ) with( clk ) {
     34        void reset( Clock & clk, Duration adj ) with( clk ) {
    3535                offset = adj + __timezone`s;                                    // timezone (global) is (UTC - local time) in seconds
    36         } // resetClock
     36        } // reset
    3737
    38         void ?{}( Clock & clk, Duration adj ) { resetClock( clk, adj ); }
     38        void ?{}( Clock & clk ) { reset( clk, (Duration){ 0 } ); }
     39        void ?{}( Clock & clk, Duration adj ) { reset( clk, adj ); }
    3940
    40         Duration getResNsec() {
     41        // System-wide clock that measures real, i.e., wall-clock) time. This clock is affected by discontinuous jumps in
     42        // the system time. For example, manual changes of the clock, and incremental adjustments performed by adjtime(3)
     43        // and NTP (daylight saving (Fall back).
     44        Duration resolutionNsec() {
    4145                struct timespec res;
    4246                clock_getres( CLOCK_REALTIME, &res );
    4347                return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
    44         } // getRes
     48        } // resolutionNsec
    4549
    46         Duration getRes() {
     50        Duration resolution() {
    4751                struct timespec res;
    4852                clock_getres( CLOCK_REALTIME_COARSE, &res );
    4953                return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
    50         } // getRes
     54        } // resolution
    5155
    52         Time getTimeNsec() {                                                            // with nanoseconds
     56        Time timeNsec() {                                                                       // with nanoseconds
    5357                timespec curr;
    5458                clock_gettime( CLOCK_REALTIME, &curr );
    5559                return (Time){ curr };
    56         } // getTimeNsec
     60        } // timeNsec
    5761
    58         Time getTime() {                                                                        // without nanoseconds
     62        Time time() {                                                                           // without nanoseconds
    5963                timespec curr;
    6064                clock_gettime( CLOCK_REALTIME_COARSE, &curr );
    6165                curr.tv_nsec = 0;
    6266                return (Time){ curr };
    63         } // getTime
     67        } // time
    6468
    65         Time getTime( Clock & clk ) with( clk ) {
    66                 return getTime() + offset;
    67         } // getTime
     69        Time time( Clock & clk ) with( clk ) {
     70                return time() + offset;
     71        } // time
    6872
    6973        Time ?()( Clock & clk ) with( clk ) {                           // alternative syntax
    70                 return getTime() + offset;
    71         } // getTime
     74                return time() + offset;
     75        } // ?()
    7276
    73         timeval getTime( Clock & clk ) {
     77        timeval time( Clock & clk ) {
    7478                return (timeval){ clk() };
    75         } // getTime
     79        } // time
    7680
    77         tm getTime( Clock & clk ) with( clk ) {
     81        tm time( Clock & clk ) with( clk ) {
    7882                tm ret;
    79                 localtime_r( getTime( clk ).tv_sec, &ret );
     83                localtime_r( time( clk ).tv_sec, &ret );
    8084                return ret;
    81         } // getTime
     85        } // time
    8286
    83         Time getCPUTime() {
     87        // CFA processor CPU-time watch that ticks when the processor (kernel thread) is running. This watch is affected by
     88        // discontinuous jumps when the OS is not running the kernal thread. A duration is returned because the value is
     89        // relative and cannot be converted to real-time (wall-clock) time.
     90        Duration processor() {
    8491                timespec ts;
    8592                clock_gettime( CLOCK_THREAD_CPUTIME_ID, &ts );
    86                 return (Time){ ts };
    87     } // getCPUTime
     93                return (Duration){ ts };
     94        } // processor
     95
     96        // Program CPU-time watch measures CPU time consumed by all processors (kernel threads) in the UNIX process.  This
     97        // watch is affected by discontinuous jumps when the OS is not running the kernel threads. A duration is returned
     98        // because the value is relative and cannot be converted to real-time (wall-clock) time.
     99        Duration program() {
     100                timespec ts;
     101                clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &ts );
     102                return (Duration){ ts };
     103        } // program
     104
     105        // Monotonic stopwatch starting at machine boot and includes system suspension. This watch is unaffected by
     106        // discontinuous jumps resulting from manual changes of the clock, and incremental adjustments performed by
     107        // adjtime(3) and NTP (Fall back). A duration is returned because the value is relative and cannot be converted to
     108        // real-time (wall-clock) time.
     109        Duration boot() {
     110                timespec ts;
     111                clock_gettime( CLOCK_BOOTTIME, &ts );
     112                return (Duration){ ts };
     113        } // boot
    88114} // distribution
    89115
  • libcfa/src/time.hfa

    ra017ee7 ra4b0aa4  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 17 16:13:00 2020
    13 // Update Count     : 663
     12// Last Modified On : Wed Apr 14 09:30:30 2021
     13// Update Count     : 664
    1414//
    1515
     
    2929static inline {
    3030        Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; }
     31
     32        void ?{}( Duration & dur, timeval t ) with( dur ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     33        Duration ?=?( Duration & dur, timeval t ) with( dur ) {
     34                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
     35                return dur;
     36        } // ?=?
     37
     38        void ?{}( Duration & dur, timespec t ) with( dur ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     39        Duration ?=?( Duration & dur, timespec t ) with( dur ) {
     40                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
     41                return dur;
     42        } // ?=?
    3143
    3244        Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn }; }
Note: See TracChangeset for help on using the changeset viewer.