[PATCH] hwclock: Check for SYS_settimeofday before calling syscall
Denys Vlasenko
vda.linux at googlemail.com
Tue Mar 9 23:17:27 UTC 2021
On Mon, Mar 8, 2021 at 2:34 AM Khem Raj <raj.khem at gmail.com> wrote:
>
> Some newer architectures e.g. RISCV32 have 64bit time_t from get go and
> thusly do not have gettimeofday_time64/settimeofday_time64 implemented
> therefore check for SYS_settimeofday definition before making the
> syscall. Fixes build for riscv32 and it will bail out at runtime.
Bail out? There should be a way to set time on RISCV64 arch, no?
> Signed-off-by: Khem Raj <raj.khem at gmail.com>
> ---
> util-linux/hwclock.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
> index 723b09589..b9faaabbc 100644
> --- a/util-linux/hwclock.c
> +++ b/util-linux/hwclock.c
> @@ -131,6 +131,7 @@ static void show_clock(const char **pp_rtcname, int utc)
>
> static void set_kernel_tz(const struct timezone *tz)
> {
> + int ret = 1;
> #if LIBC_IS_MUSL
> /* musl libc does not pass tz argument to syscall
> * because "it's deprecated by POSIX, therefore it's fine
> @@ -139,9 +140,11 @@ static void set_kernel_tz(const struct timezone *tz)
> #if !defined(SYS_settimeofday) && defined(SYS_settimeofday_time32)
> # define SYS_settimeofday SYS_settimeofday_time32
> #endif
> - int ret = syscall(SYS_settimeofday, NULL, tz);
> +#if defined(SYS_settimeofday)
> + ret = syscall(SYS_settimeofday, NULL, tz);
> +#endif
> #else
> - int ret = settimeofday(NULL, tz);
> + ret = settimeofday(NULL, tz);
> #endif
> if (ret)
> bb_simple_perror_msg_and_die("settimeofday");
> --
> 2.30.1
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
More information about the busybox
mailing list