[PATCH] Support Android NDK (which has neither futimes nor futimens)
Neil Henning
llvm at neil-henning.co.uk
Fri Dec 6 16:11:36 PST 2013
The latest NDK has no support for futimes nor funtimens. Following the ideas shown in this [[ http://stackoverflow.com/questions/19374749/how-to-work-around-absence-of-futimes-in-android-ndk | Stack Overflow post ]] I've created a simple patch which supports setLastModificationAndAccessTime using the NDK.
Comments and suggestions are welcome.
http://llvm-reviews.chandlerc.com/D2357
Files:
lib/Support/Unix/Path.inc
Index: lib/Support/Unix/Path.inc
===================================================================
--- lib/Support/Unix/Path.inc
+++ lib/Support/Unix/Path.inc
@@ -50,6 +50,10 @@
#include <mach-o/dyld.h>
#endif
+#ifdef __ANDROID__
+#include <sys/syscall.h>
+#endif
+
// Both stdio.h and cstdio are included via different pathes and
// stdcxx's cstdio doesn't include stdio.h, so it doesn't #undef the macros
// either.
@@ -536,6 +540,12 @@
Times[0].tv_usec = 0;
Times[1] = Times[0];
if (::futimes(FD, Times))
+#elif defined(__ANDROID__)
+ timespec Times[2];
+ Times[0].tv_sec = Time.toPosixTime();
+ Times[0].tv_nsec = 0;
+ Times[1] = Times[0];
+ if (syscall(__NR_utimensat, FD, NULL, Times, 0))
#else
#error Missing futimes() and futimens()
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2357.1.patch
Type: text/x-patch
Size: 774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131206/d804bde3/attachment.bin>
More information about the llvm-commits
mailing list