summaryrefslogtreecommitdiff
path: root/pfinet/mapped-time.h
blob: 2877f386e8274739eb580ae0495df55617e12ddf (plain)
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
#ifndef _MAPPED_TIME_H_
#define _MAPPED_TIME_H_

#define HZ 100

extern volatile struct mapped_time_value *mapped_time;
extern long long root_jiffies;

extern inline int
read_mapped_secs ()
{
  return mapped_time->seconds;
}

extern inline void
fill_timeval (struct timeval *tp)
{
  do
    {
      tp->tv_sec = mapped_time->seconds;
      tp->tv_usec = mapped_time->microseconds;
    }
  while (tp->tv_sec !=  mapped_time->check_seconds);
}

extern inline int
fetch_jiffies ()
{
  int secs, usecs;
  long long j;
  do
    {
      secs = mapped_time->seconds;
      usecs = mapped_time->microseconds;
    }
  while (secs != mapped_time->check_seconds);
  
  j = (long long) secs * HZ + ((long long) usecs * HZ) / 1000000;
  return j - root_jiffies;
}


#endif