[libc-commits] [PATCH] D159125: [libc] Fix nanosleep implementation when using SYS_clock_nanosleep_time64 in 32-bit systems

Mikhail Ramalho via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Aug 29 11:04:31 PDT 2023


mikhail.ramalho created this revision.
mikhail.ramalho added reviewers: michaelrj, sivachandra.
Herald added subscribers: libc-commits, asb.
Herald added projects: libc-project, All.
mikhail.ramalho requested review of this revision.

SYS_clock_nanosleep_time64 takes a struct timespec64 as argument, which
is a timespec with 64-bit members, but we pass a struct timespec
instead. This is not a problem in 64-bit systems, however, in 32-bit
systems that use this call (e.g., rv32) timespec has 32-bit members,
which leads to wrong results when calling the syscall.

This patch adds the struct timespec64 (and time64_t), and uses it
whenever we call SYS_clock_nanosleep_time64. For systems that use
SYS_nanosleep this patch doesn't change the behaviour.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159125

Files:
  libc/config/linux/api.td
  libc/include/CMakeLists.txt
  libc/include/llvm-libc-types/CMakeLists.txt
  libc/include/llvm-libc-types/struct_sched_param.h
  libc/include/llvm-libc-types/struct_stat.h
  libc/include/llvm-libc-types/struct_timespec64.h
  libc/include/llvm-libc-types/time64_t.h
  libc/spec/posix.td
  libc/spec/spec.td
  libc/spec/stdc.td
  libc/src/time/nanosleep.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159125.554431.patch
Type: text/x-patch
Size: 10752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230829/1db62277/attachment.bin>


More information about the libc-commits mailing list