You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/04/19 10:43:03 UTC

[GitHub] mkiiskila closed pull request #1036: os; add os_get_uptime()

mkiiskila closed pull request #1036: os; add os_get_uptime()
URL: https://github.com/apache/mynewt-core/pull/1036
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/kernel/os/include/os/os_time.h b/kernel/os/include/os/os_time.h
index 25f076b40..52beb2bd2 100644
--- a/kernel/os/include/os/os_time.h
+++ b/kernel/os/include/os/os_time.h
@@ -184,6 +184,13 @@ int os_gettimeofday(struct os_timeval *utctime, struct os_timezone *tz);
  */
 int64_t os_get_uptime_usec(void);
 
+/**
+ * Get time since boot as os_timeval.
+ *
+ * @param tv Structure to put the time since boot.
+ */
+void os_get_uptime(struct os_timeval *tvp);
+
 /**
  * Converts milliseconds to OS ticks.
  *
diff --git a/kernel/os/src/os_time.c b/kernel/os/src/os_time.c
index 31bb478a4..a9cbf1671 100644
--- a/kernel/os/src/os_time.c
+++ b/kernel/os/src/os_time.c
@@ -161,24 +161,31 @@ os_gettimeofday(struct os_timeval *tv, struct os_timezone *tz)
     return (0);
 }
 
-int64_t
-os_get_uptime_usec(void)
+void
+os_get_uptime(struct os_timeval *tvp)
 {
   struct os_timeval tv;
   os_time_t delta;
   os_sr_t sr;
   os_time_t ostime;
 
-
   OS_ENTER_CRITICAL(sr);
   tv = basetod.uptime;
   ostime = basetod.ostime;
   delta = os_time_get() - ostime;
   OS_EXIT_CRITICAL(sr);
 
-  os_deltatime(delta, &tv, &tv);
+  os_deltatime(delta, &tv, tvp);
+}
+
+int64_t
+os_get_uptime_usec(void)
+{
+  struct os_timeval tv;
+
+  os_get_uptime(&tv);
 
-  return(tv.tv_sec * 1000000 + tv.tv_usec);
+  return (tv.tv_sec * 1000000 + tv.tv_usec);
 }
 
 int


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services