File: rtl_time.h

package info (click to toggle)
rtlinux 3.1pre3-2
  • links: PTS
  • area: non-free
  • in suites: sarge, woody
  • size: 4,892 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (61 lines) | stat: -rw-r--r-- 1,534 bytes parent folder | download | duplicates (2)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * (C) Finite State Machine Labs Inc. 2000 business@fsmlabs.com
 *
 * Released under the terms of GPL 2.
 * Open RTLinux makes use of a patented process described in
 * US Patent 5,995,745. Use of this process is governed
 * by the Open RTLinux Patent License which can be obtained from
 * www.fsmlabs.com/PATENT or by sending email to
 * licensequestions@fsmlabs.com
 */

#ifndef __RTL_ARCH_TIME_H__
#define __RTL_ARCH_TIME_H__

extern unsigned long loops_per_sec;

#include <asm/types.h>

typedef __s64 hrtime_t;		/* high-resolution time type (signed 64-bit) */

static inline hrtime_t timespec_to_ns(const struct timespec *ts)
{
	hrtime_t t;

	t = (ts->tv_sec * NSECS_PER_SEC) + ts->tv_nsec;
	return t;
}

static inline struct timespec timespec_from_ns(hrtime_t t)
{
	struct timespec ts;
	ts.tv_sec = t / NSECS_PER_SEC;
	ts.tv_nsec = t % NSECS_PER_SEC;
	return ts;
}

#define rdtscl(x)	x=read_32bit_cp0_register(CP0_COUNT)

extern hrtime_t gethrtime(void);	/* time in nanoseconds since bootup */
extern hrtime_t gethrtimeres(void);	/* resolution of gethrtime() in ns */

struct rtl_clock_arch {
	int istimerset;
	hrtime_t time;
};

#define RTL_CLOCK_ARCH_INITIALIZER { 0, 0 }
/* __delay originally from include/asm-mips/delay.h 
 * 	-Nathan <npsimons@fsmlabs.com> */
extern __inline__ void __delay(unsigned long loops)
{
	__asm__ __volatile__(".set\tnoreorder\n"
			     "1:\tbnez\t%0,1b\n\t"
			     "subu\t%0,1\n\t"
			     ".set\treorder":"=r"(loops):"0"(loops));
}

static inline void rtl_delay(long nanoseconds)
{
}
#endif