Skip to content

[libc] Add utimes function #97530

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion libc/spec/linux.td
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ def Linux : StandardSpec<"Linux"> {
],
[StructTimevalType], // Types
[], // Enumerations
[] // Functions
[
FunctionSpec<
"utimes",
RetValSpec<IntType>,
[
ArgSpec<ConstCharPtr>,
ArgSpec<ConstStructTimevalPtr>,
]
>,
] // Functions
>;


Expand Down
1 change: 1 addition & 0 deletions libc/spec/spec.td
Original file line number Diff line number Diff line change
Expand Up @@ -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">;
Expand Down
1 change: 1 addition & 0 deletions libc/src/sys/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ add_subdirectory(statvfs)
add_subdirectory(utsname)
add_subdirectory(wait)
add_subdirectory(prctl)
add_subdirectory(time)
10 changes: 10 additions & 0 deletions libc/src/sys/time/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
12 changes: 12 additions & 0 deletions libc/src/sys/time/linux/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
12 changes: 12 additions & 0 deletions libc/src/sys/time/linux/utimes.cpp
Original file line number Diff line number Diff line change
@@ -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
18 changes: 18 additions & 0 deletions libc/src/sys/time/utimes.h
Original file line number Diff line number Diff line change
@@ -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
Loading