X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fum%2Fos-Linux%2Ftime.c;fp=arch%2Fum%2Fos-Linux%2Ftime.c;h=6f7626775acb983e7f2e663d2312533d80c1a792;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=4ae73c0e54850c4068e1ddf0cf9afc33f6e96239;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index 4ae73c0e5..6f7626775 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c @@ -17,6 +17,11 @@ #include "kern_constants.h" #include "os.h" +/* XXX This really needs to be declared and initialized in a kernel file since + * it's in + */ +extern struct timespec wall_to_monotonic; + static void set_interval(int timer_type) { int usec = 1000000/hz(); @@ -66,7 +71,6 @@ void switch_timers(int to_real) errno); } -#ifdef UML_CONFIG_MODE_TT void uml_idle_timer(void) { if(signal(SIGVTALRM, SIG_IGN) == SIG_ERR) @@ -76,7 +80,22 @@ void uml_idle_timer(void) SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, SIGVTALRM, -1); set_interval(ITIMER_REAL); } -#endif + +extern void ktime_get_ts(struct timespec *ts); +#define do_posix_clock_monotonic_gettime(ts) ktime_get_ts(ts) + +void time_init(void) +{ + struct timespec now; + + if(signal(SIGVTALRM, boot_timer_handler) == SIG_ERR) + panic("Couldn't set SIGVTALRM handler"); + set_interval(ITIMER_VIRTUAL); + + do_posix_clock_monotonic_gettime(&now); + wall_to_monotonic.tv_sec = -now.tv_sec; + wall_to_monotonic.tv_nsec = -now.tv_nsec; +} unsigned long long os_nsecs(void) { @@ -95,7 +114,15 @@ void idle_sleep(int secs) nanosleep(&ts, NULL); } +/* XXX This partly duplicates init_irq_signals */ + void user_time_init(void) { + set_handler(SIGVTALRM, (__sighandler_t) alarm_handler, + SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, + SIGALRM, SIGUSR2, -1); + set_handler(SIGALRM, (__sighandler_t) alarm_handler, + SA_ONSTACK | SA_RESTART, SIGUSR1, SIGIO, SIGWINCH, + SIGVTALRM, SIGUSR2, -1); set_interval(ITIMER_VIRTUAL); }