[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] ARM: Mes C Library: Add compile stub for time.
From: |
Danny Milosavljevic |
Subject: |
Re: [PATCH] ARM: Mes C Library: Add compile stub for time. |
Date: |
Tue, 2 Jun 2020 21:31:22 +0200 |
Hi Janneke,
this patch from you is required on mes master to support ARM.
On Tue, 2 Jun 2020 21:26:36 +0200
Danny Milosavljevic <dannym@scratchpost.org> wrote:
> * lib/linux/time.c (time)[SYS_gettimeofday]: Implement using gettimeofday.
I've fixed a typo in "Implement".
> (time)[!SYS_time && !SYS_gettimeofday]: Compile stub.
> ---
> lib/linux/time.c | 37 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 37 insertions(+)
>
> diff --git a/lib/linux/time.c b/lib/linux/time.c
> index 17af241..e33fe48 100644
> --- a/lib/linux/time.c
> +++ b/lib/linux/time.c
> @@ -22,8 +22,45 @@
> #include <syscall.h>
> #include <time.h>
>
> +#if SYS_time
> +
> time_t
> time (time_t * result)
> {
> return _sys_call1 (SYS_time, (long) result);
> }
Can this syscall fail? I guess not much we can do if it does fail...
> +
> +#elif SYS_gettimeofday
> +
> +#include <sys/time.h>
> +
> +time_t
> +time (time_t * result)
> +{
> + struct timeval tv;
> + struct timezone tz;
> + gettimeofday (&tv, &tz);
Can't gettimeofday fail? At least using TV is then usually pretty bad.
> + if (result)
> + *result = tv.tv_sec;
> + return tv.tv_sec;
> +}
> +
> +#else
> +
> +#warning there is no time
> +
> +#include <mes/lib.h>
> +
> +time_t
> +time (time_t * result)
> +{
> + static int stub = 0;
> + if (__mes_debug () && !stub)
> + eputs ("time stub\n");
> + stub = 1;
> + if (result)
> + *result = 0;
> + return 0;
> +}
> +
> +#endif
Otherwise LGTM!
pgpFx2M_LHMVZ.pgp
Description: OpenPGP digital signature