Skip to content
Merged
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
22 changes: 11 additions & 11 deletions libc/src/sys/time/linux/utimes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,21 @@

namespace LIBC_NAMESPACE_DECL {

#ifdef SYS_utimes
constexpr auto UTIMES_SYSCALL_ID = SYS_utimes;
#elif defined(SYS_utimensat)
constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat;
#elif defined(SYS_utimensat_time64)
constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat_time64;
#else
#error "utimes, utimensat, utimensat_time64, syscalls not available."
#endif

LLVM_LIBC_FUNCTION(int, utimes,
(const char *path, const struct timeval times[2])) {
int ret;

#ifdef SYS_utimes
// No need to define a timespec struct, use the syscall directly.
ret = LIBC_NAMESPACE::syscall_impl<int>(UTIMES_SYSCALL_ID, path, times);
ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_utimes, path, times);
#elif defined(SYS_utimensat) || defined(SYS_utimensat_time64)

#if defined(SYS_utimensat)
constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat;
#elif defined(SYS_utimensat_time64)
constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat_time64;
#endif

// the utimensat syscall requires a timespec struct, not timeval.
struct timespec ts[2];
struct timespec *ts_ptr = nullptr; // default value if times is nullptr
Expand Down Expand Up @@ -74,6 +71,9 @@ LLVM_LIBC_FUNCTION(int, utimes,
// flags=0 means don't follow symlinks (like utimes)
ret = LIBC_NAMESPACE::syscall_impl<int>(UTIMES_SYSCALL_ID, AT_FDCWD, path,
ts_ptr, 0);

#else
#error "utimes, utimensat, utimensat_time64, syscalls not available."
#endif // SYS_utimensat

if (ret < 0) {
Expand Down
8 changes: 7 additions & 1 deletion libc/src/unistd/linux/setsid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,20 @@
#include "hdr/types/pid_t.h"
#include "src/__support/OSUtil/syscall.h" // For internal syscall function.
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"

#include <sys/syscall.h> // For syscall numbers.

namespace LIBC_NAMESPACE_DECL {

LLVM_LIBC_FUNCTION(pid_t, setsid, ()) {
return LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_setsid);
pid_t ret = LIBC_NAMESPACE::syscall_impl<pid_t>(SYS_setsid);
if (ret < 0) {
libc_errno = static_cast<int>(-ret);
return -1;
}
return ret;
}

} // namespace LIBC_NAMESPACE_DECL
Loading