[PATCH] Support Android NDK (which has neither futimes nor futimens)

Pete Cooper peter_cooper at apple.com
Sat Dec 7 00:21:57 PST 2013


Hi Neil

Would it be better to make your code execute on any unix platform where those functions aren't available?

That is, change

> +#ifdef __ANDROID__
> +#include <sys/syscall.h>
> +#endif

To

+#if !defined(HAVE_FUTIMES) && !defined(HAVE_FUTIMENS)
+#include <sys/syscall.h>
+#endif

And then instead of 

> +#elif defined(__ANDROID__)

Put it inside the #else and remove the #error

Thanks,
Pete

Sent from my iPhone

> On Dec 6, 2013, at 4:11 PM, Neil Henning <llvm at neil-henning.co.uk> wrote:
> 
> 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
> <D2357.1.patch>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131207/4d9b90b6/attachment.html>


More information about the llvm-commits mailing list