joyent/libuv — pull request #1506 by lgierth (2014-09-28 22:50:59+00:00)
Title: android: use lowres stat fields in uv__to_stat

With this patch, libuv can be built for an Android x86 target [1].
No Android toolchain seems to provide stat->st_atim/ctim/atm,
although ARM targets do build without this patch -- I don't know.

The Dart language had the same problem and reverted back to
second-precision timestamps. [2]

The manpage for stat(2) [3] notes that glibc implemented these fields
in accordance with POSIX.1-2008 [4]. Android's bionic libc apparantly
didn't, none of their sys/stat.h headers contains it.

[1] ./gyp_uv.py -Dtarget_arch=x64 -DOS=android
[2] https://code.google.com/p/dart/issues/detail?id=18524
[3] http://linux.die.net/man/2/stat

> Glibc exposes the nanosecond component of each field using names
> of the form st_atim.tv_nsec if the _BSD_SOURCE or _SVID_SOURCE
> feature test macro is defined. These fields are specified in
> POSIX.1-2008, and, starting with version 2.12, glibc also exposes
> these field names if _POSIX_C_SOURCE is defined with the value
> 200809L or greater, or _XOPEN_SOURCE is defined with the value 700
> or greater. If none of the aforementioned macros are defined, then
> the nanosecond values are exposed with names of the form st_atimensec.

[4] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html