linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] Patch for timespec vs. timeval in 2.6
@ 2004-03-15  5:37 Pete Zaitcev
  0 siblings, 0 replies; only message in thread
From: Pete Zaitcev @ 2004-03-15  5:37 UTC (permalink / raw)
  To: user-mode-linux-devel

Looks to me that timespec and timeval got confused in 2.6, by the way
of an extern declaration in a C file. I'm not sure if this is a problem,
but the attached patch makes me more comfortable. Only you might want
to correct the comment.

-- Pete

diff -ur -X dontdiff linux-2.6.4-uml-1/arch/um/include/time_user.h linux-2.6.4-uml-1-t1/arch/um/include/time_user.h
--- linux-2.6.4-uml-1/arch/um/include/time_user.h	2003-07-13 20:31:22.000000000 -0700
+++ linux-2.6.4-uml-1-t1/arch/um/include/time_user.h	2004-03-14 21:21:43.000000000 -0800
@@ -6,7 +6,9 @@
 #ifndef __TIME_USER_H__
 #define __TIME_USER_H__
 
-extern void timer(void);
+/* struct timeval has the same layout in user and kernel */
+extern void timer(struct timeval *tv);
+
 extern void switch_timers(int to_real);
 extern void set_interval(int timer_type);
 extern void idle_sleep(int secs);
diff -ur -X dontdiff linux-2.6.4-uml-1/arch/um/kernel/time.c linux-2.6.4-uml-1-t1/arch/um/kernel/time.c
--- linux-2.6.4-uml-1/arch/um/kernel/time.c	2004-03-14 16:58:33.000000000 -0800
+++ linux-2.6.4-uml-1-t1/arch/um/kernel/time.c	2004-03-14 21:21:49.000000000 -0800
@@ -23,14 +23,17 @@
  */
 extern struct timespec wall_to_monotonic;
 
-extern struct timeval xtime;
-
 struct timeval local_offset = { 0, 0 };
 
-void timer(void)
+/*
+ * This is just a way to cross user-kernel boundary.
+ * For the moment, it is almost the same as do_gettimeofday, but non-locking.
+ * It may get different if guest time ever diverges from host time.
+ */
+void timer(struct timeval *tv)
 {
-	gettimeofday(&xtime, NULL);
-	timeradd(&xtime, &local_offset, &xtime);
+	gettimeofday(tv, NULL);
+	timeradd(tv, &local_offset, tv);
 }
 
 void set_interval(int timer_type)
diff -ur -X dontdiff linux-2.6.4-uml-1/arch/um/kernel/time_kern.c linux-2.6.4-uml-1-t1/arch/um/kernel/time_kern.c
--- linux-2.6.4-uml-1/arch/um/kernel/time_kern.c	2004-03-14 16:58:33.000000000 -0800
+++ linux-2.6.4-uml-1-t1/arch/um/kernel/time_kern.c	2004-03-14 21:24:15.000000000 -0800
@@ -97,10 +97,13 @@
 irqreturn_t um_timer(int irq, void *dev, struct pt_regs *regs)
 {
 	unsigned long flags;
+	struct timeval timeb;
 
 	do_timer(regs);
 	write_seqlock_irqsave(&xtime_lock, flags);
-	timer();
+	timer(&timeb);
+	xtime.tv_sec = timeb.tv_sec;
+	xtime.tv_nsec = timeb.tv_usec * 1000;
 	write_sequnlock_irqrestore(&xtime_lock, flags);
 	return(IRQ_HANDLED);
 }


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-03-15  5:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-15  5:37 [uml-devel] Patch for timespec vs. timeval in 2.6 Pete Zaitcev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox