Changeset 273cde6 for src


Ignore:
Timestamp:
Mar 30, 2018, 7:22:35 PM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
94ddede
Parents:
b10affd
Message:

make constants long long int

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/time

    rb10affd r273cde6  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 27 16:37:37 2018
    13 // Update Count     : 564
     12// Last Modified On : Wed Mar 28 18:03:08 2018
     13// Update Count     : 568
    1414//
    1515
     
    2525#include <iostream>                                                                             // istype/ostype
    2626
    27 enum { TIMEGRAN = 1_000_000_000L };                                             // nanosecond granularity, except for timeval
     27enum { TIMEGRAN = 1_000_000_000LL };                                    // nanosecond granularity, except for timeval
    2828
    2929
     
    131131
    132132static inline Duration ?`ns( int64_t nsec  ) { return (Duration)@{ nsec }; }
    133 static inline Duration ?`us( int64_t usec  ) { return (Duration)@{ usec * (TIMEGRAN / 1_000_000L) }; }
    134 static inline Duration ?`ms( int64_t msec  ) { return (Duration)@{ msec * (TIMEGRAN / 1_000L) }; }
     133static inline Duration ?`us( int64_t usec  ) { return (Duration)@{ usec * (TIMEGRAN / 1_000_000LL) }; }
     134static inline Duration ?`ms( int64_t msec  ) { return (Duration)@{ msec * (TIMEGRAN / 1_000LL) }; }
    135135static inline Duration ?`s ( int64_t sec   ) { return (Duration)@{ sec * TIMEGRAN }; }
    136136static inline Duration ?`s ( double  sec   ) { return (Duration)@{ sec * TIMEGRAN }; }
    137 static inline Duration ?`m ( int64_t min   ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
    138 static inline Duration ?`m ( double  min   ) { return (Duration)@{ min * (60L * TIMEGRAN) }; }
    139 static inline Duration ?`h ( int64_t hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
    140 static inline Duration ?`h ( double  hours ) { return (Duration)@{ hours * (3600L * TIMEGRAN) }; }
    141 static inline Duration ?`d ( int64_t days  ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
    142 static inline Duration ?`d ( double  days  ) { return (Duration)@{ days * (24L * 3600L * TIMEGRAN) }; }
    143 static inline Duration ?`w ( int64_t weeks ) { return (Duration)@{ weeks * (7L * 24L * 3600L * TIMEGRAN) }; }
    144 static inline Duration ?`f ( int64_t fortnight ) { return (Duration)@{ fortnight * (14L * 24L * 3600L * TIMEGRAN) }; }
     137static inline Duration ?`m ( int64_t min   ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; }
     138static inline Duration ?`m ( double  min   ) { return (Duration)@{ min * (60LL * TIMEGRAN) }; }
     139static inline Duration ?`h ( int64_t hours ) { return (Duration)@{ hours * (3600LL * TIMEGRAN) }; }
     140static inline Duration ?`h ( double  hours ) { return (Duration)@{ hours * (3600LL * TIMEGRAN) }; }
     141static inline Duration ?`d ( int64_t days  ) { return (Duration)@{ days * (24LL * 3600LL * TIMEGRAN) }; }
     142static inline Duration ?`d ( double  days  ) { return (Duration)@{ days * (24LL * 3600LL * TIMEGRAN) }; }
     143static inline Duration ?`w ( int64_t weeks ) { return (Duration)@{ weeks * (7LL * 24LL * 3600LL * TIMEGRAN) }; }
     144static inline Duration ?`f ( int64_t fortnight ) { return (Duration)@{ fortnight * (14LL * 24LL * 3600LL * TIMEGRAN) }; }
    145145
    146146static inline int64_t ?`ns ( Duration dur ) { return dur.tv; }
    147 static inline int64_t ?`us ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000L); }
    148 static inline int64_t ?`ms ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000L); }
     147static inline int64_t ?`us ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000_000LL); }
     148static inline int64_t ?`ms ( Duration dur ) { return dur.tv / (TIMEGRAN / 1_000LL); }
    149149static inline int64_t ?`s  ( Duration dur ) { return dur.tv / TIMEGRAN; }
    150 static inline int64_t ?`m  ( Duration dur ) { return dur.tv / (60L * TIMEGRAN); }
    151 static inline int64_t ?`h  ( Duration dur ) { return dur.tv / (3600L * TIMEGRAN); }
    152 static inline int64_t ?`d  ( Duration dur ) { return dur.tv / (24L * 3600L * TIMEGRAN); }
    153 static inline int64_t ?`w  ( Duration dur ) { return dur.tv / (7L * 24L * 3600L * TIMEGRAN); }
    154 static inline int64_t ?`f  ( Duration dur ) { return dur.tv / (14L * 24L * 3600L * TIMEGRAN); }
     150static inline int64_t ?`m  ( Duration dur ) { return dur.tv / (60LL * TIMEGRAN); }
     151static inline int64_t ?`h  ( Duration dur ) { return dur.tv / (3600LL * TIMEGRAN); }
     152static inline int64_t ?`d  ( Duration dur ) { return dur.tv / (24LL * 3600LL * TIMEGRAN); }
     153static inline int64_t ?`w  ( Duration dur ) { return dur.tv / (7LL * 24LL * 3600LL * TIMEGRAN); }
     154static inline int64_t ?`f  ( Duration dur ) { return dur.tv / (14LL * 24LL * 3600LL * TIMEGRAN); }
    155155
    156156//------------------------- timeval (cont) -------------------------
     
    158158static inline void ?{}( timeval & t, Duration dur ) with( dur ) {
    159159        t.tv_sec = tv / TIMEGRAN;                                                       // seconds
    160         t.tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000L); // microseconds
     160        t.tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL); // microseconds
    161161} // ?{}
    162162
     
    222222
    223223static inline Time ?=?( Time & time, timeval t ) with( time ) {
    224         tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000L);
     224        tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * (TIMEGRAN / 1_000_000LL);
    225225        return time;
    226226} // ?=?
     
    230230        return time;
    231231} // ?=?
    232 
    233 static inline void ?{}( timeval & t, Time time ) with( time ) {
    234         t.tv_sec = tv / TIMEGRAN;                                                       // seconds
    235         t.tv_usec = tv % TIMEGRAN / ( TIMEGRAN / 1_000_000L ); // microseconds
    236 } // ?{}
    237 
    238 static inline void ?{}( timespec & t, Time time ) with( time ) {
    239         t.tv_sec = tv / TIMEGRAN;                                                       // seconds
    240         t.tv_nsec = tv % TIMEGRAN;                                                      // nanoseconds
    241 } // ?{}
    242232
    243233static inline Time ?+?( Time & lhs, Duration rhs ) { return (Time)@{ lhs.tv + rhs.tv }; }
     
    274264forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
    275265
     266//------------------------- timeval (cont) -------------------------
     267
     268static inline void ?{}( timeval & t, Time time ) with( t, time ) {
     269        tv_sec = tv / TIMEGRAN;                                                         // seconds
     270        tv_usec = tv % TIMEGRAN / (TIMEGRAN / 1_000_000LL);     // microseconds
     271} // ?{}
     272
     273//------------------------- timespec (cont) -------------------------
     274
     275static inline void ?{}( timespec & t, Time time ) with( t, time ) {
     276        tv_sec = tv / TIMEGRAN;                                                         // seconds
     277        tv_nsec = tv % TIMEGRAN;                                                        // nanoseconds
     278} // ?{}
     279
    276280
    277281//######################### Clock #########################
Note: See TracChangeset for help on using the changeset viewer.