|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XTF 2/6] time: add current_time() function to time management
From: Paul Semel <phentex@xxxxxxxxx>
This function returns the "epoch" time.
Signed-off-by: Paul Semel <phentex@xxxxxxxxx>
---
common/time.c | 16 ++++++++++++++++
include/xtf/time.h | 4 ++++
2 files changed, 20 insertions(+)
diff --git a/common/time.c b/common/time.c
index b9a6531..7decd07 100644
--- a/common/time.c
+++ b/common/time.c
@@ -74,6 +74,22 @@ uint64_t since_boot_time(void)
return system_time;
}
+/* This function return the epoch time (number of seconds elapsed
+ * since Juanary 1, 1970) */
+#if defined(__i386__)
+uint32_t current_time(void)
+#else
+uint64_t current_time(void)
+#endif
+{
+#if defined(__i386__)
+ uint32_t seconds = shared_info.wc_sec;
+#else
+ uint64_t seconds = ((uint64_t)shared_info.wc_sec_hi << 32) |
shared_info.wc_sec;
+#endif
+ return seconds + (since_boot_time() / 1000000000);
+}
+
/*
* Local variables:
* mode: C
diff --git a/include/xtf/time.h b/include/xtf/time.h
index e30d109..52da27a 100644
--- a/include/xtf/time.h
+++ b/include/xtf/time.h
@@ -11,8 +11,12 @@
#if defined(__i386__)
/* Time from boot in nanoseconds */
uint32_t since_boot_time(void);
+
+uint32_t current_time(void);
#else
uint64_t since_boot_time(void);
+
+uint64_t current_time(void);
#endif
#endif /* XTF_TIME_H */
--
2.16.6
Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |