|
21 | 21 |
|
22 | 22 | namespace LIBC_NAMESPACE_DECL {
|
23 | 23 |
|
24 |
| -#ifdef SYS_utimes |
25 |
| -constexpr auto UTIMES_SYSCALL_ID = SYS_utimes; |
26 |
| -#elif defined(SYS_utimensat) |
27 |
| -constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat; |
28 |
| -#elif defined(SYS_utimensat_time64) |
29 |
| -constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat_time64; |
30 |
| -#else |
31 |
| -#error "utimes, utimensat, utimensat_time64, syscalls not available." |
32 |
| -#endif |
33 |
| - |
34 | 24 | LLVM_LIBC_FUNCTION(int, utimes,
|
35 | 25 | (const char *path, const struct timeval times[2])) {
|
36 | 26 | int ret;
|
37 | 27 |
|
38 | 28 | #ifdef SYS_utimes
|
39 | 29 | // No need to define a timespec struct, use the syscall directly.
|
40 |
| - ret = LIBC_NAMESPACE::syscall_impl<int>(UTIMES_SYSCALL_ID, path, times); |
| 30 | + ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_utimes, path, times); |
41 | 31 | #elif defined(SYS_utimensat) || defined(SYS_utimensat_time64)
|
| 32 | + |
| 33 | +#if defined(SYS_utimensat) |
| 34 | + constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat; |
| 35 | +#elif defined(SYS_utimensat_time64) |
| 36 | + constexpr auto UTIMES_SYSCALL_ID = SYS_utimensat_time64; |
| 37 | +#endif |
| 38 | + |
42 | 39 | // the utimensat syscall requires a timespec struct, not timeval.
|
43 | 40 | struct timespec ts[2];
|
44 | 41 | struct timespec *ts_ptr = nullptr; // default value if times is nullptr
|
@@ -74,6 +71,9 @@ LLVM_LIBC_FUNCTION(int, utimes,
|
74 | 71 | // flags=0 means don't follow symlinks (like utimes)
|
75 | 72 | ret = LIBC_NAMESPACE::syscall_impl<int>(UTIMES_SYSCALL_ID, AT_FDCWD, path,
|
76 | 73 | ts_ptr, 0);
|
| 74 | + |
| 75 | +#else |
| 76 | +#error "utimes, utimensat, utimensat_time64, syscalls not available." |
77 | 77 | #endif // SYS_utimensat
|
78 | 78 |
|
79 | 79 | if (ret < 0) {
|
|
0 commit comments