diff --git a/libc/src/sys/time/linux/utimes.cpp b/libc/src/sys/time/linux/utimes.cpp index 9c00ce9909f2f..e740190bc8198 100644 --- a/libc/src/sys/time/linux/utimes.cpp +++ b/libc/src/sys/time/linux/utimes.cpp @@ -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(UTIMES_SYSCALL_ID, path, times); + ret = LIBC_NAMESPACE::syscall_impl(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 @@ -74,6 +71,9 @@ LLVM_LIBC_FUNCTION(int, utimes, // flags=0 means don't follow symlinks (like utimes) ret = LIBC_NAMESPACE::syscall_impl(UTIMES_SYSCALL_ID, AT_FDCWD, path, ts_ptr, 0); + +#else +#error "utimes, utimensat, utimensat_time64, syscalls not available." #endif // SYS_utimensat if (ret < 0) { diff --git a/libc/src/unistd/linux/setsid.cpp b/libc/src/unistd/linux/setsid.cpp index df4629bb326cc..b1a265c9a01dd 100644 --- a/libc/src/unistd/linux/setsid.cpp +++ b/libc/src/unistd/linux/setsid.cpp @@ -11,6 +11,7 @@ #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 // For syscall numbers. @@ -18,7 +19,12 @@ namespace LIBC_NAMESPACE_DECL { LLVM_LIBC_FUNCTION(pid_t, setsid, ()) { - return LIBC_NAMESPACE::syscall_impl(SYS_setsid); + pid_t ret = LIBC_NAMESPACE::syscall_impl(SYS_setsid); + if (ret < 0) { + libc_errno = static_cast(-ret); + return -1; + } + return ret; } } // namespace LIBC_NAMESPACE_DECL