aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGennady Sharapov <Gennady.V.Sharapov@intel.com>2006-01-18 20:42:42 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-18 22:20:19 -0500
commitcff65c4f0ea6662124bbb7bf3806e5df1c6d735d (patch)
tree5f19b3facdfa6a50ad1668b28d1ff74a92a90271
parent4fef0c10fa174b57a10854b8b4b2b90d155706e0 (diff)
[PATCH] uml: move libc-dependent time code
The serial UML OS-abstraction layer patch (um/kernel dir). This moves all systemcalls from time.c file under os-Linux dir and joins time.c and tine_kernel.c files Signed-off-by: Gennady Sharapov <Gennady.V.Sharapov@intel.com> Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--arch/um/include/os.h12
-rw-r--r--arch/um/include/time_user.h19
-rw-r--r--arch/um/kernel/Makefile4
-rw-r--r--arch/um/kernel/exec_kern.c1
-rw-r--r--arch/um/kernel/process_kern.c1
-rw-r--r--arch/um/kernel/skas/process.c1
-rw-r--r--arch/um/kernel/skas/process_kern.c1
-rw-r--r--arch/um/kernel/syscall.c4
-rw-r--r--arch/um/kernel/time_kern.c124
-rw-r--r--arch/um/kernel/tt/exec_kern.c1
-rw-r--r--arch/um/kernel/tt/process_kern.c1
-rw-r--r--arch/um/os-Linux/main.c1
-rw-r--r--arch/um/os-Linux/signal.c2
-rw-r--r--arch/um/os-Linux/start_up.c1
-rw-r--r--arch/um/os-Linux/time.c131
-rw-r--r--arch/um/os-Linux/tt.c1
16 files changed, 211 insertions, 94 deletions
diff --git a/arch/um/include/os.h b/arch/um/include/os.h
index 7f27dfe0ecac..624938ad9e14 100644
--- a/arch/um/include/os.h
+++ b/arch/um/include/os.h
@@ -190,7 +190,6 @@ extern int os_protect_memory(void *addr, unsigned long len,
190 int r, int w, int x); 190 int r, int w, int x);
191extern int os_unmap_memory(void *addr, int len); 191extern int os_unmap_memory(void *addr, int len);
192extern void os_flush_stdout(void); 192extern void os_flush_stdout(void);
193extern unsigned long long os_usecs(void);
194 193
195/* tt.c 194/* tt.c
196 * for tt mode only (will be deleted in future...) 195 * for tt mode only (will be deleted in future...)
@@ -245,4 +244,15 @@ extern void setup_machinename(char *machine_out);
245extern void setup_hostinfo(void); 244extern void setup_hostinfo(void);
246extern int setjmp_wrapper(void (*proc)(void *, void *), ...); 245extern int setjmp_wrapper(void (*proc)(void *, void *), ...);
247 246
247/* time.c */
248#define BILLION (1000 * 1000 * 1000)
249
250extern void switch_timers(int to_real);
251extern void idle_sleep(int secs);
252extern void enable_timer(void);
253extern void disable_timer(void);
254extern void user_time_init(void);
255extern void uml_idle_timer(void);
256extern unsigned long long os_nsecs(void);
257
248#endif 258#endif
diff --git a/arch/um/include/time_user.h b/arch/um/include/time_user.h
deleted file mode 100644
index 17d7ef2141f4..000000000000
--- a/arch/um/include/time_user.h
+++ /dev/null
@@ -1,19 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __TIME_USER_H__
7#define __TIME_USER_H__
8
9extern void timer(void);
10extern void switch_timers(int to_real);
11extern void idle_sleep(int secs);
12extern void enable_timer(void);
13extern void prepare_timer(void * ptr);
14extern void disable_timer(void);
15extern unsigned long time_lock(void);
16extern void time_unlock(unsigned long);
17extern void user_time_init(void);
18
19#endif
diff --git a/arch/um/kernel/Makefile b/arch/um/kernel/Makefile
index 165c8639c9f6..693018ba80f1 100644
--- a/arch/um/kernel/Makefile
+++ b/arch/um/kernel/Makefile
@@ -9,7 +9,7 @@ clean-files :=
9obj-y = config.o exec_kern.o exitcode.o \ 9obj-y = config.o exec_kern.o exitcode.o \
10 init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \ 10 init_task.o irq.o irq_user.o ksyms.o mem.o physmem.o \
11 process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \ 11 process_kern.o ptrace.o reboot.o resource.o sigio_user.o sigio_kern.o \
12 signal_kern.o smp.o syscall_kern.o sysrq.o time.o \ 12 signal_kern.o smp.o syscall_kern.o sysrq.o \
13 time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o 13 time_kern.o tlb.o trap_kern.o uaccess.o um_arch.o umid.o
14 14
15obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o 15obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
@@ -23,7 +23,7 @@ obj-$(CONFIG_MODE_SKAS) += skas/
23 23
24user-objs-$(CONFIG_TTY_LOG) += tty_log.o 24user-objs-$(CONFIG_TTY_LOG) += tty_log.o
25 25
26USER_OBJS := $(user-objs-y) config.o time.o tty_log.o 26USER_OBJS := $(user-objs-y) config.o tty_log.o
27 27
28include arch/um/scripts/Makefile.rules 28include arch/um/scripts/Makefile.rules
29 29
diff --git a/arch/um/kernel/exec_kern.c b/arch/um/kernel/exec_kern.c
index efd222ffe20e..569fe8b9b053 100644
--- a/arch/um/kernel/exec_kern.c
+++ b/arch/um/kernel/exec_kern.c
@@ -17,7 +17,6 @@
17#include "irq_user.h" 17#include "irq_user.h"
18#include "tlb.h" 18#include "tlb.h"
19#include "os.h" 19#include "os.h"
20#include "time_user.h"
21#include "choose-mode.h" 20#include "choose-mode.h"
22#include "mode_kern.h" 21#include "mode_kern.h"
23 22
diff --git a/arch/um/kernel/process_kern.c b/arch/um/kernel/process_kern.c
index 7f13b85d2656..e167cf0a71f4 100644
--- a/arch/um/kernel/process_kern.c
+++ b/arch/um/kernel/process_kern.c
@@ -39,7 +39,6 @@
39#include "init.h" 39#include "init.h"
40#include "irq_user.h" 40#include "irq_user.h"
41#include "mem_user.h" 41#include "mem_user.h"
42#include "time_user.h"
43#include "tlb.h" 42#include "tlb.h"
44#include "frame_kern.h" 43#include "frame_kern.h"
45#include "sigcontext.h" 44#include "sigcontext.h"
diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c
index 3b3955d84407..eea1c9c4bb0f 100644
--- a/arch/um/kernel/skas/process.c
+++ b/arch/um/kernel/skas/process.c
@@ -18,7 +18,6 @@
18#include <asm/types.h> 18#include <asm/types.h>
19#include "user.h" 19#include "user.h"
20#include "ptrace_user.h" 20#include "ptrace_user.h"
21#include "time_user.h"
22#include "sysdep/ptrace.h" 21#include "sysdep/ptrace.h"
23#include "user_util.h" 22#include "user_util.h"
24#include "kern_util.h" 23#include "kern_util.h"
diff --git a/arch/um/kernel/skas/process_kern.c b/arch/um/kernel/skas/process_kern.c
index fcddee76c7c0..a340006dec47 100644
--- a/arch/um/kernel/skas/process_kern.c
+++ b/arch/um/kernel/skas/process_kern.c
@@ -13,7 +13,6 @@
13#include "asm/uaccess.h" 13#include "asm/uaccess.h"
14#include "asm/atomic.h" 14#include "asm/atomic.h"
15#include "kern_util.h" 15#include "kern_util.h"
16#include "time_user.h"
17#include "skas.h" 16#include "skas.h"
18#include "os.h" 17#include "os.h"
19#include "user_util.h" 18#include "user_util.h"
diff --git a/arch/um/kernel/syscall.c b/arch/um/kernel/syscall.c
index 1429c131879d..1731d90e6850 100644
--- a/arch/um/kernel/syscall.c
+++ b/arch/um/kernel/syscall.c
@@ -25,12 +25,12 @@ int record_syscall_start(int syscall)
25 syscall_record[index].syscall = syscall; 25 syscall_record[index].syscall = syscall;
26 syscall_record[index].pid = current_pid(); 26 syscall_record[index].pid = current_pid();
27 syscall_record[index].result = 0xdeadbeef; 27 syscall_record[index].result = 0xdeadbeef;
28 syscall_record[index].start = os_usecs(); 28 syscall_record[index].start = os_nsecs();
29 return(index); 29 return(index);
30} 30}
31 31
32void record_syscall_end(int index, long result) 32void record_syscall_end(int index, long result)
33{ 33{
34 syscall_record[index].result = result; 34 syscall_record[index].result = result;
35 syscall_record[index].end = os_usecs(); 35 syscall_record[index].end = os_nsecs();
36} 36}
diff --git a/arch/um/kernel/time_kern.c b/arch/um/kernel/time_kern.c
index 020ca79b8d33..6712ffad0242 100644
--- a/arch/um/kernel/time_kern.c
+++ b/arch/um/kernel/time_kern.c
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
@@ -13,12 +13,12 @@
13#include "linux/interrupt.h" 13#include "linux/interrupt.h"
14#include "linux/init.h" 14#include "linux/init.h"
15#include "linux/delay.h" 15#include "linux/delay.h"
16#include "linux/hrtimer.h"
16#include "asm/irq.h" 17#include "asm/irq.h"
17#include "asm/param.h" 18#include "asm/param.h"
18#include "asm/current.h" 19#include "asm/current.h"
19#include "kern_util.h" 20#include "kern_util.h"
20#include "user_util.h" 21#include "user_util.h"
21#include "time_user.h"
22#include "mode.h" 22#include "mode.h"
23#include "os.h" 23#include "os.h"
24 24
@@ -39,7 +39,7 @@ unsigned long long sched_clock(void)
39int timer_irq_inited = 0; 39int timer_irq_inited = 0;
40 40
41static int first_tick; 41static int first_tick;
42static unsigned long long prev_usecs; 42static unsigned long long prev_nsecs;
43#ifdef CONFIG_UML_REAL_TIME_CLOCK 43#ifdef CONFIG_UML_REAL_TIME_CLOCK
44static long long delta; /* Deviation per interval */ 44static long long delta; /* Deviation per interval */
45#endif 45#endif
@@ -58,23 +58,23 @@ void timer_irq(union uml_pt_regs *regs)
58 if(first_tick){ 58 if(first_tick){
59#ifdef CONFIG_UML_REAL_TIME_CLOCK 59#ifdef CONFIG_UML_REAL_TIME_CLOCK
60 /* We've had 1 tick */ 60 /* We've had 1 tick */
61 unsigned long long usecs = os_usecs(); 61 unsigned long long nsecs = os_nsecs();
62 62
63 delta += usecs - prev_usecs; 63 delta += nsecs - prev_nsecs;
64 prev_usecs = usecs; 64 prev_nsecs = nsecs;
65 65
66 /* Protect against the host clock being set backwards */ 66 /* Protect against the host clock being set backwards */
67 if(delta < 0) 67 if(delta < 0)
68 delta = 0; 68 delta = 0;
69 69
70 ticks += (delta * HZ) / MILLION; 70 ticks += (delta * HZ) / BILLION;
71 delta -= (ticks * MILLION) / HZ; 71 delta -= (ticks * BILLION) / HZ;
72#else 72#else
73 ticks = 1; 73 ticks = 1;
74#endif 74#endif
75 } 75 }
76 else { 76 else {
77 prev_usecs = os_usecs(); 77 prev_nsecs = os_nsecs();
78 first_tick = 1; 78 first_tick = 1;
79 } 79 }
80 80
@@ -88,45 +88,99 @@ void boot_timer_handler(int sig)
88{ 88{
89 struct pt_regs regs; 89 struct pt_regs regs;
90 90
91 CHOOSE_MODE((void) 91 CHOOSE_MODE((void)
92 (UPT_SC(&regs.regs) = (struct sigcontext *) (&sig + 1)), 92 (UPT_SC(&regs.regs) = (struct sigcontext *) (&sig + 1)),
93 (void) (regs.regs.skas.is_user = 0)); 93 (void) (regs.regs.skas.is_user = 0));
94 do_timer(&regs); 94 do_timer(&regs);
95} 95}
96 96
97static DEFINE_SPINLOCK(timer_spinlock);
98
99static unsigned long long local_offset = 0;
100
101static inline unsigned long long get_time(void)
102{
103 unsigned long long nsecs;
104 unsigned long flags;
105
106 spin_lock_irqsave(&timer_spinlock, flags);
107 nsecs = os_nsecs();
108 nsecs += local_offset;
109 spin_unlock_irqrestore(&timer_spinlock, flags);
110
111 return nsecs;
112}
113
97irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs) 114irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
98{ 115{
116 unsigned long long nsecs;
99 unsigned long flags; 117 unsigned long flags;
100 118
101 do_timer(regs); 119 do_timer(regs);
120
102 write_seqlock_irqsave(&xtime_lock, flags); 121 write_seqlock_irqsave(&xtime_lock, flags);
103 timer(); 122 nsecs = get_time() + local_offset;
123 xtime.tv_sec = nsecs / NSEC_PER_SEC;
124 xtime.tv_nsec = nsecs - xtime.tv_sec * NSEC_PER_SEC;
104 write_sequnlock_irqrestore(&xtime_lock, flags); 125 write_sequnlock_irqrestore(&xtime_lock, flags);
126
105 return(IRQ_HANDLED); 127 return(IRQ_HANDLED);
106} 128}
107 129
108long um_time(int __user *tloc) 130long um_time(int __user *tloc)
109{ 131{
110 struct timeval now; 132 long ret = get_time() / NSEC_PER_SEC;
111 133
112 do_gettimeofday(&now); 134 if((tloc != NULL) && put_user(ret, tloc))
113 if (tloc) { 135 return -EFAULT;
114 if (put_user(now.tv_sec, tloc)) 136
115 now.tv_sec = -EFAULT; 137 return ret;
116 } 138}
117 return now.tv_sec; 139
140void do_gettimeofday(struct timeval *tv)
141{
142 unsigned long long nsecs = get_time();
143
144 tv->tv_sec = nsecs / NSEC_PER_SEC;
145 /* Careful about calculations here - this was originally done as
146 * (nsecs - tv->tv_sec * NSEC_PER_SEC) / NSEC_PER_USEC
147 * which gave bogus (> 1000000) values. Dunno why, suspect gcc
148 * (4.0.0) miscompiled it, or there's a subtle 64/32-bit conversion
149 * problem that I missed.
150 */
151 nsecs -= tv->tv_sec * NSEC_PER_SEC;
152 tv->tv_usec = (unsigned long) nsecs / NSEC_PER_USEC;
153}
154
155static inline void set_time(unsigned long long nsecs)
156{
157 unsigned long long now;
158 unsigned long flags;
159
160 spin_lock_irqsave(&timer_spinlock, flags);
161 now = os_nsecs();
162 local_offset = nsecs - now;
163 spin_unlock_irqrestore(&timer_spinlock, flags);
164
165 clock_was_set();
118} 166}
119 167
120long um_stime(int __user *tptr) 168long um_stime(int __user *tptr)
121{ 169{
122 int value; 170 int value;
123 struct timespec new;
124 171
125 if (get_user(value, tptr)) 172 if (get_user(value, tptr))
126 return -EFAULT; 173 return -EFAULT;
127 new.tv_sec = value; 174
128 new.tv_nsec = 0; 175 set_time((unsigned long long) value * NSEC_PER_SEC);
129 do_settimeofday(&new); 176
177 return 0;
178}
179
180int do_settimeofday(struct timespec *tv)
181{
182 set_time((unsigned long long) tv->tv_sec * NSEC_PER_SEC + tv->tv_nsec);
183
130 return 0; 184 return 0;
131} 185}
132 186
@@ -142,21 +196,6 @@ void timer_handler(int sig, union uml_pt_regs *regs)
142 timer_irq(regs); 196 timer_irq(regs);
143} 197}
144 198
145static DEFINE_SPINLOCK(timer_spinlock);
146
147unsigned long time_lock(void)
148{
149 unsigned long flags;
150
151 spin_lock_irqsave(&timer_spinlock, flags);
152 return(flags);
153}
154
155void time_unlock(unsigned long flags)
156{
157 spin_unlock_irqrestore(&timer_spinlock, flags);
158}
159
160int __init timer_init(void) 199int __init timer_init(void)
161{ 200{
162 int err; 201 int err;
@@ -171,14 +210,3 @@ int __init timer_init(void)
171} 210}
172 211
173__initcall(timer_init); 212__initcall(timer_init);
174
175/*
176 * Overrides for Emacs so that we follow Linus's tabbing style.
177 * Emacs will notice this stuff at the end of the file and automatically
178 * adjust the settings for this buffer only. This must remain at the end
179 * of the file.
180 * ---------------------------------------------------------------------------
181 * Local variables:
182 * c-file-style: "linux"
183 * End:
184 */
diff --git a/arch/um/kernel/tt/exec_kern.c b/arch/um/kernel/tt/exec_kern.c
index 8f40e4838736..5c1e4cc1c049 100644
--- a/arch/um/kernel/tt/exec_kern.c
+++ b/arch/um/kernel/tt/exec_kern.c
@@ -13,7 +13,6 @@
13#include "user_util.h" 13#include "user_util.h"
14#include "kern_util.h" 14#include "kern_util.h"
15#include "irq_user.h" 15#include "irq_user.h"
16#include "time_user.h"
17#include "mem_user.h" 16#include "mem_user.h"
18#include "os.h" 17#include "os.h"
19#include "tlb.h" 18#include "tlb.h"
diff --git a/arch/um/kernel/tt/process_kern.c b/arch/um/kernel/tt/process_kern.c
index 62535303aa27..295c1ac817b3 100644
--- a/arch/um/kernel/tt/process_kern.c
+++ b/arch/um/kernel/tt/process_kern.c
@@ -18,7 +18,6 @@
18#include "os.h" 18#include "os.h"
19#include "kern.h" 19#include "kern.h"
20#include "sigcontext.h" 20#include "sigcontext.h"
21#include "time_user.h"
22#include "mem_user.h" 21#include "mem_user.h"
23#include "tlb.h" 22#include "tlb.h"
24#include "mode.h" 23#include "mode.h"
diff --git a/arch/um/os-Linux/main.c b/arch/um/os-Linux/main.c
index 172c8474453c..98becd18f211 100644
--- a/arch/um/os-Linux/main.c
+++ b/arch/um/os-Linux/main.c
@@ -16,7 +16,6 @@
16#include "user_util.h" 16#include "user_util.h"
17#include "kern_util.h" 17#include "kern_util.h"
18#include "mem_user.h" 18#include "mem_user.h"
19#include "time_user.h"
20#include "irq_user.h" 19#include "irq_user.h"
21#include "user.h" 20#include "user.h"
22#include "init.h" 21#include "init.h"
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c
index c1f46a0fef13..da474a797fbf 100644
--- a/arch/um/os-Linux/signal.c
+++ b/arch/um/os-Linux/signal.c
@@ -18,8 +18,8 @@
18#include "sysdep/sigcontext.h" 18#include "sysdep/sigcontext.h"
19#include "sysdep/signal.h" 19#include "sysdep/signal.h"
20#include "sigcontext.h" 20#include "sigcontext.h"
21#include "time_user.h"
22#include "mode.h" 21#include "mode.h"
22#include "os.h"
23 23
24void sig_handler(ARCH_SIGHDLR_PARAM) 24void sig_handler(ARCH_SIGHDLR_PARAM)
25{ 25{
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index b47e5e71d1a5..6c5b17ed59e1 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -29,7 +29,6 @@
29#include "irq_user.h" 29#include "irq_user.h"
30#include "ptrace_user.h" 30#include "ptrace_user.h"
31#include "mem_user.h" 31#include "mem_user.h"
32#include "time_user.h"
33#include "init.h" 32#include "init.h"
34#include "os.h" 33#include "os.h"
35#include "uml-config.h" 34#include "uml-config.h"
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index cf30a39bc484..6f7626775acb 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -1,21 +1,128 @@
1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include <stdio.h>
1#include <stdlib.h> 7#include <stdlib.h>
8#include <unistd.h>
9#include <time.h>
2#include <sys/time.h> 10#include <sys/time.h>
11#include <signal.h>
12#include <errno.h>
13#include "user_util.h"
14#include "kern_util.h"
15#include "user.h"
16#include "process.h"
17#include "kern_constants.h"
18#include "os.h"
19
20/* XXX This really needs to be declared and initialized in a kernel file since
21 * it's in <linux/time.h>
22 */
23extern struct timespec wall_to_monotonic;
24
25static void set_interval(int timer_type)
26{
27 int usec = 1000000/hz();
28 struct itimerval interval = ((struct itimerval) { { 0, usec },
29 { 0, usec } });
30
31 if(setitimer(timer_type, &interval, NULL) == -1)
32 panic("setitimer failed - errno = %d\n", errno);
33}
34
35void enable_timer(void)
36{
37 set_interval(ITIMER_VIRTUAL);
38}
39
40void disable_timer(void)
41{
42 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
43 if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
44 (setitimer(ITIMER_REAL, &disable, NULL) < 0))
45 printk("disnable_timer - setitimer failed, errno = %d\n",
46 errno);
47 /* If there are signals already queued, after unblocking ignore them */
48 set_handler(SIGALRM, SIG_IGN, 0, -1);
49 set_handler(SIGVTALRM, SIG_IGN, 0, -1);
50}
51
52void switch_timers(int to_real)
53{
54 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
55 struct itimerval enable = ((struct itimerval) { { 0, 1000000/hz() },
56 { 0, 1000000/hz() }});
57 int old, new;
58
59 if(to_real){
60 old = ITIMER_VIRTUAL;
61 new = ITIMER_REAL;
62 }
63 else {
64 old = ITIMER_REAL;
65 new = ITIMER_VIRTUAL;
66 }
67
68 if((setitimer(old, &disable, NULL) < 0) ||
69 (setitimer(new, &enable, NULL)))
70 printk("switch_timers - setitimer failed, errno = %d\n",
71 errno);
72}
3 73
4unsigned long long os_usecs(void) 74void uml_idle_timer(void)
75{
76 if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR)
77 panic("Couldn't unset SIGVTALRM handler");
78
79 set_handler(SIGALRM, (__sighandler_t) alarm_handler,
80 SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1);
81 set_interval(ITIMER_REAL);
82}
83
84extern void ktime_get_ts(struct timespec *ts);
85#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts)
86
87void time_init(void)
88{
89 struct timespec now;
90
91 if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR)
92 panic("Couldn't set SIGVTALRM handler");
93 set_interval(ITIMER_VIRTUAL);
94
95 do_posix_clock_monotonic_gettime(&now);
96 wall_to_monotonic.tv_sec = -now.tv_sec;
97 wall_to_monotonic.tv_nsec = -now.tv_nsec;
98}
99
100unsigned long long os_nsecs(void)
5{ 101{
6 struct timeval tv; 102 struct timeval tv;
7 103
8 gettimeofday(&tv, NULL); 104 gettimeofday(&tv, NULL);
9 return((unsigned long long) tv.tv_sec * 1000000 + tv.tv_usec); 105 return((unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000);
10} 106}
11 107
12/* 108void idle_sleep(int secs)
13 * Overrides for Emacs so that we follow Linus's tabbing style. 109{
14 * Emacs will notice this stuff at the end of the file and automatically 110 struct timespec ts;
15 * adjust the settings for this buffer only. This must remain at the end 111
16 * of the file. 112 ts.tv_sec = secs;
17 * --------------------------------------------------------------------------- 113 ts.tv_nsec = 0;
18 * Local variables: 114 nanosleep(&ts, NULL);
19 * c-file-style: "linux" 115}
20 * End: 116
21 */ 117/* XXX This partly duplicates init_irq_signals */
118
119void user_time_init(void)
120{
121 set_handler(SIGVTALRM, (__sighandler_t) alarm_handler,
122 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
123 SIGALRM, SIGUSR2, -1);
124 set_handler(SIGALRM, (__sighandler_t) alarm_handler,
125 SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH,
126 SIGVTALRM, SIGUSR2, -1);
127 set_interval(ITIMER_VIRTUAL);
128}
diff --git a/arch/um/os-Linux/tt.c b/arch/um/os-Linux/tt.c
index 404bb63a74a9..919d19f11537 100644
--- a/arch/um/os-Linux/tt.c
+++ b/arch/um/os-Linux/tt.c
@@ -27,7 +27,6 @@
27#include "sysdep/sigcontext.h" 27#include "sysdep/sigcontext.h"
28#include "irq_user.h" 28#include "irq_user.h"
29#include "ptrace_user.h" 29#include "ptrace_user.h"
30#include "time_user.h"
31#include "init.h" 30#include "init.h"
32#include "os.h" 31#include "os.h"
33#include "uml-config.h" 32#include "uml-config.h"