-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc] Add utimes
function
#97530
[libc] Add utimes
function
#97530
Conversation
@llvm/pr-subscribers-libc Author: Izaak Schroeder (izaakschroeder) ChangesImplementation needed, definition provided. Full diff: https://github.com/llvm/llvm-project/pull/97530.diff 9 Files Affected:
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 940df63e3912b..0e158ff9c1c05 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -242,6 +242,9 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.stat.mkdirat
libc.src.sys.stat.stat
+ # sys/time.h entrypoints
+ libc.src.sys.time.utimes
+
# sys/utsname.h entrypoints
libc.src.sys.utsname.uname
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 09f04fb31dfd8..1c5bec7626654 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -266,6 +266,9 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.statvfs.fstatvfs
libc.src.sys.statvfs.statvfs
+ # sys/time.h entrypoints
+ libc.src.sys.time.utimes
+
# sys/utsname.h entrypoints
libc.src.sys.utsname.uname
diff --git a/libc/spec/linux.td b/libc/spec/linux.td
index 82630ff413c73..191fd73adec60 100644
--- a/libc/spec/linux.td
+++ b/libc/spec/linux.td
@@ -148,7 +148,16 @@ def Linux : StandardSpec<"Linux"> {
],
[StructTimevalType], // Types
[], // Enumerations
- [] // Functions
+ [
+ FunctionSpec<
+ "utimes",
+ RetValSpec<IntType>,
+ [
+ ArgSpec<ConstCharPtr>,
+ ArgSpec<ConstStructTimevalPtr>,
+ ]
+ >,
+ ] // Functions
>;
diff --git a/libc/spec/spec.td b/libc/spec/spec.td
index a3a5db7465b39..17c0589ab1d55 100644
--- a/libc/spec/spec.td
+++ b/libc/spec/spec.td
@@ -148,6 +148,7 @@ def StructRUsagePtr : PtrType<StructRUsage>;
def StructTimevalType : NamedType<"struct timeval">;
def StructTimevalPtr : PtrType<StructTimevalType>;
+def ConstStructTimevalPtr : ConstType<StructTimevalPtr>;
def RestrictedStructTimevalPtr : RestrictedPtrType<StructTimevalType>;
def SuSecondsT : NamedType<"suseconds_t">;
diff --git a/libc/src/sys/CMakeLists.txt b/libc/src/sys/CMakeLists.txt
index adc666b94202f..fba5f86d0b08c 100644
--- a/libc/src/sys/CMakeLists.txt
+++ b/libc/src/sys/CMakeLists.txt
@@ -11,3 +11,4 @@ add_subdirectory(statvfs)
add_subdirectory(utsname)
add_subdirectory(wait)
add_subdirectory(prctl)
+add_subdirectory(time)
diff --git a/libc/src/sys/time/CMakeLists.txt b/libc/src/sys/time/CMakeLists.txt
new file mode 100644
index 0000000000000..f599cddaaeeb3
--- /dev/null
+++ b/libc/src/sys/time/CMakeLists.txt
@@ -0,0 +1,10 @@
+if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
+endif()
+
+add_entrypoint_object(
+ utimes
+ ALIAS
+ DEPENDS
+ .${LIBC_TARGET_OS}.utimes
+)
diff --git a/libc/src/sys/time/linux/CMakeLists.txt b/libc/src/sys/time/linux/CMakeLists.txt
new file mode 100644
index 0000000000000..da5f698e3515c
--- /dev/null
+++ b/libc/src/sys/time/linux/CMakeLists.txt
@@ -0,0 +1,12 @@
+add_entrypoint_object(
+ utimes
+ SRCS
+ utimes.cpp
+ HDRS
+ ../utimes.h
+ DEPENDS
+ libc.include.sys_time
+ libc.include.sys_syscall
+ libc.src.__support.OSUtil.osutil
+ libc.src.errno.errno
+)
diff --git a/libc/src/sys/time/linux/utimes.cpp b/libc/src/sys/time/linux/utimes.cpp
new file mode 100644
index 0000000000000..acf318bec7d91
--- /dev/null
+++ b/libc/src/sys/time/linux/utimes.cpp
@@ -0,0 +1,12 @@
+#include "src/sys/time/utimes.h"
+
+#include "src/__support/common.h"
+#include "src/errno/libc_errno.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, utimes, (const char *, const struct timeval[2])) {
+ return EINVAL;
+}
+
+} // namespace LIBC_NAMESPACE
diff --git a/libc/src/sys/time/utimes.h b/libc/src/sys/time/utimes.h
new file mode 100644
index 0000000000000..93d5d4d1e9aef
--- /dev/null
+++ b/libc/src/sys/time/utimes.h
@@ -0,0 +1,18 @@
+//===-- Implementation header for socket ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SYS_TIME_UTIMES_H
+#define LLVM_LIBC_SRC_SYS_TIME_UTIMES_H
+
+namespace LIBC_NAMESPACE {
+
+int utimes(const char *pathname, const struct timeval times[2]);
+
+} // namespace LIBC_NAMESPACE
+
+#endif // LLVM_LIBC_SRC_SYS_TIME_UTIMES_H
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch. I'd prefer to have an implementation rather than stubs that do nothing, otherwise it makes it difficult for me to use tools like llvm-nm
or llvm-readelf
to analyze which symbols we're missing.
Superseded by #134167 |
Implementation needed, definition provided.
See: