Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/time.hfa

    r030653a re638266  
    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 21 06:32:31 2021
     13// Update Count     : 667
    1414//
    1515
     
    2828
    2929static inline {
     30        void ?{}( Duration & dur, timeval t ) with( dur ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     31        void ?{}( Duration & dur, timespec t ) with( dur ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     32
    3033        Duration ?=?( Duration & dur, __attribute__((unused)) zero_t ) { return dur{ 0 }; }
     34        Duration ?=?( Duration & dur, timeval t ) with( dur ) {
     35                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
     36                return dur;
     37        } // ?=?
     38        Duration ?=?( Duration & dur, timespec t ) with( dur ) {
     39                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
     40                return dur;
     41        } // ?=?
    3142
    3243        Duration +?( Duration rhs ) with( rhs ) { return (Duration)@{ +tn }; }
     
    4960        Duration ?%?( Duration lhs, Duration rhs ) { return (Duration)@{ lhs.tn % rhs.tn }; }
    5061        Duration ?%=?( Duration & lhs, Duration rhs ) { lhs = lhs % rhs; return lhs; }
     62
     63        bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn == 0; }
     64        bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn != 0; }
     65        bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <  0; }
     66        bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <= 0; }
     67        bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >  0; }
     68        bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >= 0; }
    5169
    5270        bool ?==?( Duration lhs, Duration rhs ) { return lhs.tn == rhs.tn; }
     
    5674        bool ?>? ( Duration lhs, Duration rhs ) { return lhs.tn >  rhs.tn; }
    5775        bool ?>=?( Duration lhs, Duration rhs ) { return lhs.tn >= rhs.tn; }
    58 
    59         bool ?==?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn == 0; }
    60         bool ?!=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn != 0; }
    61         bool ?<? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <  0; }
    62         bool ?<=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn <= 0; }
    63         bool ?>? ( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >  0; }
    64         bool ?>=?( Duration lhs, __attribute__((unused)) zero_t ) { return lhs.tn >= 0; }
    6576
    6677        Duration abs( Duration rhs ) { return rhs.tn >= 0 ? rhs : -rhs; }
     
    152163void ?{}( Time & time, int year, int month = 1, int day = 1, int hour = 0, int min = 0, int sec = 0, int64_t nsec = 0 );
    153164static inline {
     165        void ?{}( Time & time, timeval t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     166        void ?{}( Time & time, timespec t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
     167
    154168        Time ?=?( Time & time, __attribute__((unused)) zero_t ) { return time{ 0 }; }
    155 
    156         void ?{}( Time & time, timeval t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
    157169        Time ?=?( Time & time, timeval t ) with( time ) {
    158170                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
    159171                return time;
    160172        } // ?=?
    161 
    162         void ?{}( Time & time, timespec t ) with( time ) { tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec; }
    163173        Time ?=?( Time & time, timespec t ) with( time ) {
    164174                tn = (int64_t)t.tv_sec * TIMEGRAN + t.tv_nsec;
Note: See TracChangeset for help on using the changeset viewer.