1 /* vi: set sw=4 ts=4: */
5 * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
7 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
10 #include <sys/syscall.h>
13 #if defined __NR_utimensat && !defined __NR_utime
17 int utime(const char *file, const struct utimbuf *times)
19 struct timespec tspecs[2], *ts;
23 ts[0].tv_sec = times->actime;
25 ts[1].tv_sec = times->modtime;
31 return utimensat(AT_FDCWD, file, ts, 0);
34 #elif defined(__NR_utime)
35 _syscall2(int, utime, const char *, file, const struct utimbuf *, times)
36 #elif defined __NR_utimes /* alpha || ia64 */
39 # include <sys/time.h>
41 int utime(const char *file, const struct utimbuf *times)
43 struct timeval timevals[2];
46 timevals[0].tv_usec = 0L;
47 timevals[1].tv_usec = 0L;
48 timevals[0].tv_sec = (time_t) times->actime;
49 timevals[1].tv_sec = (time_t) times->modtime;
51 return utimes(file, times ? timevals : NULL);
55 #if (defined __NR_utimensat && !defined __NR_utime) || \
56 defined __NR_utime || defined __NR_utimes
57 link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use `utimes'")
58 libc_hidden_def(utime)