Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201227184032.22413-4-alobakin@pm.me>
Date: Sun, 27 Dec 2020 18:41:09 +0000
From: Alexander Lobakin <alobakin@...me>
To: Rich Felker <dalias@...ifal.cx>, musl@...ts.openwall.com
Cc: Alexander Lobakin <alobakin@...me>
Subject: [PATCH 04/18] clock_getres: use time64 variant by default

Use the new time64 variant as a default and fallback to time32 only
on -ENOSYS.

Signed-off-by: Alexander Lobakin <alobakin@...me>
---
 src/time/clock_getres.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/time/clock_getres.c b/src/time/clock_getres.c
index 81c6703761d4..eb563509b420 100644
--- a/src/time/clock_getres.c
+++ b/src/time/clock_getres.c
@@ -4,18 +4,17 @@
 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];
-		}
+	int r = __syscall(SYS_clock_getres_time64, clk, ts);
+	if (SYS_clock_getres == SYS_clock_getres_time64 || r != -ENOSYS)
 		return __syscall_ret(r);
+	long ts32[2];
+	r = __syscall(SYS_clock_getres, clk, ts32);
+	if (!r && ts) {
+		ts->tv_sec = ts32[0];
+		ts->tv_nsec = ts32[1];
 	}
-#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_ret(r);
+#else
 	return syscall(SYS_clock_getres, clk, ts);
+#endif
 }
-- 
2.29.2


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.