aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/os-Linux/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/os-Linux/time.c')
-rw-r--r--arch/um/os-Linux/time.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c
index 5eb32d24ba58..f22fcdfd4250 100644
--- a/arch/um/os-Linux/time.c
+++ b/arch/um/os-Linux/time.c
@@ -1,21 +1,17 @@
1/* 1/*
2 * Copyright (C) 2000, 2001, 2002 Jeff Dike (jdike@karaya.com) 2 * Copyright (C) 2000 - 2007 Jeff Dike (jdike{addtoit,linux.intel}.com)
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <stdio.h> 6#include <stddef.h>
7#include <stdlib.h> 7#include <errno.h>
8#include <unistd.h> 8#include <signal.h>
9#include <time.h> 9#include <time.h>
10#include <sys/time.h> 10#include <sys/time.h>
11#include <signal.h>
12#include <errno.h>
13#include "kern_util.h" 11#include "kern_util.h"
14#include "user.h"
15#include "process.h"
16#include "kern_constants.h" 12#include "kern_constants.h"
17#include "os.h" 13#include "os.h"
18#include "uml-config.h" 14#include "user.h"
19 15
20int set_interval(int is_virtual) 16int set_interval(int is_virtual)
21{ 17{
@@ -24,7 +20,7 @@ int set_interval(int is_virtual)
24 struct itimerval interval = ((struct itimerval) { { 0, usec }, 20 struct itimerval interval = ((struct itimerval) { { 0, usec },
25 { 0, usec } }); 21 { 0, usec } });
26 22
27 if(setitimer(timer_type, &interval, NULL) == -1) 23 if (setitimer(timer_type, &interval, NULL) == -1)
28 return -errno; 24 return -errno;
29 25
30 return 0; 26 return 0;
@@ -33,10 +29,12 @@ int set_interval(int is_virtual)
33void disable_timer(void) 29void disable_timer(void)
34{ 30{
35 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }}); 31 struct itimerval disable = ((struct itimerval) { { 0, 0 }, { 0, 0 }});
36 if((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) || 32
37 (setitimer(ITIMER_REAL, &disable, NULL) < 0)) 33 if ((setitimer(ITIMER_VIRTUAL, &disable, NULL) < 0) ||
38 printk("disnable_timer - setitimer failed, errno = %d\n", 34 (setitimer(ITIMER_REAL, &disable, NULL) < 0))
39 errno); 35 printk(UM_KERN_ERR "disable_timer - setitimer failed, "
36 "errno = %d\n", errno);
37
40 /* If there are signals already queued, after unblocking ignore them */ 38 /* If there are signals already queued, after unblocking ignore them */
41 signal(SIGALRM, SIG_IGN); 39 signal(SIGALRM, SIG_IGN);
42 signal(SIGVTALRM, SIG_IGN); 40 signal(SIGVTALRM, SIG_IGN);
@@ -49,7 +47,7 @@ void switch_timers(int to_real)
49 { 0, 1000000/hz() }}); 47 { 0, 1000000/hz() }});
50 int old, new; 48 int old, new;
51 49
52 if(to_real){ 50 if (to_real) {
53 old = ITIMER_VIRTUAL; 51 old = ITIMER_VIRTUAL;
54 new = ITIMER_REAL; 52 new = ITIMER_REAL;
55 } 53 }
@@ -58,10 +56,10 @@ void switch_timers(int to_real)
58 new = ITIMER_VIRTUAL; 56 new = ITIMER_VIRTUAL;
59 } 57 }
60 58
61 if((setitimer(old, &disable, NULL) < 0) || 59 if ((setitimer(old, &disable, NULL) < 0) ||
62 (setitimer(new, &enable, NULL))) 60 (setitimer(new, &enable, NULL)))
63 printk("switch_timers - setitimer failed, errno = %d\n", 61 printk(UM_KERN_ERR "switch_timers - setitimer failed, "
64 errno); 62 "errno = %d\n", errno);
65} 63}
66 64
67unsigned long long os_nsecs(void) 65unsigned long long os_nsecs(void)
@@ -69,7 +67,7 @@ unsigned long long os_nsecs(void)
69 struct timeval tv; 67 struct timeval tv;
70 68
71 gettimeofday(&tv, NULL); 69 gettimeofday(&tv, NULL);
72 return((unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000); 70 return (unsigned long long) tv.tv_sec * BILLION + tv.tv_usec * 1000;
73} 71}
74 72
75void idle_sleep(int secs) 73void idle_sleep(int secs)