1 /*
2  * futimesat() for uClibc
3  *
4  * Copyright (C) 2009 Analog Devices Inc.
5  *
6  * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7  */
8 
9 #include <sys/syscall.h>
10 #include <sys/stat.h>
11 #include <sys/time.h>
12 
13 #ifdef __NR_futimesat
14 _syscall3(int, futimesat, int, fd, const char *, file, const struct timeval *, tvp)
15 #elif defined __NR_utimensat
16 #include <errno.h>
17 #define __need_NULL
18 #include <stddef.h>
19 
20 int futimesat(int dirfd, const char *file, const struct timeval tvp[2])
21 {
22 	struct timespec ts[2];
23 
24 	if (tvp != NULL)
25 	{
26 		if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
27 		    || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
28 		{
29 			__set_errno(EINVAL);
30 			return -1;
31 		}
32 
33 		TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]);
34 		TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]);
35 	}
36 
37 	return utimensat(dirfd, file, tvp ? ts : NULL, 0);
38 }
39 #endif
40