Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/alarm.h

    r969b3fe rc81ebf9  
    1919
    2020#include <stdbool.h>
    21 #include <stdint.h>
    2221
    2322#include "assert"
     23
     24typedef unsigned long int __cfa_time_t;
    2425
    2526struct thread_desc;
    2627struct processor;
    2728
    28 struct timespec;
    29 struct itimerval;
    30 
    31 //=============================================================================================
    32 // time type
    33 //=============================================================================================
    34 
    35 struct __cfa_time_t {
    36         uint64_t val;
    37 };
    38 
    39 // ctors
    40 void ?{}( __cfa_time_t * this );
    41 void ?{}( __cfa_time_t * this, zero_t zero );
    42 void ?{}( __cfa_time_t * this, timespec * curr );
    43 void ?{}( itimerval * this, __cfa_time_t * alarm );
    44 
    45 __cfa_time_t ?=?( __cfa_time_t * this, zero_t rhs );
    46 
    47 // logical ops
    48 static inline bool ?==?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val == rhs.val; }
    49 static inline bool ?!=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val != rhs.val; }
    50 static inline bool ?>? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >  rhs.val; }
    51 static inline bool ?<? ( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <  rhs.val; }
    52 static inline bool ?>=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val >= rhs.val; }
    53 static inline bool ?<=?( __cfa_time_t lhs, __cfa_time_t rhs ) { return lhs.val <= rhs.val; }
    54 
    55 static inline bool ?==?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val == rhs; }
    56 static inline bool ?!=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val != rhs; }
    57 static inline bool ?>? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >  rhs; }
    58 static inline bool ?<? ( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <  rhs; }
    59 static inline bool ?>=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val >= rhs; }
    60 static inline bool ?<=?( __cfa_time_t lhs, zero_t rhs ) { return lhs.val <= rhs; }
    61 
    62 // addition/substract
    63 static inline __cfa_time_t ?+?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    64         __cfa_time_t ret;
    65         ret.val = lhs.val + rhs.val;
    66         return ret;
    67 }
    68 
    69 static inline __cfa_time_t ?-?( __cfa_time_t lhs, __cfa_time_t rhs ) {
    70         __cfa_time_t ret;
    71         ret.val = lhs.val - rhs.val;
    72         return ret;
    73 }
    74 
    75 __cfa_time_t from_s ( uint64_t );
    76 __cfa_time_t from_ms( uint64_t );
    77 __cfa_time_t from_us( uint64_t );
    78 __cfa_time_t from_ns( uint64_t );
    79 
    80 extern __cfa_time_t zero_time;
    81 
    8229//=============================================================================================
    8330// Clock logic
    8431//=============================================================================================
     32
     33#define TIMEGRAN 1_000_000_000L                         // nanosecond granularity, except for timeval
    8534
    8635__cfa_time_t __kernel_get_time();
     
    10756typedef alarm_node_t ** __alarm_it_t;
    10857
    109 void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
    110 void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = zero_time, __cfa_time_t period = zero_time );
     58void ?{}( alarm_node_t * this, thread_desc * thrd, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
     59void ?{}( alarm_node_t * this, processor   * proc, __cfa_time_t alarm = 0, __cfa_time_t period = 0 );
    11160void ^?{}( alarm_node_t * this );
    11261
Note: See TracChangeset for help on using the changeset viewer.