[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT v2 7/8] lib/uktime: Add the missing changes from newlib's time.c


  • To: minios-devel@xxxxxxxxxxxxx
  • From: Costin Lupu <costin.lupu@xxxxxxxxx>
  • Date: Fri, 4 Oct 2019 10:51:38 +0300
  • Delivery-date: Fri, 04 Oct 2019 07:52:22 +0000
  • Ironport-sdr: oF0w5kqnWDLSPq0hyukYfjvaoC7rIGgqJ/CWbjuhUD7d7CnJDC8HyNH8J+q3JU4yhEZFCwvhB/ 8jiEfAWBh8GA==
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>

This patch copies the changes that were only in the newlib's time.c.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 lib/uktime/exportsyms.uk |  5 +++++
 lib/uktime/time.c        | 41 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/lib/uktime/exportsyms.uk b/lib/uktime/exportsyms.uk
index 3c17d35a..1a4a2b1a 100644
--- a/lib/uktime/exportsyms.uk
+++ b/lib/uktime/exportsyms.uk
@@ -1,5 +1,10 @@
+clock_getres
 clock_gettime
+clock_settime
 gettimeofday
 nanosleep
 sleep
 timegm
+times
+usleep
+utime
diff --git a/lib/uktime/time.c b/lib/uktime/time.c
index f884531f..0c92b615 100644
--- a/lib/uktime/time.c
+++ b/lib/uktime/time.c
@@ -35,16 +35,23 @@
  * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
  */
 
+#include <errno.h>
 #include <time.h>
+#include <utime.h>
+#include <unistd.h>
+#include <sys/time.h>
 #include <uk/plat/time.h>
-#include <errno.h>
 #include <uk/config.h>
 #if CONFIG_HAVE_SCHED
 #include <uk/sched.h>
 #else
 #include <uk/plat/lcpu.h>
 #endif
-#include <uk/essentials.h>
+
+int utime(const char *filename __unused, const struct utimbuf *times __unused)
+{
+       return 0;
+}
 
 #ifndef CONFIG_HAVE_SCHED
 /* Workaround until Unikraft changes interface for something more
@@ -92,6 +99,18 @@ int nanosleep(const struct timespec *req, struct timespec 
*rem)
        return 0;
 }
 
+int usleep(useconds_t usec)
+{
+       struct timespec ts;
+
+       ts.tv_sec = (long int) (usec / 1000000);
+       ts.tv_nsec = (long int) ukarch_time_usec_to_nsec(usec % 1000000);
+       if (nanosleep(&ts, &ts))
+               return -1;
+
+       return 0;
+}
+
 unsigned int sleep(unsigned int seconds)
 {
        struct timespec ts;
@@ -118,7 +137,12 @@ int gettimeofday(struct timeval *tv, void *tz __unused)
        return 0;
 }
 
-int clock_gettime(clockid_t clk_id, struct timespec *tp)
+int clock_getres(clockid_t clk_id __unused, struct timespec *res __unused)
+{
+       return 0;
+}
+
+int clock_gettime(clockid_t clk_id __unused, struct timespec *tp __unused)
 {
        __nsec now;
 
@@ -143,3 +167,14 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp)
        tp->tv_nsec = ukarch_time_subsec(now);
        return 0;
 }
+
+int clock_settime(clockid_t clk_id __unused, const struct timespec *tp 
__unused)
+{
+       return 0;
+}
+
+int times(struct tm *buf __unused)
+{
+       errno = ENODATA;
+       return -1;
+}
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.