File: rtl_time_common.c

package info (click to toggle)
rtlinux 3.1pre3-3
  • links: PTS
  • area: non-free
  • in suites: etch, etch-m68k
  • size: 4,896 kB
  • ctags: 4,228
  • sloc: ansic: 26,204; sh: 2,069; makefile: 1,414; perl: 855; tcl: 489; asm: 380; cpp: 42
file content (116 lines) | stat: -rw-r--r-- 2,430 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/*
 * RTLinux architecture-independent clock support
 *
 * 1999 Michael Barabanov <baraban@fsmlabs.com>
 *
 * Copyright (C) Finite State Machine Labs Inc., 1999
 */

#include <rtl_conf.h>
#include <rtl_time.h>
#include <rtl_core.h>
#include <errno.h>
#include <linux/kernel.h>

/* This is not really the right place but...*/
int *(*__errno_location)(void);

static int default_errno;
static int *default_errno_location(void)
{
	return &default_errno;
}

int rtl_setclockhandler (clockid_t h, clock_irq_handler_t fn)
{
	if (h -> handler != RTL_CLOCK_DEFAULTS.handler) {
		return -EBUSY;
	}
	h->handler = fn;
	return 0;
}

int rtl_unsetclockhandler (clockid_t h)
{
	if (h->handler == RTL_CLOCK_DEFAULTS.handler) {
		return -EINVAL;
	}
	h-> handler = RTL_CLOCK_DEFAULTS.handler;
	return 0;
}

static int definit (struct rtl_clock *c) { return 0; }
static void defuninit (struct rtl_clock *c) { return; }
static hrtime_t defgethrtime (struct rtl_clock *c)
{
	rtl_printf("defgethrtime called from %p\n", __builtin_return_address(0));
	return (hrtime_t) -1;
}

static int defsethrtime(struct rtl_clock *c, hrtime_t t)
{
	rtl_printf("defsethrtime called from %p\n", __builtin_return_address(0));
	return -EINVAL;
}
static int defsettimer(struct rtl_clock *c, hrtime_t interval)
{
	rtl_printf("defsettimer called from %p\n", __builtin_return_address(0));
	return -1;
}
static int defsettimermode (struct rtl_clock *c, int mode)
{
	rtl_printf("defsettimermode called from %p\n", __builtin_return_address(0));
	return -1;
}

static void default_handler( struct pt_regs *regs) { }


#define RTL_CLOCK_INITIALIZER { \
	definit, \
	defuninit, \
	defgethrtime, \
	defsethrtime, \
	defsettimer, \
	defsettimermode, \
	default_handler, \
	RTL_CLOCK_MODE_UNINITIALIZED, \
	0, \
	0, \
	0, \
	PTHREAD_SPINLOCK_INITIALIZER, \
	RTL_CLOCK_ARCH_INITIALIZER};


struct rtl_clock RTL_CLOCK_DEFAULTS = RTL_CLOCK_INITIALIZER;

static struct rtl_clock clock_ust = RTL_CLOCK_INITIALIZER;

hrtime_t ust_gethrtime(struct rtl_clock *c)
{
	return gethrtime();
}

#include <rtl_debug.h>
#include <rtl_core.h>

clockid_t CLOCK_UST = &clock_ust;


int rtl_init_standard_clocks(void)
{
	__errno_location = &default_errno_location;
	clock_ust.gethrtime = &ust_gethrtime;
	clock_ust.resolution = gethrtimeres();
#ifdef RTLINUX_V2
	return rtl_printf_init();
#endif
	return 0;
}

void rtl_cleanup_standard_clocks(void)
{
#ifdef RTLINUX_V2
	rtl_printf_cleanup();
#endif
}