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..6339aeef6b11559a01d6be4fde5da23ebbc26e14 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 |
|
jbudorick
2017/05/30 15:48:02
Should this all just be in test_file_util_android.
Maks Orlovich
2017/05/30 16:49:17
I can bind "all" two different ways, and have diff
jbudorick
2017/05/30 16:52:05
This was what I meant. Your reasoning for keeping
|
| +// until API level = 21, which we don't use yet, so provide a wrapper, at least |
|
jbudorick
2017/05/30 15:48:02
nit: note that this is *native* api level 21.
Maks Orlovich
2017/05/30 16:49:17
Thanks for elaborating, I wasn't aware of this dis
|
| +// on ARM32 |
| +#if defined(OS_ANDROID) |
|
jbudorick
2017/05/30 15:48:02
nit: Should this be
if defined(OS_ANDROID) && _
Maks Orlovich
2017/05/30 16:49:17
Done.
|
| + |
| +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()) |