[clang] e0b702f - [libc] Fix `nanosleep` definition in the posix spec (#67855)

via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 29 15:35:19 PDT 2023


Author: Joseph Huber
Date: 2023-09-29T17:35:10-05:00
New Revision: e0b702ffc24b15b2ffb91cf4e7199f8fba80088c

URL: https://github.com/llvm/llvm-project/commit/e0b702ffc24b15b2ffb91cf4e7199f8fba80088c
DIFF: https://github.com/llvm/llvm-project/commit/e0b702ffc24b15b2ffb91cf4e7199f8fba80088c.diff

LOG: [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.

Added: 
    

Modified: 
    clang/lib/Headers/llvm_libc_wrappers/time.h
    libc/spec/posix.td

Removed: 
    


################################################################################
diff  --git a/clang/lib/Headers/llvm_libc_wrappers/time.h b/clang/lib/Headers/llvm_libc_wrappers/time.h
index 894f6f6c7aaf774..9d1340c4eb748f0 100644
--- a/clang/lib/Headers/llvm_libc_wrappers/time.h
+++ b/clang/lib/Headers/llvm_libc_wrappers/time.h
@@ -25,7 +25,7 @@
 
 _Static_assert(sizeof(clock_t) == sizeof(long), "ABI mismatch!");
 
-#include <llvm-libc-decls/ctype.h>
+#include <llvm-libc-decls/time.h>
 
 #pragma omp end declare target
 

diff  --git a/libc/spec/posix.td b/libc/spec/posix.td
index d09c7228549dfc7..a367cf2a6935c02 100644
--- a/libc/spec/posix.td
+++ b/libc/spec/posix.td
@@ -44,6 +44,7 @@ def ConstStructDirentPtrPtr : ConstType<StructDirentPtrPtr>;
 
 def StructTimeSpec : NamedType<"struct timespec">;
 def StructTimeSpecPtr : PtrType<StructTimeSpec>;
+def ConstStructTimeSpecPtr : ConstType<StructTimeSpecPtr>;
 
 def StructSchedParam : NamedType<"struct sched_param">;
 def StructSchedParamPtr : PtrType<StructSchedParam>;
@@ -1192,7 +1193,7 @@ def POSIX : StandardSpec<"POSIX"> {
           FunctionSpec<
               "nanosleep",
               RetValSpec<IntType>,
-              [ArgSpec<StructTimeSpecPtr>, ArgSpec<StructTimeSpecPtr>]
+              [ArgSpec<ConstStructTimeSpecPtr>, ArgSpec<StructTimeSpecPtr>]
           >,
       ]
   >;


        


More information about the cfe-commits mailing list