This is an archive of the discontinued LLVM Phabricator instance.

Implement nanosleep per https://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html
ClosedPublic

Authored by rtenneti on Sep 16 2022, 5:40 PM.

Details

Summary

Tested:
Limited unit test: This makes a call and checks that no error was
returned, but we currently don't have the ability to ensure that
time has elapsed as expected.

Co-authored-by: Jeff Bailey <jeffbailey@google.com>

Diff Detail

Event Timeline

rtenneti created this revision.Sep 16 2022, 5:40 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 16 2022, 5:40 PM
rtenneti requested review of this revision.Sep 16 2022, 5:40 PM

Hi Siva,

Jeff and I worked on this. Please take a look. Thanks
sivachandra accepted this revision.Sep 19 2022, 10:27 AM
sivachandra added inline comments.
libc/include/llvm-libc-types/CMakeLists.txt
38 ↗(On Diff #460949)

Since this depends on time_t.h, we should add a DEPENDS .time_t.

libc/include/llvm-libc-types/struct_timespec.h
17

I think this definition is correct as per the POSIX spec. But, since we are passing structures of this shape to the Linux syscall, we should probably add a comment or TODO in src/time/nanosleep.cpp explaining why this definition is sufficient or incomplete.

libc/spec/stdc.td
17 ↗(On Diff #460949)

Can you do the changes in the file separately as an obvious change?

libc/src/time/mktime.h
1 ↗(On Diff #460949)

Can you make the changes in this file also separately?

libc/test/src/time/nanosleep_test.cpp
22

Call it SmokeTest may be? Also, move the above comment inside this test block.

This revision is now accepted and ready to land.Sep 19 2022, 10:27 AM
rtenneti updated this revision to Diff 462616.Sep 23 2022, 4:39 PM
rtenneti marked 4 inline comments as done.

Fixed comments.

rtenneti marked an inline comment as done.Sep 23 2022, 4:39 PM
jeffbailey accepted this revision.Sep 23 2022, 4:40 PM
rtenneti updated this revision to Diff 462623.Sep 23 2022, 4:56 PM

Fixed comments.

This revision was automatically updated to reflect the committed changes.