| 1 |
#include "harness.h" |
| 2 |
|
| 3 |
static unsigned long current_time = 0; |
| 4 |
static unsigned long current_rate = 1; |
| 5 |
static unsigned long current_step = 0; |
| 6 |
|
| 7 |
void init_time(unsigned long t) |
| 8 |
{ |
| 9 |
current_time = t; |
| 10 |
} |
| 11 |
|
| 12 |
void set_rate(unsigned long rate) |
| 13 |
{ |
| 14 |
current_rate = rate; |
| 15 |
} |
| 16 |
|
| 17 |
unsigned long get_time(void) |
| 18 |
{ |
| 19 |
return current_time; |
| 20 |
} |
| 21 |
|
| 22 |
void tick() |
| 23 |
{ |
| 24 |
if (++current_step >= current_rate) |
| 25 |
{ |
| 26 |
++current_time; |
| 27 |
process_events_at(current_time); |
| 28 |
current_step = 0; |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
void warp_time(unsigned long t) |
| 33 |
{ |
| 34 |
outputf("Warped time to %ld\n", t); |
| 35 |
process_events_at(t); |
| 36 |
current_time = t; |
| 37 |
current_step = 0; |
| 38 |
} |
| 39 |
|
| 40 |
/* */ |
| 41 |
/* Local Variables: */ |
| 42 |
/* mode:c */ |
| 43 |
/* c-indentation-style: "whitesmith" */ |
| 44 |
/* c-basic-offset: 2 */ |
| 45 |
/* End: */ |