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

Re: [Minios-devel] [UNIKRAFT v2 8/8] lib/uktime: Fix build with nolibc



Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@xxxxxxxxx>

On 04.10.2019 10:51, Costin Lupu wrote:
* Remove time.h and sys/time.h headers. We will use the ones from lib/uktime.
* Add missing type definitions in nolibc-internal/shareddefs.h: timer_t,
   clock_t, locale_t, useconds_t.
* There is no ENODATA in nolibc, so we set errno to ENOTSUP in times().
* Fix 'no new line at end of file' warning in Config.uk. It seems that
   Config.uk must end with an empty line, otherwise we will get 'no new line at
   end of file' warnings. This does not occur only for nolibc, but we're
   squeezing this here anyway.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
  .../include/nolibc-internal/shareddefs.h      | 20 ++++++
  lib/nolibc/include/sys/time.h                 | 61 -----------------
  lib/nolibc/include/sys/types.h                |  3 +
  lib/nolibc/include/time.h                     | 65 -------------------
  lib/nolibc/include/unistd.h                   |  1 +
  lib/uktime/Config.uk                          |  2 +-
  lib/uktime/musl-imported/include/sys/time.h   |  3 +
  lib/uktime/time.c                             |  2 +-
  8 files changed, 29 insertions(+), 128 deletions(-)
  delete mode 100644 lib/nolibc/include/sys/time.h
  delete 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 3bd449a7..9eb613a1 100644
--- a/lib/nolibc/include/nolibc-internal/shareddefs.h
+++ b/lib/nolibc/include/nolibc-internal/shareddefs.h
@@ -91,11 +91,21 @@ struct timespec {
  #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
+
  #if (defined __NEED_mode_t && !defined __DEFINED_mode_t)
  typedef unsigned mode_t;
  #define __DEFINED_mode_t
@@ -111,6 +121,11 @@ typedef unsigned gid_t;
  #define __DEFINED_gid_t
  #endif
+#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
+typedef unsigned useconds_t;
+#define __DEFINED_useconds_t
+#endif
+
  #if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
  typedef int pid_t;
  #define __DEFINED_pid_t
@@ -141,6 +156,11 @@ typedef long blksize_t;
  #define __DEFINED_blksize_t
  #endif
+#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
+typedef struct __locale_struct *locale_t;
+#define __DEFINED_locale_t
+#endif
+
  #if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
  struct iovec { void *iov_base; size_t iov_len; };
  #define __DEFINED_struct_iovec
diff --git a/lib/nolibc/include/sys/time.h b/lib/nolibc/include/sys/time.h
deleted file mode 100644
index d2c8904d..00000000
--- a/lib/nolibc/include/sys/time.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Costin Lupu <costin.lupu@xxxxxxxxx>
- *          Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
- *
- * Copyright (c) 2017, 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 __SYS_TIME_H__
-#define __SYS_TIME_H__
-
-#include <sys/select.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define __NEED_time_t
-#define __NEED_suseconds_t
-#define __NEED_struct_timeval
-#include <nolibc-internal/shareddefs.h>
-
-struct itimerval {
-       struct timeval it_interval;
-       struct timeval it_value;
-};
-
-int gettimeofday(struct timeval *tv, void *tz);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SYS_TIME_H__ */
diff --git a/lib/nolibc/include/sys/types.h b/lib/nolibc/include/sys/types.h
index c08d4d77..412d1ff0 100644
--- a/lib/nolibc/include/sys/types.h
+++ b/lib/nolibc/include/sys/types.h
@@ -47,8 +47,11 @@ extern "C" {
  #define __NEED_ssize_t
  #define __NEED_off_t
  #define __NEED_time_t
+#define __NEED_timer_t
  #define __NEED_suseconds_t
+#define __NEED_clock_t
  #define __NEED_clockid_t
+#define __NEED_locale_t
  #define __NEED_mode_t
  #define __NEED_uid_t
  #define __NEED_gid_t
diff --git a/lib/nolibc/include/time.h b/lib/nolibc/include/time.h
deleted file mode 100644
index f77bb2fd..00000000
--- a/lib/nolibc/include/time.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* 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__
-
-#include <sys/time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define __NEED_NULL
-#define __NEED_time_t
-#define __NEED_struct_timespec
-#define __NEED_clockid_t
-#include <nolibc-internal/shareddefs.h>
-
-#define CLOCK_REALTIME  0
-#define CLOCK_MONOTONIC 1
-
-struct itimerspec {
-       struct timespec it_interval;
-       struct timespec it_value;
-};
-
-int nanosleep(const struct timespec *req, struct timespec *rem);
-int clock_gettime(clockid_t clk, struct timespec *tp);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __TIME_H__ */
diff --git a/lib/nolibc/include/unistd.h b/lib/nolibc/include/unistd.h
index e9b4f348..a6986873 100644
--- a/lib/nolibc/include/unistd.h
+++ b/lib/nolibc/include/unistd.h
@@ -46,6 +46,7 @@ extern "C" {
  #define __NEED_size_t
  #define __NEED_ssize_t
  #define __NEED_off_t
+#define __NEED_useconds_t
/*
   * Sysconf name values
diff --git a/lib/uktime/Config.uk b/lib/uktime/Config.uk
index a68e3f4e..1c634f27 100644
--- a/lib/uktime/Config.uk
+++ b/lib/uktime/Config.uk
@@ -1,3 +1,3 @@
  config LIBUKTIME
         bool "uktime: Time functions"
-       default n
\ No newline at end of file
+       default n
diff --git a/lib/uktime/musl-imported/include/sys/time.h 
b/lib/uktime/musl-imported/include/sys/time.h
index b1fdc8aa..9bdb9739 100644
--- a/lib/uktime/musl-imported/include/sys/time.h
+++ b/lib/uktime/musl-imported/include/sys/time.h
@@ -4,6 +4,9 @@
  extern "C" {
  #endif
+#define __NEED_time_t
+#define __NEED_suseconds_t
+#define __NEED_struct_timeval
  #include <sys/types.h>
  #include <sys/select.h>
diff --git a/lib/uktime/time.c b/lib/uktime/time.c
index 0c92b615..da7da72b 100644
--- a/lib/uktime/time.c
+++ b/lib/uktime/time.c
@@ -175,6 +175,6 @@ int clock_settime(clockid_t clk_id __unused, const struct 
timespec *tp __unused)
int times(struct tm *buf __unused)
  {
-       errno = ENODATA;
+       errno = ENOTSUP;
        return -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®.