diff options
author | Kalesh Singh <kaleshsingh@google.com> | 2023-09-19 09:29:00 -0700 |
---|---|---|
committer | Kalesh Singh <kaleshsingh@google.com> | 2023-09-19 11:01:50 -0700 |
commit | 961d2216f4ddc4ca26440fece61bb9002277df24 (patch) | |
tree | f502d74481e01a2f11ef19738d557549ac6408d4 | |
parent | fbbe8bdff14790c710ff1e76ce4cf6f4794cd73f (diff) | |
download | gchips-961d2216f4ddc4ca26440fece61bb9002277df24.tar.gz |
gralloc4: Remove PAGE_SIZE 4096 assumption
bionic provides PAGE_SIZE macro which hard codes the page-size
to 4096.
PAGE_SIZE is being removed as no other libc provides this and
Android is moving towards being page-size-agnostic.
Make gralloc query the page size form the auxillary vector using
getpagesize() instead. Remove unused round_up_to_page_size()
function.
Bug: 301096752
Test: manual; build page agnostic target
Change-Id: Id857b982587fdfeaafc7be5785ddade966b30841
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
-rw-r--r-- | gralloc4/src/core/mali_gralloc_reference.cpp | 6 | ||||
-rw-r--r-- | gralloc4/src/gralloc_helper.h | 5 |
2 files changed, 4 insertions, 7 deletions
diff --git a/gralloc4/src/core/mali_gralloc_reference.cpp b/gralloc4/src/core/mali_gralloc_reference.cpp index 6726895..359a455 100644 --- a/gralloc4/src/core/mali_gralloc_reference.cpp +++ b/gralloc4/src/core/mali_gralloc_reference.cpp @@ -25,6 +25,8 @@ #include <map> #include <mutex> +#include <unistd.h> + #include "allocator/mali_gralloc_ion.h" #include "mali_gralloc_buffer.h" @@ -73,8 +75,8 @@ private: auto check_pid = [&](int fd, uint64_t allocated_size) -> bool { auto size = get_buffer_size(fd); auto size_padding = size - (off_t)allocated_size; - if ((size != -1) && ((size_padding < 0) || (size_padding > PAGE_SIZE))) { - MALI_GRALLOC_LOGE("%s failed: fd (%d) size (%jd) is not within a PAGE_SIZE of " + if ((size != -1) && ((size_padding < 0) || (size_padding > getpagesize()))) { + MALI_GRALLOC_LOGE("%s failed: fd (%d) size (%jd) is not within a page of " "expected size (%" PRIx64 ")", __func__, fd, static_cast<intmax_t>(size), allocated_size); return false; diff --git a/gralloc4/src/gralloc_helper.h b/gralloc4/src/gralloc_helper.h index ba31333..7add6a4 100644 --- a/gralloc4/src/gralloc_helper.h +++ b/gralloc4/src/gralloc_helper.h @@ -31,9 +31,4 @@ #define GRALLOC_UNUSED(x) ((void)x) -static inline size_t round_up_to_page_size(size_t x) -{ - return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); -} - #endif /* GRALLOC_HELPER_H_ */ |