From 32652200bf6ef0f756ca00cac1bfeb848876acb8 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Mon, 23 Mar 2020 19:51:06 +0300 Subject: [PATCH] Fix glibc compatibility --- base/glibc-compatibility/musl/clock_getres.c | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 base/glibc-compatibility/musl/clock_getres.c diff --git a/base/glibc-compatibility/musl/clock_getres.c b/base/glibc-compatibility/musl/clock_getres.c new file mode 100644 index 00000000000..95702709224 --- /dev/null +++ b/base/glibc-compatibility/musl/clock_getres.c @@ -0,0 +1,22 @@ +#include +#include +#include "syscall.h" + +int clock_getres(clockid_t clk, struct timespec *ts) +{ +#ifdef SYS_clock_getres_time64 + /* On a 32-bit arch, use the old syscall if it exists. */ + if (SYS_clock_getres != SYS_clock_getres_time64) { + long ts32[2]; + int r = __syscall(SYS_clock_getres, clk, ts32); + if (!r && ts) { + ts->tv_sec = ts32[0]; + ts->tv_nsec = ts32[1]; + } + return __syscall_ret(r); + } +#endif + /* If reaching this point, it's a 64-bit arch or time64-only + * 32-bit arch and we can get result directly into timespec. */ + return syscall(SYS_clock_getres, clk, ts); +}