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

Re: [Minios-devel] [UNIKRAFT PATCH v2 6/6] lib/nolibc: put time value definitions in correct files



Reviewed-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>

On 17.08.2018 09:56, Florian Schmidt wrote:
sys/time.h provides timeval, not timespec. It doesn't provide a forward
declaration of a struct timezone. Finally, it may make visible all
symbols provided by sys/select.h, so we might as well do that in case
some application relies on this optionally allowed behavior.

Provide timespec in time.h, and change the include to fix a resulting
compile error.

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
  .../include/nolibc-internal/shareddefs.h      | 26 +++++++++
  lib/nolibc/include/sys/time.h                 | 21 +++----
  lib/nolibc/include/time.h                     | 56 +++++++++++++++++++
  plat/linuxu/include/linuxu/syscall.h          |  2 +-
  4 files changed, 91 insertions(+), 14 deletions(-)
  create mode 100644 lib/nolibc/include/time.h

diff --git a/lib/nolibc/include/nolibc-internal/shareddefs.h 
b/lib/nolibc/include/nolibc-internal/shareddefs.h
index 6503ab1..9b81fab 100644
--- a/lib/nolibc/include/nolibc-internal/shareddefs.h
+++ b/lib/nolibc/include/nolibc-internal/shareddefs.h
@@ -64,3 +64,29 @@ typedef __ssz ssize_t;
  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
diff --git a/lib/nolibc/include/sys/time.h b/lib/nolibc/include/sys/time.h
index 3c45581..11f89bb 100644
--- a/lib/nolibc/include/sys/time.h
+++ b/lib/nolibc/include/sys/time.h
@@ -37,27 +37,22 @@
  #define __SYS_TIME_H__
#include <uk/plat/time.h>
+#include <sys/select.h>
#ifdef __cplusplus
  extern "C" {
  #endif
-typedef long time_t;
-typedef long suseconds_t;
+#define __NEED_time_t
+#define __NEED_suseconds_t
+#define __NEED_struct_timeval
+#include <nolibc-internal/shareddefs.h>
-struct timespec {
-       time_t      tv_sec;
-       long        tv_nsec;
+struct itimerval {
+       struct timeval it_interval;
+       struct timeval it_value;
  };
-struct timezone;
-
-struct timeval {
-       time_t      tv_sec;     /* seconds */
-       suseconds_t tv_usec;    /* microseconds */
-};
-
-
  /* TODO: Implement */
  int gettimeofday(struct timeval *tv, void *tz);
diff --git a/lib/nolibc/include/time.h b/lib/nolibc/include/time.h
new file mode 100644
index 0000000..26270bf
--- /dev/null
+++ b/lib/nolibc/include/time.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Authors: Florian Schmidt <florian.schmidt@xxxxxxxxx>
+ *
+ * Copyright (c) 2018, NEC Europe Ltd., NEC Corporation. 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.
+ */
+
+#ifndef __TIME_H__
+#define __TIME_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define __NEED_NULL
+#define __NEED_time_t
+#define __NEED_struct_timespec
+#include <nolibc-internal/shareddefs.h>
+
+struct itimerspec {
+       struct timespec it_interval;
+       struct timespec it_value;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIME_H__ */
diff --git a/plat/linuxu/include/linuxu/syscall.h 
b/plat/linuxu/include/linuxu/syscall.h
index 1b0a3bc..7ebc9c0 100644
--- a/plat/linuxu/include/linuxu/syscall.h
+++ b/plat/linuxu/include/linuxu/syscall.h
@@ -36,9 +36,9 @@
  #ifndef __SYSCALL_H__
  #define __SYSCALL_H__
+#include <time.h>
  #include <sys/types.h>
  #include <sys/select.h>
-#include <sys/time.h>
#if defined __X86_64__
  #include <linuxu/syscall-x86_64.h>


_______________________________________________
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®.