Skip to content

Commit e0b702f

Browse files
authored
[libc] Fix nanosleep definition in the posix spec (#67855)
Summary: The POSIX standard expects the first argument to this function to be constant, e.g. https://man7.org/linux/man-pages/man2/nanosleep.2.html. This fixes that problem and also corrects an obvious problem with enabling this for offloading.
1 parent 832b3b2 commit e0b702f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Headers/llvm_libc_wrappers/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
_Static_assert(sizeof(clock_t) == sizeof(long), "ABI mismatch!");
2727

28-
#include <llvm-libc-decls/ctype.h>
28+
#include <llvm-libc-decls/time.h>
2929

3030
#pragma omp end declare target
3131

libc/spec/posix.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def ConstStructDirentPtrPtr : ConstType<StructDirentPtrPtr>;
4444

4545
def StructTimeSpec : NamedType<"struct timespec">;
4646
def StructTimeSpecPtr : PtrType<StructTimeSpec>;
47+
def ConstStructTimeSpecPtr : ConstType<StructTimeSpecPtr>;
4748

4849
def StructSchedParam : NamedType<"struct sched_param">;
4950
def StructSchedParamPtr : PtrType<StructSchedParam>;
@@ -1192,7 +1193,7 @@ def POSIX : StandardSpec<"POSIX"> {
11921193
FunctionSpec<
11931194
"nanosleep",
11941195
RetValSpec<IntType>,
1195-
[ArgSpec<StructTimeSpecPtr>, ArgSpec<StructTimeSpecPtr>]
1196+
[ArgSpec<ConstStructTimeSpecPtr>, ArgSpec<StructTimeSpecPtr>]
11961197
>,
11971198
]
11981199
>;

0 commit comments

Comments
 (0)