Chromium Code Reviews| Index: base/test/test_file_util_linux.cc |
| diff --git a/base/test/test_file_util_linux.cc b/base/test/test_file_util_linux.cc |
| index 0ef5c0a1571041da64665bbf1673f0cce268396d..cf8b05627297e4daa5b79ff53152b129671f524a 100644 |
| --- a/base/test/test_file_util_linux.cc |
| +++ b/base/test/test_file_util_linux.cc |
| @@ -9,11 +9,42 @@ |
| #include <sys/types.h> |
| #include <unistd.h> |
| +#if defined(OS_ANDROID) |
| +#include <asm/unistd.h> |
| +#include <errno.h> |
| +#include <linux/fadvise.h> |
| +#include <sys/syscall.h> |
| +#endif |
| + |
| #include "base/files/file_path.h" |
| #include "base/files/scoped_file.h" |
| namespace base { |
| +// Inconveniently, the NDK doesn't provide for posix_fadvise |
| +// until native API level = 21, which we don't use yet, so provide a wrapper, at |
| +// least on ARM32 |
| +#if defined(OS_ANDROID) && __ANDROID_API__ < 21 |
|
Paweł Hajdan Jr.
2017/05/31 15:28:13
If this is android-specific, why force a _linux fi
Maks Orlovich
2017/05/31 15:30:25
So I can put it in an anonymous namespace (seems p
|
| + |
| +namespace { |
| +int posix_fadvise(int fd, off_t offset, off_t len, int advice) { |
| +#if defined(ARCH_CPU_ARMEL) |
| + // Note that the syscall argument order on ARM is different from the C |
| + // function; this is helpfully documented in the Linux posix_fadvise manpage. |
| + return syscall(__NR_arm_fadvise64_64, fd, advice, |
| + 0, // Upper 32-bits for offset |
| + offset, |
| + 0, // Upper 32-bits for length |
| + len); |
| +#endif |
| + NOTIMPLEMENTED(); |
| + return ENOSYS; |
| +} |
| + |
| +} // namespace |
| + |
| +#endif // OS_ANDROID |
| + |
| bool EvictFileFromSystemCache(const FilePath& file) { |
| ScopedFD fd(open(file.value().c_str(), O_RDONLY)); |
| if (!fd.is_valid()) |