[libc-commits] [PATCH] D137881: [libc] Implement gettimeofday

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 14 10:57:47 PST 2022


michaelrj added inline comments.


================
Comment at: libc/spec/posix.td:48
 
+def StructTimeVal : NamedType<"struct timeval">;
+def StructTimeValPtr : PtrType<StructTimeVal>;
----------------
these are already defined in `spec.td` as `StructTimevalType` and `StructTimevalPtr`


================
Comment at: libc/spec/posix.td:1083-1087
           FunctionSpec<
-              "nanosleep",
+              "clock_gettime",
               RetValSpec<IntType>,
-              [
-	      	      ArgSpec<StructTimeSpecPtr>,
-	      	      ArgSpec<StructTimeSpecPtr>,
-	            ]
+              [ArgSpec<ClockIdT>, ArgSpec<StructTimeSpecPtr>]
           >,
----------------
why did you move this?


================
Comment at: libc/src/time/gettimeofday.cpp:13
+#include "src/__support/common.h"
+#include "src/time/clock_gettime.h"
+
----------------
we try to avoid calling entrypoints from other entrypoints. Here instead of calling `clock_gettime` it would be better to copy the code since it's just a simple syscall wrapper. If it was more complex then it would be better to extract it into a shared utility.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137881/new/

https://reviews.llvm.org/D137881



More information about the libc-commits mailing list