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

[Minios-devel] [UNIKRAFT PATCH 2/3] lib/uktime: Introduce time_types.h for type defintions



We basically take the type definitions we used for nolibc and put them in
time_types.h.

In this patch we also add the changes for allowing custom definitions in libc
implementations. We allow for all libc implementations but for nolibc; the
alternative would have been to add empty headers in nolibc.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 .../include/nolibc-internal/shareddefs.h      | 41 +---------
 lib/uktime/include/uk/time_types.h            | 74 +++++++++++++++++++
 lib/uktime/musl-imported/include/sys/time.h   | 10 ++-
 lib/uktime/musl-imported/include/time.h       |  7 ++
 plat/xen/x86/arch_time.c                      |  2 +-
 5 files changed, 91 insertions(+), 43 deletions(-)
 create mode 100644 lib/uktime/include/uk/time_types.h

diff --git a/lib/nolibc/include/nolibc-internal/shareddefs.h 
b/lib/nolibc/include/nolibc-internal/shareddefs.h
index 9eb613a1..a1661081 100644
--- a/lib/nolibc/include/nolibc-internal/shareddefs.h
+++ b/lib/nolibc/include/nolibc-internal/shareddefs.h
@@ -65,46 +65,7 @@ typedef __off off_t;
 #define __DEFINED_off_t
 #endif
 
-#if (defined __NEED_time_t && !defined __DEFINED_time_t)
-typedef long time_t;
-#define __DEFINED_time_t
-#endif
-
-#if (defined __NEED_suseconds_t && !defined __DEFINED_suseconds_t)
-typedef long suseconds_t;
-#define __DEFINED_suseconds_t
-#endif
-
-#if (defined __NEED_struct_timeval && !defined __DEFINED_struct_timeval)
-struct timeval {
-       time_t      tv_sec;
-       suseconds_t tv_usec;
-};
-#define __DEFINED_struct_timeval
-#endif
-
-#if (defined __NEED_struct_timespec && !defined __DEFINED_struct_timespec)
-struct timespec {
-       time_t tv_sec;
-       long   tv_nsec;
-};
-#define __DEFINED_struct_timespec
-#endif
-
-#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
-typedef void *timer_t;
-#define __DEFINED_timer_t
-#endif
-
-#if (defined __NEED_clockid_t && !defined __DEFINED_clockid_t)
-typedef int clockid_t;
-#define __DEFINED_clockid_t
-#endif
-
-#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
-typedef long clock_t;
-#define __DEFINED_clock_t
-#endif
+#include <uk/time_types.h>
 
 #if (defined __NEED_mode_t && !defined __DEFINED_mode_t)
 typedef unsigned mode_t;
diff --git a/lib/uktime/include/uk/time_types.h 
b/lib/uktime/include/uk/time_types.h
new file mode 100644
index 00000000..d6b0083f
--- /dev/null
+++ b/lib/uktime/include/uk/time_types.h
@@ -0,0 +1,74 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
+ *
+ * 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.
+ */
+
+#if (defined __NEED_time_t && !defined __DEFINED_time_t)
+typedef long time_t;
+#define __DEFINED_time_t
+#endif
+
+#if (defined __NEED_suseconds_t && !defined __DEFINED_suseconds_t)
+typedef long suseconds_t;
+#define __DEFINED_suseconds_t
+#endif
+
+#if (defined __NEED_struct_timeval && !defined __DEFINED_struct_timeval)
+struct timeval {
+       time_t      tv_sec;
+       suseconds_t tv_usec;
+};
+#define __DEFINED_struct_timeval
+#endif
+
+#if (defined __NEED_struct_timespec && !defined __DEFINED_struct_timespec)
+struct timespec {
+       time_t tv_sec;
+       long   tv_nsec;
+};
+#define __DEFINED_struct_timespec
+#endif
+
+#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
+typedef void *timer_t;
+#define __DEFINED_timer_t
+#endif
+
+#if (defined __NEED_clockid_t && !defined __DEFINED_clockid_t)
+typedef int clockid_t;
+#define __DEFINED_clockid_t
+#endif
+
+#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
+typedef long clock_t;
+#define __DEFINED_clock_t
+#endif
diff --git a/lib/uktime/musl-imported/include/sys/time.h 
b/lib/uktime/musl-imported/include/sys/time.h
index 9bdb9739..bc76a32c 100644
--- a/lib/uktime/musl-imported/include/sys/time.h
+++ b/lib/uktime/musl-imported/include/sys/time.h
@@ -4,11 +4,17 @@
 extern "C" {
 #endif
 
+#include <uk/config.h>
+
 #define __NEED_time_t
 #define __NEED_suseconds_t
 #define __NEED_struct_timeval
-#include <sys/types.h>
-#include <sys/select.h>
+#include <uk/time_types.h>
+
+#ifndef CONFIG_LIBNOLIBC
+/* Allow custom definitions */
+#include_next <sys/time.h>
+#endif
 
 int gettimeofday (struct timeval *__restrict, void *__restrict);
 
diff --git a/lib/uktime/musl-imported/include/time.h 
b/lib/uktime/musl-imported/include/time.h
index 9a90d1e5..7cfcdba6 100644
--- a/lib/uktime/musl-imported/include/time.h
+++ b/lib/uktime/musl-imported/include/time.h
@@ -5,6 +5,8 @@
 extern "C" {
 #endif
 
+#include <uk/config.h>
+
 #define __NEED_size_t
 #define __NEED_time_t
 #define __NEED_clock_t
@@ -16,6 +18,11 @@ extern "C" {
 
 #include <sys/types.h>
 
+#ifndef CONFIG_LIBNOLIBC
+/* Allow custom definitions */
+#include_next <time.h>
+#endif
+
 #if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
 #define __tm_gmtoff tm_gmtoff
 #define __tm_zone tm_zone
diff --git a/plat/xen/x86/arch_time.c b/plat/xen/x86/arch_time.c
index c6b8d02d..1c87be4f 100644
--- a/plat/xen/x86/arch_time.c
+++ b/plat/xen/x86/arch_time.c
@@ -35,7 +35,7 @@
 
 #include <stddef.h>
 #include <stdint.h>
-#include <sys/time.h>
+#include <time.h>
 #include <uk/plat/time.h>
 #include <x86/cpu.h>
 #include <_time.h>
-- 
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®.