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

[Minios-devel] [UNIKRAFT PATCH v2 2/3] lib/uktime: Adapt timegm implementation to Unikraft


  • To: "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Wed, 11 Sep 2019 15:00:18 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=stud.acs.upb.ro; dmarc=pass action=none header.from=stud.acs.upb.ro; dkim=pass header.d=stud.acs.upb.ro; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YeOVlXmxjDPbitF4Vbhe22SEllvve3qVBQQpfXxhijs=; b=VUAdzUWtvT1oMMM/p3j+1H6dXVPF6SAS1Uzw9ncB1phDIxzAh24kw/mxqSz9twQIPCsz2Xpq0R3d/8EUd6GeSw2bY9v99qDtDHYPKWjCqFpiwnH2usvp+r6gRG5bUg3i7OxZJHQXfPQ3V1nA3SQWXiHm4u4lfDD233t1YpNZ20j8RDtWeNBjGQz1T9FU+BVMEwRu4prWSHHHuEZOT1Yhv2BPRO9wGr8oOtYrTGsU5+K3Evf5V2USpDeoQQBzSu64gcYOMWcy+iRvG2QFGiKiCoUjBhkrPONTsNRADy8pcpaedNZG968M/H5cCUCes4Sy5VsYxG1zvV1Vyfcnrd9Avw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a82F/K1ZcZ5OVFaAO1vEY2JfBksdIWZKn/1zzZluDIpdPPHlj9drIzVdcnnv9iop3EwSivSbvCMtaQm+DofvrZPlAkU2/gS569yeD02tLdW/KZ7Ig2+AyZr/i18DxFTfjJklLP+gkaf8b7r5k89seY1g9nopAfoq8DqKo/0nwE6gtn3302xVTd2lIy9eD+abG3BGt0IAFLxqbKHON6AnsFkFtwA/aPNZfQ+vq5SLxgu+ehLVp9Nvb1TLy0SmcQTPdvkoNF5LcMZdUwM37WWev3cILKTk/MavLgTmm+YUS8jYHveDsKn2JPHbCcpsSjo8dtUvluvUWxIIDEPR/CezZQ==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vlad_andrei.badoiu@xxxxxxxxxxxxxxx;
  • Cc: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>, "costin.lupu@xxxxxxxxx" <costin.lupu@xxxxxxxxx>
  • Delivery-date: Wed, 11 Sep 2019 15:00:35 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHVaLGgYD5Dlx4fiEipxyXYBR+XjQ==
  • Thread-topic: [UNIKRAFT PATCH v2 2/3] lib/uktime: Adapt timegm implementation to Unikraft

We exclude from uktime/time.h the functions that have not been implemented in
Unikraft. _time_types.h holds the definitions of the types used
in uktime/time.h

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
 lib/uktime/Makefile.uk                        | 13 +++-
 lib/uktime/exportsyms.uk                      |  2 +-
 lib/uktime/include/uktime/_time_types.h       | 62 +++++++++++++++++++
 lib/uktime/musl-imported/include/time_impl.h  | 16 ++---
 .../musl-imported/include/uktime/time.h       | 40 +++++++-----
 lib/uktime/musl-imported/src/timegm.c         |  2 +
 6 files changed, 108 insertions(+), 27 deletions(-)
 create mode 100644 lib/uktime/include/uktime/_time_types.h

diff --git a/lib/uktime/Makefile.uk b/lib/uktime/Makefile.uk
index 9c1f8b35..62bee914 100644
--- a/lib/uktime/Makefile.uk
+++ b/lib/uktime/Makefile.uk
@@ -1,4 +1,13 @@
 $(eval $(call addlib_s,libuktime,$(CONFIG_LIBUKTIME)))
 
-CINCLUDES-$(CONFIG_LIBUKTIME)    += -I$(LIBUKTIME_BASE)/include
-CXXINCLUDES-$(CONFIG_LIBUKTIME)  += -I$(LIBUKTIME_BASE)/include
+LIBUKTIME_COMMON_INCLUDES-y    += -I$(LIBUKTIME_BASE)/include
+LIBUKTIME_COMMON_INCLUDES-y    += -I$(LIBUKTIME_BASE)/musl-imported/include
+
+CINCLUDES-$(CONFIG_LIBUKTIME)    += $(LIBUKTIME_COMMON_INCLUDES-y)
+CXXINCLUDES-$(CONFIG_LIBUKTIME)  += $(LIBUKTIME_COMMON_INCLUDES-y)
+
+LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/musl-imported/src/__month_to_secs.c
+LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/musl-imported/src/__secs_to_tm.c
+LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/musl-imported/src/timegm.c
+LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/musl-imported/src/__tm_to_secs.c
+LIBUKTIME_SRCS-y += $(LIBUKTIME_BASE)/musl-imported/src/__year_to_secs.c
diff --git a/lib/uktime/exportsyms.uk b/lib/uktime/exportsyms.uk
index c86c3f35..a00d1601 100644
--- a/lib/uktime/exportsyms.uk
+++ b/lib/uktime/exportsyms.uk
@@ -1 +1 @@
-none
\ No newline at end of file
+timegm
diff --git a/lib/uktime/include/uktime/_time_types.h 
b/lib/uktime/include/uktime/_time_types.h
new file mode 100644
index 00000000..7afd3c7c
--- /dev/null
+++ b/lib/uktime/include/uktime/_time_types.h
@@ -0,0 +1,62 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Florian Schmidt <florian.schmidt@xxxxxxxxx>
+ *
+ * Copyright (c) 2018, NEC Labs Europe, NEC Corporation. All rights reserved.
+ * Copyright (c) 2019, University Politehnica of Bucharest. All rights 
reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the copyright holder nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
+ */
+
+/* This header does by design not have include guards, so that it can be
+ * included from multiple files. The __NEED_x macros instead make sure that
+ * only those definitions are included that are required by that specific
+ * file, and only if they haven't been defined on a previous pass through
+ * this file.
+ */
+
+#include <uk/arch/types.h>
+
+#if (defined __NEED_clockid_t && !defined __DEFINED_clockid_t)
+typedef int clockid_t;
+#define __DEFINED_clockid_t
+#endif
+
+#if (defined __NEED_time_t && !defined __DEFINED_time_t)
+typedef long time_t;
+#define __DEFINED_time_t
+#endif
+
+#if (defined __NEED_struct_timespec &&                 \
+               !defined __DEFINED_struct_timespec)
+struct timespec {
+       time_t  tv_sec;
+       long    tv_nsec;
+};
+#define __DEFINED_struct_timespec
+#endif
diff --git a/lib/uktime/musl-imported/include/time_impl.h 
b/lib/uktime/musl-imported/include/time_impl.h
index f26d8005..fb59fc1a 100644
--- a/lib/uktime/musl-imported/include/time_impl.h
+++ b/lib/uktime/musl-imported/include/time_impl.h
@@ -1,11 +1,7 @@
-#include <time.h>
+#include <uktime/time.h>
 
-hidden int __days_in_month(int, int);
-hidden int __month_to_secs(int, int);
-hidden long long __year_to_secs(long long, int *);
-hidden long long __tm_to_secs(const struct tm *);
-hidden const char *__tm_to_tzname(const struct tm *);
-hidden int __secs_to_tm(long long, struct tm *);
-hidden void __secs_to_zone(long long, int, int *, long *, long *, const char 
**);
-hidden const char *__strftime_fmt_1(char (*)[100], size_t *, int, const struct 
tm *, locale_t, int);
-extern hidden const char __utc[];
+int __month_to_secs(int, int);
+long long __year_to_secs(long long, int *);
+long long __tm_to_secs(const struct tm *);
+int __secs_to_tm(long long, struct tm *);
+extern const char __utc[];
diff --git a/lib/uktime/musl-imported/include/uktime/time.h 
b/lib/uktime/musl-imported/include/uktime/time.h
index 672b3fc3..a77926c1 100644
--- a/lib/uktime/musl-imported/include/uktime/time.h
+++ b/lib/uktime/musl-imported/include/uktime/time.h
@@ -1,18 +1,17 @@
-#ifndef        _TIME_H
-#define _TIME_H
+#ifndef _UKTIME_TIME_H
+#define _UKTIME_TIME_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <uk/config.h>
 
-#include <features.h>
+#ifdef CONFIG_LIBNOLIBC
+#include <sys/time.h>
+#endif
 
 #ifdef __cplusplus
-#define NULL 0L
-#else
-#define NULL ((void*)0)
+extern "C" {
 #endif
 
+#define _GNU_SOURCE
 
 #define __NEED_size_t
 #define __NEED_time_t
@@ -28,7 +27,12 @@ extern "C" {
 #define __NEED_locale_t
 #endif
 
-#include <bits/alltypes.h>
+#include <uktime/_time_types.h>
+#ifdef CONFIG_LIBNOLIBC
+#include <nolibc-internal/shareddefs.h>
+#else
+#include <stddef.h>
+#endif
 
 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
 #define __tm_gmtoff tm_gmtoff
@@ -49,6 +53,7 @@ struct tm {
        const char *__tm_zone;
 };
 
+#if 0
 clock_t clock (void);
 time_t time (time_t *);
 double difftime (time_t, time_t);
@@ -59,6 +64,7 @@ struct tm *localtime (const time_t *);
 char *asctime (const struct tm *);
 char *ctime (const time_t *);
 int timespec_get(struct timespec *, int);
+#endif
 
 #define CLOCKS_PER_SEC 1000000L
 
@@ -68,6 +74,7 @@ int timespec_get(struct timespec *, int);
  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
  || defined(_BSD_SOURCE)
 
+#if 0
 size_t strftime_l (char *  __restrict, size_t, const char *  __restrict, const 
struct tm *  __restrict, locale_t);
 
 struct tm *gmtime_r (const time_t *__restrict, struct tm *__restrict);
@@ -76,6 +83,7 @@ char *asctime_r (const struct tm *__restrict, char 
*__restrict);
 char *ctime_r (const time_t *, char *);
 
 void tzset (void);
+#endif
 
 struct itimerspec {
        struct timespec it_interval;
@@ -98,8 +106,11 @@ struct itimerspec {
 #define TIMER_ABSTIME 1
 
 int nanosleep (const struct timespec *, struct timespec *);
+#if 0
 int clock_getres (clockid_t, struct timespec *);
+#endif
 int clock_gettime (clockid_t, struct timespec *);
+#if 0
 int clock_settime (clockid_t, const struct timespec *);
 int clock_nanosleep (clockid_t, int, const struct timespec *, struct timespec 
*);
 int clock_getcpuclockid (pid_t, clockid_t *);
@@ -112,10 +123,10 @@ int timer_gettime (timer_t, struct itimerspec *);
 int timer_getoverrun (timer_t);
 
 extern char *tzname[2];
-
+#endif
 #endif
 
-
+#if 0
 #if defined(_XOPEN_SOURCE) || defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
 char *strptime (const char *__restrict, const char *__restrict, struct tm 
*__restrict);
 extern int daylight;
@@ -123,10 +134,12 @@ extern long timezone;
 extern int getdate_err;
 struct tm *getdate (const char *);
 #endif
-
+#endif
 
 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
+#if 0
 int stime(const time_t *);
+#endif
 time_t timegm(struct tm *);
 #endif
 
@@ -134,5 +147,4 @@ time_t timegm(struct tm *);
 }
 #endif
 
-
 #endif
diff --git a/lib/uktime/musl-imported/src/timegm.c 
b/lib/uktime/musl-imported/src/timegm.c
index 4e5907d7..80e2506d 100644
--- a/lib/uktime/musl-imported/src/timegm.c
+++ b/lib/uktime/musl-imported/src/timegm.c
@@ -2,6 +2,8 @@
 #include "time_impl.h"
 #include <errno.h>
 
+const char __utc[] = "UTC";
+
 time_t timegm(struct tm *tm)
 {
        struct tm new;
-- 
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®.