Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 27 Dec 2020 18:42:55 +0000
From: Alexander Lobakin <alobakin@...me>
To: Rich Felker <dalias@...ifal.cx>, musl@...ts.openwall.com
Cc: Alexander Lobakin <alobakin@...me>
Subject: [PATCH 18/18] sched_rr_get_interval: use time64 variant if available

Use the new time64 variant of sched_rr_get_interval as a default and
fallback to the old one only on -ENOSYS.

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

diff --git a/src/sched/sched_rr_get_interval.c b/src/sched/sched_rr_get_interval.c
index 33a3d1aeed43..bdcba9c57248 100644
--- a/src/sched/sched_rr_get_interval.c
+++ b/src/sched/sched_rr_get_interval.c
@@ -4,18 +4,17 @@
 int sched_rr_get_interval(pid_t pid, struct timespec *ts)
 {
 #ifdef SYS_sched_rr_get_interval_time64
-	/* On a 32-bit arch, use the old syscall if it exists. */
-	if (SYS_sched_rr_get_interval != SYS_sched_rr_get_interval_time64) {
-		long ts32[2];
-		int r = __syscall(SYS_sched_rr_get_interval, pid, ts32);
-		if (!r) {
-			ts->tv_sec = ts32[0];
-			ts->tv_nsec = ts32[1];
-		}
+	int r = __syscall(SYS_sched_rr_get_interval_time64, pid, ts);
+	if (SYS_sched_rr_get_interval == SYS_sched_rr_get_interval_time64 || r != -ENOSYS)
 		return __syscall_ret(r);
+	long ts32[2];
+	r = __syscall(SYS_sched_rr_get_interval, pid, ts32);
+	if (!r) {
+		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_sched_rr_get_interval, pid, 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.