[PATCH] Use syscall() for some platforms like Android without futimes() function

waxiadao@gmail.com waxiadao at gmail.com
Sun Apr 6 02:43:04 PDT 2014


A very simple patch...It's tested and works fine.

Index: autoconf/configure.ac
===================================================================
--- autoconf/configure.ac (revision 205687)
+++ autoconf/configure.ac (working copy)
@@ -1723,6 +1723,7 @@
 AC_CHECK_HEADERS([dlfcn.h execinfo.h fcntl.h inttypes.h link.h])
 AC_CHECK_HEADERS([malloc.h setjmp.h signal.h stdint.h termios.h unistd.h])
 AC_CHECK_HEADERS([utime.h])
+AC_CHECK_HEADERS([sys/syscall.h])
 AC_CHECK_HEADERS([sys/mman.h sys/param.h sys/resource.h sys/time.h sys/uio.h])
 AC_CHECK_HEADERS([sys/ioctl.h malloc/malloc.h mach/mach.h])
 AC_CHECK_HEADERS([valgrind/valgrind.h])
@@ -1804,6 +1805,7 @@
 AC_CHECK_FUNCS([strtoll strtoq sysconf malloc_zone_statistics ])
 AC_CHECK_FUNCS([setjmp longjmp sigsetjmp siglongjmp writev])
 AC_CHECK_FUNCS([futimes futimens])
+AC_CHECK_FUNCS([syscall])
 AC_C_PRINTF_A
 AC_FUNC_RAND48

Index: lib/Support/Unix/Path.inc
===================================================================
--- lib/Support/Unix/Path.inc (revision 205687)
+++ lib/Support/Unix/Path.inc (working copy)
@@ -43,6 +43,9 @@
 # if HAVE_NDIR_H
 #  include <ndir.h>
 # endif
+# if HAVE_SYS_SYSCALL_H
+#  include <sys/syscall.h>
+# endif
 #endif

 #ifdef __APPLE__
@@ -464,6 +467,14 @@
   if (::futimes(FD, Times))
     return error_code(errno, system_category());
   return error_code::success();
+#elif defined(HAVE_SYSCALL)
+  timeval Times[2];
+  Times[0].tv_sec = Time.toEpochTime();
+  Times[0].tv_usec = 0;
+  Times[1] = Times[0];
+  if (::syscall(__NR_utimensat, FD, 0, Times, 0))
+    return error_code(errno, system_category());
+  return error_code::success();
 #else
 #warning Missing futimes() and futimens()
   return make_error_code(errc::not_supported);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: futimes.patch
Type: application/octet-stream
Size: 1693 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140406/63869797/attachment.obj>


More information about the llvm-commits mailing list