master
1#define _GNU_SOURCE
2#include <sys/time.h>
3#include <sys/stat.h>
4#include <errno.h>
5#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
6#include "syscall.h"
7#endif
8
9int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])
10{
11 struct timespec ts[2];
12 if (times) {
13 int i;
14 for (i=0; i<2; i++) {
15#ifdef __wasilibc_unmodified_upstream // WASI has no syscall
16 if (times[i].tv_usec >= 1000000ULL)
17 return __syscall_ret(-EINVAL);
18#else
19 if (times[i].tv_usec >= 1000000ULL) {
20 errno = EINVAL;
21 return -1;
22 }
23#endif
24 ts[i].tv_sec = times[i].tv_sec;
25 ts[i].tv_nsec = times[i].tv_usec * 1000;
26 }
27 }
28 return utimensat(dirfd, pathname, times ? ts : 0, 0);
29}
30
31weak_alias(__futimesat, futimesat);