Files

42 lines
1.1 KiB
C

#ifndef TASK01_SOFTWARE_TIMERS_MODEL_H
#define TASK01_SOFTWARE_TIMERS_MODEL_H
#include <stddef.h>
#include <stdint.h>
typedef struct TimerEvidence
{
uint32_t sequence;
uint32_t event;
uint32_t tick;
uint32_t actor;
uint32_t value;
uint32_t committed;
} TimerEvidence;
static inline int fc06_timeline_is_exact( const uint32_t auto_ticks[ 3 ],
uint32_t one_shot_tick )
{
return auto_ticks[ 0 ] == 2U &&
auto_ticks[ 1 ] == 4U &&
one_shot_tick == 6U &&
auto_ticks[ 2 ] == 7U;
}
static inline uint32_t fc06_digest( const TimerEvidence * events,
size_t count )
{
uint32_t hash = 2166136261U;
size_t index;
for( index = 0U; index < count; ++index )
{
hash = ( hash ^ events[ index ].event ) * 16777619U;
hash = ( hash ^ events[ index ].actor ) * 16777619U;
hash = ( hash ^ events[ index ].value ) * 16777619U;
hash = ( hash ^ events[ index ].committed ) * 16777619U;
}
return hash;
}
#endif