WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] minios: make time interface POSIX

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] minios: make time interface POSIX
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Fri, 18 Jan 2008 18:10:23 +0000
Delivery-date: Fri, 18 Jan 2008 10:41:50 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Mail-followup-to: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
minios: make time interface POSIX
timespec uses tv_sec and tv_nsec too. gettimeofday takes a tz argument.

Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>

diff -r 538a343f8e38 extras/mini-os/arch/ia64/time.c
--- a/extras/mini-os/arch/ia64/time.c   Fri Jan 18 16:43:44 2008 +0000
+++ b/extras/mini-os/arch/ia64/time.c   Fri Jan 18 18:01:42 2008 +0000
@@ -147,10 +147,10 @@ calculate_time(void)
                new = itc_new - itc_alt;
        itc_alt = itc_new;
        new = ns_from_cycles(new);
-       os_time.ts_nsec += new;
-       if (os_time.ts_nsec > 1000000000) {     /* On overflow. */
-               os_time.ts_sec++;
-               os_time.ts_nsec -= 1000000000;
+       os_time.tv_nsec += new;
+       if (os_time.tv_nsec > 1000000000) {     /* On overflow. */
+               os_time.tv_sec++;
+               os_time.tv_nsec -= 1000000000;
        }
 }
 
@@ -177,12 +177,13 @@ monotonic_clock(void)
        return delta;
 }
 
-void
-gettimeofday(struct timeval *tv)
+int
+gettimeofday(struct timeval *tv, void *tz)
 {
        calculate_time();
-       tv->tv_sec = os_time.ts_sec;                    /* seconds */
-       tv->tv_usec = NSEC_TO_USEC(os_time.ts_nsec);    /* microseconds */
+       tv->tv_sec = os_time.tv_sec;                    /* seconds */
+       tv->tv_usec = NSEC_TO_USEC(os_time.tv_nsec);    /* microseconds */
+        return 0;
 };
 
 /*
@@ -253,16 +254,16 @@ init_time(void)
        itm_val = (itc_frequency + HZ/2) / HZ;
        printk("  itm_val: %ld\n", itm_val);
 
-       os_time.ts_sec = 0;
-       os_time.ts_nsec = 0;
+       os_time.tv_sec = 0;
+       os_time.tv_nsec = 0;
 
        if (efi_get_time(&tm)) {
                printk("  EFI-Time: %d.%d.%d   %d:%d:%d\n", tm.Day,
                       tm.Month, tm.Year, tm.Hour, tm.Minute, tm.Second);
-               os_time.ts_sec = mktime(SWAP(tm.Year), SWAP(tm.Month),
+               os_time.tv_sec = mktime(SWAP(tm.Year), SWAP(tm.Month),
                                        SWAP(tm.Day), SWAP(tm.Hour),
                                        SWAP(tm.Minute), SWAP(tm.Second));
-               os_time.ts_nsec = tm.Nanosecond;
+               os_time.tv_nsec = tm.Nanosecond;
        } else
                printk("efi_get_time() failed\n");
 
diff -r 538a343f8e38 extras/mini-os/arch/x86/time.c
--- a/extras/mini-os/arch/x86/time.c    Fri Jan 18 16:43:44 2008 +0000
+++ b/extras/mini-os/arch/x86/time.c    Fri Jan 18 18:01:42 2008 +0000
@@ -175,30 +175,32 @@ static void update_wallclock(void)
        do {
                shadow_ts_version = s->wc_version;
                rmb();
-               shadow_ts.ts_sec  = s->wc_sec;
-               shadow_ts.ts_nsec = s->wc_nsec;
+               shadow_ts.tv_sec  = s->wc_sec;
+               shadow_ts.tv_nsec = s->wc_nsec;
                rmb();
        }
        while ((s->wc_version & 1) | (shadow_ts_version ^ s->wc_version));
 }
 
 
-void gettimeofday(struct timeval *tv)
+int gettimeofday(struct timeval *tv, void *tz)
 {
     u64 nsec = monotonic_clock();
-    nsec += shadow_ts.ts_nsec;
+    nsec += shadow_ts.tv_nsec;
     
     
-    tv->tv_sec = shadow_ts.ts_sec;
+    tv->tv_sec = shadow_ts.tv_sec;
     tv->tv_sec += NSEC_TO_SEC(nsec);
     tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL);
+
+    return 0;
 }
 
 
 void block_domain(s_time_t until)
 {
     struct timeval tv;
-    gettimeofday(&tv);
+    gettimeofday(&tv, NULL);
     if(monotonic_clock() < until)
     {
         HYPERVISOR_set_timer_op(until);
diff -r 538a343f8e38 extras/mini-os/include/time.h
--- a/extras/mini-os/include/time.h     Fri Jan 18 16:43:44 2008 +0000
+++ b/extras/mini-os/include/time.h     Fri Jan 18 18:01:42 2008 +0000
@@ -38,20 +38,13 @@ typedef s64 s_time_t;
 #define Time_Max                ((s_time_t) 0x7fffffffffffffffLL)
 #define FOREVER                 Time_Max
 #define NSEC_TO_USEC(_nsec)     ((_nsec) / 1000UL)
+#define NSEC_TO_MSEC(_nsec)     ((_nsec) / 1000000ULL)
 #define NSEC_TO_SEC(_nsec)      ((_nsec) / 1000000000ULL)
 
 /* wall clock time  */
 typedef long time_t;
 typedef long suseconds_t;
-struct timeval {
-       time_t          tv_sec;         /* seconds */
-       suseconds_t     tv_usec;        /* microseconds */
-};
-
-struct timespec {
-    time_t      ts_sec;
-    long        ts_nsec;
-};
+#include <sys/time.h>
 
 
 /* prototypes */
@@ -59,7 +52,6 @@ s_time_t get_s_time(void);
 s_time_t get_s_time(void);
 s_time_t get_v_time(void);
 u64      monotonic_clock(void);
-void     gettimeofday(struct timeval *tv);
 void     block_domain(s_time_t until);
 
 #endif /* _TIME_H_ */
diff -r 538a343f8e38 extras/mini-os/kernel.c
--- a/extras/mini-os/kernel.c   Fri Jan 18 16:43:44 2008 +0000
+++ b/extras/mini-os/kernel.c   Fri Jan 18 18:01:42 2008 +0000
@@ -75,7 +75,7 @@ static void periodic_thread(void *p)
     printk("Periodic thread started.\n");
     for(;;)
     {
-        gettimeofday(&tv);
+        gettimeofday(&tv, NULL);
         printk("T(s=%ld us=%ld)\n", tv.tv_sec, tv.tv_usec);
         sleep(1000);
     }
diff -r 538a343f8e38 extras/mini-os/sched.c
--- a/extras/mini-os/sched.c    Fri Jan 18 16:43:44 2008 +0000
+++ b/extras/mini-os/sched.c    Fri Jan 18 18:01:42 2008 +0000
@@ -270,10 +270,10 @@ void th_f1(void *data)
         up(&mutex);
         
         
-        gettimeofday(&tv1);
+        gettimeofday(&tv1, NULL);
         for(;;)
         {
-            gettimeofday(&tv2);
+            gettimeofday(&tv2, NULL);
             if(tv2.tv_sec - tv1.tv_sec > 2) break;
         }
                 
diff -r 538a343f8e38 extras/mini-os/include/sys/time.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/extras/mini-os/include/sys/time.h Fri Jan 18 18:03:29 2008 +0000
@@ -0,0 +1,38 @@
+/* -*-  Mode:C; c-basic-offset:4; tab-width:4 -*-
+ ****************************************************************************
+ * (C) 2003 - Rolf Neugebauer - Intel Research Cambridge
+ * (C) 2005 - Grzegorz Milos - Intel Research Cambridge
+ ****************************************************************************
+ *
+ *        File: time.h
+ *      Author: Rolf Neugebauer (neugebar@xxxxxxxxxxxxx)
+ *     Changes: Grzegorz Milos (gm281@xxxxxxxxx)
+ *              Robert Kaiser (kaiser@xxxxxxxxxxxxxxxxxxxxxxxxxx)
+ *              
+ *        Date: Jul 2003, changes: Jun 2005, Sep 2006
+ * 
+ * Environment: Xen Minimal OS
+ * Description: Time and timer functions
+ *
+ ****************************************************************************
+ */
+
+#ifndef _MINIOS_SYS_TIME_H_
+#define _MINIOS_SYS_TIME_H_
+
+struct timespec {
+    time_t      tv_sec;
+    long        tv_nsec;
+};
+
+struct timezone {
+};
+
+struct timeval {
+       time_t          tv_sec;         /* seconds */
+       suseconds_t     tv_usec;        /* microseconds */
+};
+
+int      gettimeofday(struct timeval *tv, void *tz);
+
+#endif /* _MINIOS_SYS_TIME_H_ */

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] minios: make time interface POSIX, Samuel Thibault <=