From a294529ca92050d5f480c2323a1a8a59eb9ce03f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Isager=20Dalsgar=C3=B0?= Date: Wed, 27 Nov 2024 12:56:32 -0800 Subject: [PATCH] Fix Android compilation (#12914) Summary: I was seeing errors like these prior to this patch: ``` env/io_posix.cc:174:17: error: variable has incomplete type 'struct statfs' struct statfs buf; ``` ``` env/io_posix.h:40:9: error: 'POSIX_MADV_NORMAL' macro redefined [-Werror,-Wmacro-redefined] #define POSIX_MADV_NORMAL 0 /* [MC1] no further special treatment */ ``` Pull Request resolved: https://github.com/facebook/rocksdb/pull/12914 Reviewed By: hx235 Differential Revision: D66307960 Pulled By: cbi42 fbshipit-source-id: f38034c56986e7877c9a04046b910bbeec9be1fe --- env/io_posix.cc | 9 +++++---- env/io_posix.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/env/io_posix.cc b/env/io_posix.cc index bf2638e922..231e88daef 100644 --- a/env/io_posix.cc +++ b/env/io_posix.cc @@ -28,7 +28,7 @@ #include #include #include -#ifdef OS_LINUX +#if defined(OS_LINUX) || defined(OS_ANDROID) #include #include #endif @@ -1421,9 +1421,10 @@ IOStatus PosixWritableFile::Close(const IOOptions& /*opts*/, // After ftruncate, we check whether ftruncate has the correct behavior. // If not, we should hack it with FALLOC_FL_PUNCH_HOLE if (result == 0 && - (file_stats.st_size + file_stats.st_blksize - 1) / - file_stats.st_blksize != - file_stats.st_blocks / (file_stats.st_blksize / 512)) { + static_cast((file_stats.st_size + file_stats.st_blksize - 1) / + file_stats.st_blksize) != + static_cast(file_stats.st_blocks / + (file_stats.st_blksize / 512))) { IOSTATS_TIMER_GUARD(allocate_nanos); if (allow_fallocate_) { fallocate(fd_, FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE, filesize_, diff --git a/env/io_posix.h b/env/io_posix.h index d76ca757cc..60788df9bf 100644 --- a/env/io_posix.h +++ b/env/io_posix.h @@ -30,7 +30,7 @@ // For non linux platform, the following macros are used only as place // holder. #if !(defined OS_LINUX) && !(defined OS_FREEBSD) && !(defined CYGWIN) && \ - !(defined OS_AIX) + !(defined OS_AIX) && !(defined OS_ANDROID) #define POSIX_FADV_NORMAL 0 /* [MC1] no further special treatment */ #define POSIX_FADV_RANDOM 1 /* [MC1] expect random page refs */ #define POSIX_FADV_SEQUENTIAL 2 /* [MC1] expect sequential page refs */