From: Pete Zaitcev <zaitcev@redhat.com>
To: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] Patch for timespec vs. timeval in 2.6
Date: Sun, 14 Mar 2004 21:37:18 -0800 [thread overview]
Message-ID: <20040314213718.063a4753.zaitcev@redhat.com> (raw)
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
reply other threads:[~2004-03-15 5:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040314213718.063a4753.zaitcev@redhat.com \
--to=zaitcev@redhat.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox