[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 2/4] lib/uktime: Adapt timegm implementation to Unikraft
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 | 13 ++++++- lib/uktime/exportsyms.uk | 2 +- lib/uktime/include/_time_types.h | 22 +++++++++++ .../musl-imported/include/_time_types.h | 21 ++++++++++ lib/uktime/musl-imported/include/time_impl.h | 16 +++----- .../musl-imported/include/uktime/time.h | 38 ++++++++++++++----- lib/uktime/musl-imported/src/timegm.c | 2 + 7 files changed, 92 insertions(+), 22 deletions(-) create mode 100644 lib/uktime/include/_time_types.h create mode 100644 lib/uktime/musl-imported/include/_time_types.h diff --git a/lib/uktime/Makefile.uk b/lib/uktime/Makefile.uk index 9c1f8b35..62bee914 100644 --- a/lib/uktime/Makefile.uk +++ b/lib/uktime/Makefile.uk @@ -1,4 +1,13 @@ $(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_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/_time_types.h b/lib/uktime/include/_time_types.h new file mode 100644 index 00000000..945de02b --- /dev/null +++ b/lib/uktime/include/_time_types.h @@ -0,0 +1,22 @@ +#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_types.h b/lib/uktime/musl-imported/include/_time_types.h new file mode 100644 index 00000000..839921a2 --- /dev/null +++ b/lib/uktime/musl-imported/include/_time_types.h @@ -0,0 +1,21 @@ +#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_impl.h b/lib/uktime/musl-imported/include/time_impl.h index f26d8005..fb59fc1a 100644 --- a/lib/uktime/musl-imported/include/time_impl.h +++ b/lib/uktime/musl-imported/include/time_impl.h @@ -1,11 +1,7 @@ -#include <time.h> +#include <uktime/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/include/uktime/time.h b/lib/uktime/musl-imported/include/uktime/time.h index 672b3fc3..b64560ab 100644 --- a/lib/uktime/musl-imported/include/uktime/time.h +++ b/lib/uktime/musl-imported/include/uktime/time.h @@ -1,18 +1,25 @@ -#ifndef _TIME_H -#define _TIME_H +#ifndef _UKTIME_TIME_H +#define _UKTIME_TIME_H + +#include <uk/config.h> + +#ifdef CONFIG_LIBNOLIBC +#include <sys/time.h> +#endif #ifdef __cplusplus extern "C" { #endif -#include <features.h> - +#ifndef NULL #ifdef __cplusplus #define NULL 0L #else #define NULL ((void*)0) #endif +#endif +#define _GNU_SOURCE #define __NEED_size_t #define __NEED_time_t @@ -28,7 +35,12 @@ extern "C" { #define __NEED_locale_t #endif -#include <bits/alltypes.h> +#include <_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 +61,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 +72,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 +82,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 +91,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 +114,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 +131,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 +142,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 +155,4 @@ time_t timegm(struct tm *); } #endif - #endif 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; -- 2.20.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |