[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Minios-devel] [UNIKRAFT PATCH v3 2/3] lib/uktime: Adapt timegm implementation to Unikraft
Thanks for the patch, Vlad! We also need to add -I$(LIBUKTIME_BASE)/musl-imported/include to global include paths, but we can do that on upstreaming. Reviewed-by: Costin Lupu <costin.lupu@xxxxxxxxx> On 9/12/19 2:31 PM, Vlad-Andrei BĂDOIU (78692) wrote: > 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 | 15 +++++- > lib/uktime/exportsyms.uk | 2 +- > lib/uktime/include/uktime/_time_types.h | 62 ++++++++++++++++++++++++ > lib/uktime/musl-imported/include/time.h | 40 +++++++++------ > lib/uktime/musl-imported/src/time_impl.h | 14 ++---- > lib/uktime/musl-imported/src/timegm.c | 2 + > 6 files changed, 109 insertions(+), 26 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..1ba83c8f 100644 > --- a/lib/uktime/Makefile.uk > +++ b/lib/uktime/Makefile.uk > @@ -1,4 +1,15 @@ > $(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_CFLAGS-y += -D_TIME_H_ > + > +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.h > b/lib/uktime/musl-imported/include/time.h > index 672b3fc3..a77926c1 100644 > --- a/lib/uktime/musl-imported/include/time.h > +++ b/lib/uktime/musl-imported/include/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/time_impl.h > b/lib/uktime/musl-imported/src/time_impl.h > index f26d8005..0af063ed 100644 > --- a/lib/uktime/musl-imported/src/time_impl.h > +++ b/lib/uktime/musl-imported/src/time_impl.h > @@ -1,11 +1,7 @@ > #include <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/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; > _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |