clock_nanosleep: add CLOCK_THREAD_CPUTIME_ID special case
POSIX makes "the CPU-time clock of the calling thread" (i.e.,
CLOCK_THREAD_CPUTIME_ID) a special case which returns EINVAL instead of
ENOTSUP.
However, the clock_nanosleep syscall treats this clock just like any
other, and returns -EOPNOTSUPP to indicate an unimplemented nanosleep
handler. So we need to handle this ourselves in userspace.
This change fixes the LTP clock_nanosleep01 testcase.
Change-Id: If3bed940d276834bcd114d8c17f96197e9384711
Signed-off-by: Greg Hackmann <ghackmann@google.com>
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index 6cdabd2..b1f6364 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -573,3 +573,10 @@
timespec out;
ASSERT_EQ(EINVAL, clock_nanosleep(-1, 0, &in, &out));
}
+
+TEST(time, clock_nanosleep_thread_cputime_id) {
+ timespec in;
+ in.tv_sec = 1;
+ in.tv_nsec = 0;
+ ASSERT_EQ(EINVAL, clock_nanosleep(CLOCK_THREAD_CPUTIME_ID, 0, &in, nullptr));
+}