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

Re: [Minios-devel] [UNIKRAFT PATCH 6/7] lib/nolibc: Implement gettimeofday()



Hi Florian,

Looks good, thanks.

— Felipe

Reviewed-by: Felipe Huici <felipe.huici@xxxxxxxxx>

> On 22. Feb 2019, at 15:12, Florian Schmidt <Florian.Schmidt@xxxxxxxxx> wrote:
> 
> Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
> ---
> lib/nolibc/exportsyms.uk      |  3 +++
> lib/nolibc/include/sys/time.h |  1 -
> lib/nolibc/time.c             | 15 +++++++++++++++
> plat/xen/x86/arch_time.c      | 19 -------------------
> 4 files changed, 18 insertions(+), 20 deletions(-)
> 
> diff --git a/lib/nolibc/exportsyms.uk b/lib/nolibc/exportsyms.uk
> index b2ebb8d6..a26440c9 100644
> --- a/lib/nolibc/exportsyms.uk
> +++ b/lib/nolibc/exportsyms.uk
> @@ -72,6 +72,9 @@ strlcat
> # time
> nanosleep
> 
> +# sys/time
> +gettimeofday
> +
> # ctype
> _nolibc_ctype
> 
> diff --git a/lib/nolibc/include/sys/time.h b/lib/nolibc/include/sys/time.h
> index e08fa85e..d2c8904d 100644
> --- a/lib/nolibc/include/sys/time.h
> +++ b/lib/nolibc/include/sys/time.h
> @@ -52,7 +52,6 @@ struct itimerval {
>       struct timeval it_value;
> };
> 
> -/* TODO: Implement */
> int gettimeofday(struct timeval *tv, void *tz);
> 
> #ifdef __cplusplus
> diff --git a/lib/nolibc/time.c b/lib/nolibc/time.c
> index 78b1b4b7..b15d7e0d 100644
> --- a/lib/nolibc/time.c
> +++ b/lib/nolibc/time.c
> @@ -44,6 +44,7 @@
> #else
> #include <uk/plat/lcpu.h>
> #endif
> +#include <uk/essentials.h>
> 
> #ifndef CONFIG_HAVE_SCHED
> /* Workaround until Unikraft changes interface for something more
> @@ -90,3 +91,17 @@ int nanosleep(const struct timespec *req, struct timespec 
> *rem)
>       }
>       return 0;
> }
> +
> +int gettimeofday(struct timeval *tv, void *tz __unused)
> +{
> +     __nsec now = ukplat_wall_clock();
> +
> +     if (!tv) {
> +             errno = EINVAL;
> +             return -1;
> +     }
> +
> +     tv->tv_sec = ukarch_time_nsec_to_sec(now);
> +     tv->tv_usec = ukarch_time_nsec_to_usec(ukarch_time_subsec(now));
> +     return 0;
> +}
> diff --git a/plat/xen/x86/arch_time.c b/plat/xen/x86/arch_time.c
> index d36f9632..c6b8d02d 100644
> --- a/plat/xen/x86/arch_time.c
> +++ b/plat/xen/x86/arch_time.c
> @@ -209,25 +209,6 @@ __nsec ukplat_wall_clock(void)
>       return ret;
> }
> 
> -#if 0 /* TODO */
> -int gettimeofday(struct timeval *tv, void *tz)
> -{
> -     uint64_t nsec = monotonic_clock();
> -
> -     if (!wc_values_up_to_date())
> -             update_wallclock();
> -
> -     nsec += shadow_ts.tv_nsec;
> -
> -     tv->tv_sec = shadow_ts.tv_sec;
> -     tv->tv_sec += NSEC_TO_SEC(nsec);
> -     tv->tv_usec = NSEC_TO_USEC(nsec % 1000000000UL);
> -
> -     return 0;
> -}
> -#endif
> -
> -
> void time_block_until(__snsec until)
> {
>       UK_ASSERT(irqs_disabled());
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> Minios-devel mailing list
> Minios-devel@xxxxxxxxxxxxxxxxxxxx
> https://lists.xenproject.org/mailman/listinfo/minios-devel

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