Skip to contentSkip to conversation

lib/tst_wallclock.c: Add check for unsupported CLOCK_MONOTONIC_RAW

PATCH New Xiao Yang 2 participants 2 messages Apr 5, 2019 Library code

lore
Share & tools
lore

Xiao Yang

author
#0 lore raw

PATCH 1/1 lib/tst_wallclock.c: Add check for unsupported CLOCK_MONOTONIC_RAW

CLOCK_MONOTONIC_RAW was introduced since kernel v2.6.28, so we want TCONF instead of TBROK if CLOCK_MONOTONIC_RAW wasn't supported on older kernels.

---
 lib/tst_wallclock.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
lib/tst_wallclock.c +7 -1
index f1c96c0..282d6ad 100644
@@ -25,8 +25,14 @@ void tst_wallclock_save(void)
 	if (tst_clock_gettime(CLOCK_REALTIME, &real_begin))
 		tst_brk(TBROK | TERRNO, "tst_clock_gettime() realtime failed");
 
-	if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin))
+	if (tst_clock_gettime(CLOCK_MONOTONIC_RAW, &mono_begin)) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"tst_clock_gettime() didn't support CLOCK_MONOTONIC_RAW");
+		}
+
 		tst_brk(TBROK | TERRNO, "tst_clock_gettime() monotonic failed");
+	}
 
 	clock_saved = 1;
 }
Signature · 1 line
1.7.11.rc0
#1 lore raw

PATCH 1/1 lib/tst_wallclock.c: Add check for unsupported CLOCK_MONOTONIC_RAW

Hi!
Applied, thanks.

Signature · 2 lines
Cyril Hrubis
[email protected]