Changeset e93f1d2 for src/libcfa


Ignore:
Timestamp:
Apr 13, 2018, 11:16:36 AM (7 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, with_gc
Children:
5f08961d, deaef5b
Parents:
01963df (diff), bd5cf7c (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

Location:
src/libcfa
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/Makefile.am

    r01963df re93f1d2  
    1111## Created On       : Sun May 31 08:54:01 2015
    1212## Last Modified By : Peter A. Buhr
    13 ## Last Modified On : Sun Apr  8 23:49:34 2018
    14 ## Update Count     : 227
     13## Last Modified On : Thu Apr 12 14:38:34 2018
     14## Update Count     : 231
    1515###############################################################################
    1616
     
    100100        math                            \
    101101        gmp                             \
     102        time_t.h                        \
     103        clock                   \
    102104        bits/align.h            \
    103105        bits/containers.h               \
  • src/libcfa/Makefile.in

    r01963df re93f1d2  
    264264        containers/result containers/vector concurrency/coroutine \
    265265        concurrency/thread concurrency/kernel concurrency/monitor \
    266         ${shell find stdhdr -type f -printf "%p "} math gmp \
    267         bits/align.h bits/containers.h bits/defs.h bits/debug.h \
     266        ${shell find stdhdr -type f -printf "%p "} math gmp time_t.h \
     267        clock bits/align.h bits/containers.h bits/defs.h bits/debug.h \
    268268        bits/locks.h concurrency/invoke.h
    269269HEADERS = $(nobase_cfa_include_HEADERS)
     
    437437        math                            \
    438438        gmp                             \
     439        time_t.h                        \
     440        clock                   \
    439441        bits/align.h            \
    440442        bits/containers.h               \
  • src/libcfa/concurrency/kernel

    r01963df re93f1d2  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 23 17:08:20 2018
    13 // Update Count     : 3
     12// Last Modified On : Tue Apr 10 14:46:49 2018
     13// Update Count     : 10
    1414//
    1515
     
    1919
    2020#include "invoke.h"
    21 #include "time"
     21#include "time_t.h"
    2222
    2323extern "C" {
  • src/libcfa/concurrency/kernel.c

    r01963df re93f1d2  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 30 18:26:11 2018
    13 // Update Count     : 23
     12// Last Modified On : Mon Apr  9 16:11:46 2018
     13// Update Count     : 24
    1414//
    1515
     
    2525
    2626//CFA Includes
     27#include "time"
    2728#include "kernel_private.h"
    2829#include "preemption.h"
  • src/libcfa/iostream

    r01963df re93f1d2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Jan 25 13:08:39 2018
    13 // Update Count     : 149
     12// Last Modified On : Thu Apr 12 14:34:37 2018
     13// Update Count     : 150
    1414//
    1515
     
    159159forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Istream_cstrC );
    160160
     161
     162#include <time_t.h>                                                                             // Duration (constructors) / Time (constructors)
     163
     164forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
     165forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
     166
     167
    161168// Local Variables: //
    162169// mode: c //
  • src/libcfa/time

    r01963df re93f1d2  
    1010// Created On       : Wed Mar 14 23:18:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr  9 13:10:23 2018
    13 // Update Count     : 616
     12// Last Modified On : Fri Apr 13 07:51:52 2018
     13// Update Count     : 634
    1414//
    1515
     
    2323#include <sys/time.h>                                                                   // timeval
    2424}
    25 #include <iostream>                                                                             // istype/ostype
     25#include <time_t.h>                                                                             // Duration/Time types
    2626
    2727enum { TIMEGRAN = 1_000_000_000LL };                                    // nanosecond granularity, except for timeval
     
    3030//######################### Duration #########################
    3131
    32 struct Duration {                                                                               // private
    33         int64_t tv;                                                                                     // nanoseconds
    34 }; // Duration
    35 
    36 static inline void ?{}( Duration & dur ) with( dur ) { tv = 0; }
    3732static inline void ?{}( Duration & dur, Duration d ) with( dur ) { tv = d.tv; }
    3833
    39 static inline void ?{}( Duration & dur, zero_t ) with( dur ) { tv = 0; }
    4034static inline Duration ?=?( Duration & dur, zero_t ) { return dur{ 0 }; }
    4135
     
    7569
    7670static inline Duration abs( Duration rhs ) { return rhs.tv >= 0 ? rhs : -rhs; }
    77 
    78 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Duration dur );
    7971
    8072static inline Duration ?`ns( int64_t nsec ) { return (Duration)@{ nsec }; }
     
    143135
    144136
    145 //######################### C time #########################
    146 
    147 static inline char * ctime( time_t tp ) { char * buf = ctime( &tp ); buf[24] = '\0'; return buf; }
    148 static inline char * ctime_r( time_t tp, char * buf ) { ctime_r( &tp, buf ); buf[24] = '\0'; return buf; }
    149 static inline tm * gmtime( time_t tp ) { return gmtime( &tp ); }
    150 static inline tm * gmtime_r( time_t tp, tm * result ) { return gmtime_r( &tp, result ); }
    151 static inline tm * localtime( time_t tp ) { return localtime( &tp ); }
    152 static inline tm * localtime_r( time_t tp, tm * result ) { return localtime_r( &tp, result ); }
    153 
    154 
    155137//######################### Time #########################
    156138
    157 struct Time {                                                                                   // private
    158         uint64_t tv;                                                                            // nanoseconds since UNIX epoch
    159 }; // Time
    160 
    161 static inline void ?{}( Time & t ) with( t ) { tv = 0; } // fast
    162 void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 ); // slow
    163 
    164 static inline void ?{}( Time & t, zero_t ) { t.tv = 0; }
    165 static inline Time ?=?( Time & t, zero_t ) { return t{ 0 }; }
    166 
    167 static inline void ?{}( Time & time, timeval t ) with( time ) {
    168         tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000;
    169 } // Time
     139static inline void ?{}( Time & time, Time t ) with( time ) { tv = t.tv; }
     140void ?{}( Time & time, int year, int month = 0, int day = 0, int hour = 0, int min = 0, int sec = 0, int nsec = 0 );
     141static inline void ?{}( Time & time, timeval t ) with( time ) { tv = (int64_t)t.tv_sec * TIMEGRAN + t.tv_usec * 1000; }
     142
     143static inline Time ?=?( Time & time, zero_t ) { return time{ 0 }; }
    170144
    171145static inline Time ?=?( Time & time, timeval t ) with( time ) {
     
    214188size_t strftime( char * buf, size_t size, const char * fmt, Time time );
    215189
    216 forall( dtype ostype | ostream( ostype ) ) ostype & ?|?( ostype & os, Time time );
    217 
    218190//------------------------- timeval (cont) -------------------------
    219191
     
    230202} // ?{}
    231203
    232 
    233 //######################### Clock #########################
    234 
    235 struct Clock {                                                                                  // private
    236         Duration offset;                                                                        // for virtual clock: contains offset from real-time
    237         int clocktype;                                                                          // implementation only -1 (virtual), CLOCK_REALTIME
    238 };
    239 
    240 static inline void resetClock( Clock & clk ) with( clk ) {
    241         clocktype = CLOCK_REALTIME_COARSE;
    242 } // Clock::resetClock
    243 
    244 static inline void resetClock( Clock & clk, Duration adj ) with( clk ) {
    245         clocktype = -1;
    246         offset = adj + timezone`s;                                                      // timezone (global) is (UTC - local time) in seconds
    247 } // resetClock
    248 
    249 static inline void ?{}( Clock & clk ) {
    250         resetClock( clk );
    251 } // Clock
    252 
    253 static inline void ?{}( Clock & clk, Duration adj ) {
    254         resetClock( clk, adj );
    255 } // Clock
    256 
    257 static inline Duration getRes() {
    258         struct timespec res;
    259         clock_getres( CLOCK_REALTIME_COARSE, &res );
    260         return ((int64_t)res.tv_sec * TIMEGRAN + res.tv_nsec)`ns;
    261 } // getRes
    262 
    263 static inline Time getTimeNsec() {                                              // with nanoseconds
    264         timespec curr;
    265         clock_gettime( CLOCK_REALTIME_COARSE, &curr );
    266         return (Time){ curr };
    267 } // getTime
    268 
    269 static inline Time getTime() {                                                  // without nanoseconds
    270         timespec curr;
    271         clock_gettime( CLOCK_REALTIME_COARSE, &curr );
    272         curr.tv_nsec = 0;
    273         return (Time){ curr };
    274 } // getTime
    275 
    276 static inline Time getTime( Clock & clk ) with( clk ) {
    277         return getTime() + offset;
    278 } // getTime
    279 
    280 static inline Time ?()( Clock & clk ) with( clk ) {             // alternative syntax
    281         return getTime() + offset;
    282 } // getTime
    283 
    284 static inline timeval getTime( Clock & clk ) {
    285         return (timeval){ clk() };
    286 } // getTime
    287 
    288 static inline tm getTime( Clock & clk ) with( clk ) {
    289         tm ret;
    290         localtime_r( getTime( clk ).tv_sec, &ret );
    291         return ret;
    292 } // getTime
    293 
    294204// Local Variables: //
    295205// mode: c //
  • src/libcfa/time.c

    r01963df re93f1d2  
    1010// Created On       : Tue Mar 27 13:33:14 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Apr  1 17:30:08 2018
    13 // Update Count     : 21
     12// Last Modified On : Thu Apr 12 14:41:00 2018
     13// Update Count     : 22
    1414//
    1515
    1616#include "time"
     17#include "iostream"
    1718#include <stdio.h>                                                                              // snprintf
    1819
Note: See TracChangeset for help on using the changeset viewer.