File: time.c

package info (click to toggle)
mbr 1.2.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 676 kB
  • sloc: sh: 3,941; ansic: 2,226; makefile: 116
file content (45 lines) | stat: -rw-r--r-- 716 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "harness.h"

static unsigned long current_time = 0;
static unsigned long current_rate = 1;
static unsigned long current_step = 0;

void init_time(unsigned long t)
{
  current_time = t;
}

void set_rate(unsigned long rate)
{
  current_rate = rate;
}

unsigned long get_time(void)
{
  return current_time;
}

void tick()
{
  if (++current_step >= current_rate)
  {
    ++current_time;
    process_events_at(current_time);
    current_step = 0;
  }
}

void warp_time(unsigned long t)
{
  outputf("Warped time to %ld\n", t);
  process_events_at(t);
  current_time = t;
  current_step = 0;
}

/*  */
/* Local Variables: */
/* mode:c */
/* c-indentation-style: "whitesmith" */
/* c-basic-offset: 2 */
/* End: */