Skip to content

Commit

Permalink
uml: time build fix
Browse files Browse the repository at this point in the history
Put back an implementation of timeval_to_ns in arch/um/os-Linux/time.c.
tglx pointed out in his review of tickless support that there was a
perfectly good implementation of it in linux/time.h.  The problem is that
this is userspace code which can't pull in kernel headers and there doesn't
seem to be a libc version.

So, I'm copying the version from linux/time.h rather than resurrecting my
version.  This causes some declaration changes as it now returns a signed
value rather than an unsigned value.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
cfd-36 authored and Linus Torvalds committed Oct 16, 2007
1 parent b160fb6 commit 5f73461
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions arch/um/include/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ extern void os_dump_core(void);
extern void idle_sleep(unsigned long long nsecs);
extern int set_interval(void);
extern int timer_one_shot(int ticks);
extern unsigned long long disable_timer(void);
extern long long disable_timer(void);
extern void uml_idle_timer(void);
extern unsigned long long os_nsecs(void);
extern long long os_nsecs(void);

/* skas/mem.c */
extern long run_syscall_stub(struct mm_id * mm_idp,
Expand Down
22 changes: 19 additions & 3 deletions arch/um/os-Linux/time.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,34 @@ int timer_one_shot(int ticks)
return 0;
}

unsigned long long disable_timer(void)
/**
* timeval_to_ns - Convert timeval to nanoseconds
* @ts: pointer to the timeval variable to be converted
*
* Returns the scalar nanosecond representation of the timeval
* parameter.
*
* Ripped from linux/time.h because it's a kernel header, and thus
* unusable from here.
*/
static inline long long timeval_to_ns(const struct timeval *tv)
{
return ((long long) tv->tv_sec * UM_NSEC_PER_SEC) +
tv->tv_usec * UM_NSEC_PER_USEC;
}

long long disable_timer(void)
{
struct itimerval time = ((struct itimerval) { { 0, 0 }, { 0, 0 } });

if(setitimer(ITIMER_VIRTUAL, &time, &time) < 0)
printk(UM_KERN_ERR "disable_timer - setitimer failed, "
"errno = %d\n", errno);

return tv_to_nsec(&time.it_value);
return timeval_to_ns(&time.it_value);
}

unsigned long long os_nsecs(void)
long long os_nsecs(void)
{
struct timeval tv;

Expand Down

0 comments on commit 5f73461

Please sign in to comment.