diff options
-rw-r--r-- | arch/um/include/common-offsets.h | 4 | ||||
-rw-r--r-- | arch/um/include/os.h | 2 | ||||
-rw-r--r-- | arch/um/kernel/time.c | 9 | ||||
-rw-r--r-- | arch/um/os-Linux/skas/process.c | 12 | ||||
-rw-r--r-- | arch/um/os-Linux/time.c | 12 |
5 files changed, 22 insertions, 17 deletions
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 54694693f400..0edab695ed4e 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/common-offsets.h | |||
@@ -34,3 +34,7 @@ DEFINE(crypto_tfm_ctx_offset, offsetof(struct crypto_tfm, __crt_ctx)); | |||
34 | DEFINE(UM_THREAD_SIZE, THREAD_SIZE); | 34 | DEFINE(UM_THREAD_SIZE, THREAD_SIZE); |
35 | 35 | ||
36 | DEFINE(UM_HZ, HZ); | 36 | DEFINE(UM_HZ, HZ); |
37 | |||
38 | DEFINE(UM_USEC_PER_SEC, USEC_PER_SEC); | ||
39 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | ||
40 | DEFINE(UM_NSEC_PER_USEC, NSEC_PER_USEC); | ||
diff --git a/arch/um/include/os.h b/arch/um/include/os.h index a1b0804ee57b..fbf0a87c6eaa 100644 --- a/arch/um/include/os.h +++ b/arch/um/include/os.h | |||
@@ -249,8 +249,6 @@ extern int setjmp_wrapper(void (*proc)(void *, void *), ...); | |||
249 | extern void os_dump_core(void); | 249 | extern void os_dump_core(void); |
250 | 250 | ||
251 | /* time.c */ | 251 | /* time.c */ |
252 | #define BILLION (1000 * 1000 * 1000) | ||
253 | |||
254 | extern void idle_sleep(unsigned long long nsecs); | 252 | extern void idle_sleep(unsigned long long nsecs); |
255 | extern int set_interval(void); | 253 | extern int set_interval(void); |
256 | extern int timer_one_shot(int ticks); | 254 | extern int timer_one_shot(int ticks); |
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 2acdc7efb2ac..1ac746a9eae1 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c | |||
@@ -17,7 +17,7 @@ | |||
17 | */ | 17 | */ |
18 | unsigned long long sched_clock(void) | 18 | unsigned long long sched_clock(void) |
19 | { | 19 | { |
20 | return (unsigned long long)jiffies_64 * (1000000000 / HZ); | 20 | return (unsigned long long)jiffies_64 * (NSEC_PER_SEC / HZ); |
21 | } | 21 | } |
22 | 22 | ||
23 | void timer_handler(int sig, struct uml_pt_regs *regs) | 23 | void timer_handler(int sig, struct uml_pt_regs *regs) |
@@ -118,8 +118,9 @@ void __init time_init(void) | |||
118 | timer_init(); | 118 | timer_init(); |
119 | 119 | ||
120 | nsecs = os_nsecs(); | 120 | nsecs = os_nsecs(); |
121 | set_normalized_timespec(&wall_to_monotonic, -nsecs / BILLION, | 121 | set_normalized_timespec(&wall_to_monotonic, -nsecs / NSEC_PER_SEC, |
122 | -nsecs % BILLION); | 122 | -nsecs % NSEC_PER_SEC); |
123 | set_normalized_timespec(&xtime, nsecs / BILLION, nsecs % BILLION); | 123 | set_normalized_timespec(&xtime, nsecs / NSEC_PER_SEC, |
124 | nsecs % NSEC_PER_SEC); | ||
124 | late_time_init = setup_itimer; | 125 | late_time_init = setup_itimer; |
125 | } | 126 | } |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index 9936531a2620..8548f126d628 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
@@ -294,8 +294,8 @@ void userspace(struct uml_pt_regs *regs) | |||
294 | 294 | ||
295 | if (getitimer(ITIMER_VIRTUAL, &timer)) | 295 | if (getitimer(ITIMER_VIRTUAL, &timer)) |
296 | printk("Failed to get itimer, errno = %d\n", errno); | 296 | printk("Failed to get itimer, errno = %d\n", errno); |
297 | nsecs = timer.it_value.tv_sec * BILLION + | 297 | nsecs = timer.it_value.tv_sec * UM_NSEC_PER_SEC + |
298 | timer.it_value.tv_usec * 1000; | 298 | timer.it_value.tv_usec * UM_NSEC_PER_USEC; |
299 | nsecs += os_nsecs(); | 299 | nsecs += os_nsecs(); |
300 | 300 | ||
301 | while (1) { | 301 | while (1) { |
@@ -347,8 +347,10 @@ void userspace(struct uml_pt_regs *regs) | |||
347 | block_signals(); | 347 | block_signals(); |
348 | (*sig_info[sig])(sig, regs); | 348 | (*sig_info[sig])(sig, regs); |
349 | unblock_signals(); | 349 | unblock_signals(); |
350 | nsecs = timer.it_value.tv_sec * BILLION + | 350 | nsecs = timer.it_value.tv_sec * |
351 | timer.it_value.tv_usec * 1000; | 351 | UM_NSEC_PER_SEC + |
352 | timer.it_value.tv_usec * | ||
353 | UM_NSEC_PER_USEC; | ||
352 | nsecs += os_nsecs(); | 354 | nsecs += os_nsecs(); |
353 | break; | 355 | break; |
354 | case SIGIO: | 356 | case SIGIO: |
@@ -395,7 +397,7 @@ __initcall(init_thread_regs); | |||
395 | 397 | ||
396 | int copy_context_skas0(unsigned long new_stack, int pid) | 398 | int copy_context_skas0(unsigned long new_stack, int pid) |
397 | { | 399 | { |
398 | struct timeval tv = { .tv_sec = 0, .tv_usec = 1000000 / UM_HZ }; | 400 | struct timeval tv = { .tv_sec = 0, .tv_usec = UM_USEC_PER_SEC / UM_HZ }; |
399 | int err; | 401 | int err; |
400 | unsigned long current_stack = current_stub_stack(); | 402 | unsigned long current_stack = current_stub_stack(); |
401 | struct stub_data *data = (struct stub_data *) current_stack; | 403 | struct stub_data *data = (struct stub_data *) current_stack; |
diff --git a/arch/um/os-Linux/time.c b/arch/um/os-Linux/time.c index 574b134f0502..e34e1effe0f5 100644 --- a/arch/um/os-Linux/time.c +++ b/arch/um/os-Linux/time.c | |||
@@ -14,7 +14,7 @@ | |||
14 | 14 | ||
15 | int set_interval(void) | 15 | int set_interval(void) |
16 | { | 16 | { |
17 | int usec = 1000000/UM_HZ; | 17 | int usec = UM_USEC_PER_SEC / UM_HZ; |
18 | struct itimerval interval = ((struct itimerval) { { 0, usec }, | 18 | struct itimerval interval = ((struct itimerval) { { 0, usec }, |
19 | { 0, usec } }); | 19 | { 0, usec } }); |
20 | 20 | ||
@@ -26,11 +26,11 @@ int set_interval(void) | |||
26 | 26 | ||
27 | int timer_one_shot(int ticks) | 27 | int timer_one_shot(int ticks) |
28 | { | 28 | { |
29 | unsigned long usec = ticks * 1000000 / UM_HZ; | 29 | unsigned long usec = ticks * UM_USEC_PER_SEC / UM_HZ; |
30 | unsigned long sec = usec / 1000000; | 30 | unsigned long sec = usec / UM_USEC_PER_SEC; |
31 | struct itimerval interval; | 31 | struct itimerval interval; |
32 | 32 | ||
33 | usec %= 1000000; | 33 | usec %= UM_USEC_PER_SEC; |
34 | interval = ((struct itimerval) { { 0, 0 }, { sec, usec } }); | 34 | interval = ((struct itimerval) { { 0, 0 }, { sec, usec } }); |
35 | 35 | ||
36 | if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1) | 36 | if (setitimer(ITIMER_VIRTUAL, &interval, NULL) == -1) |
@@ -78,8 +78,8 @@ extern void alarm_handler(int sig, struct sigcontext *sc); | |||
78 | 78 | ||
79 | void idle_sleep(unsigned long long nsecs) | 79 | void idle_sleep(unsigned long long nsecs) |
80 | { | 80 | { |
81 | struct timespec ts = { .tv_sec = nsecs / BILLION, | 81 | struct timespec ts = { .tv_sec = nsecs / UM_NSEC_PER_SEC, |
82 | .tv_nsec = nsecs % BILLION }; | 82 | .tv_nsec = nsecs % UM_NSEC_PER_SEC }; |
83 | 83 | ||
84 | if (nanosleep(&ts, &ts) == 0) | 84 | if (nanosleep(&ts, &ts) == 0) |
85 | alarm_handler(SIGVTALRM, NULL); | 85 | alarm_handler(SIGVTALRM, NULL); |