linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / um / os-Linux / time.c
index 4ae73c0..6f76267 100644 (file)
 #include "kern_constants.h"
 #include "os.h"
 
+/* XXX This really needs to be declared and initialized in a kernel file since
+ * it's in <linux/time.h>
+ */
+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);
 }