diff options
author | Vilas Bhat <vilasbhat@google.com> | 2024-03-28 00:11:22 +0000 |
---|---|---|
committer | Vilas Bhat <vilasbhat@google.com> | 2024-03-28 00:11:22 +0000 |
commit | 1f733ff7c1103bc660d9b9666847b78e22efb3f2 (patch) | |
tree | 938542b9b9245044b663d7de32fa142b999ac6d1 | |
parent | b1ca40e62ade9a2fd671b24ce652c1752180607a (diff) | |
download | hikey-master.tar.gz |
Bug: 310232825
Test: Presubmit
Change-Id: If7517d37a0af3f811beafcbc34a4e71ad78d3ce7
-rw-r--r-- | gralloc/gralloc_helper.h | 3 | ||||
-rw-r--r-- | gralloc960/gralloc_buffer_priv.cpp | 11 | ||||
-rw-r--r-- | gralloc960/gralloc_buffer_priv.h | 5 | ||||
-rw-r--r-- | gralloc960/gralloc_helper.h | 3 |
4 files changed, 13 insertions, 9 deletions
diff --git a/gralloc/gralloc_helper.h b/gralloc/gralloc_helper.h index c8378f81..79566e6a 100644 --- a/gralloc/gralloc_helper.h +++ b/gralloc/gralloc_helper.h @@ -23,7 +23,8 @@ inline size_t round_up_to_page_size(size_t x) { - return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); + const size_t page_size = getpagesize(); + return (x + (page_size - 1)) & ~(page_size - 1); } #endif /* GRALLOC_HELPER_H_ */ diff --git a/gralloc960/gralloc_buffer_priv.cpp b/gralloc960/gralloc_buffer_priv.cpp index 30b49ce3..537c397c 100644 --- a/gralloc960/gralloc_buffer_priv.cpp +++ b/gralloc960/gralloc_buffer_priv.cpp @@ -40,6 +40,7 @@ int gralloc_buffer_attr_allocate(private_handle_t *hnd) { int rval = -1; + const size_t page_size = getpagesize(); if (!hnd) { @@ -52,7 +53,7 @@ int gralloc_buffer_attr_allocate(private_handle_t *hnd) close(hnd->share_attr_fd); } - hnd->share_attr_fd = ashmem_create_region("gralloc_shared_attr", PAGE_SIZE); + hnd->share_attr_fd = ashmem_create_region("gralloc_shared_attr", page_size); if (hnd->share_attr_fd < 0) { @@ -73,7 +74,7 @@ int gralloc_buffer_attr_allocate(private_handle_t *hnd) * Because of this we keep the PROT_EXEC flag. */ - hnd->attr_base = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_attr_fd, 0); + hnd->attr_base = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, hnd->share_attr_fd, 0); if (hnd->attr_base != MAP_FAILED) { @@ -83,8 +84,8 @@ int gralloc_buffer_attr_allocate(private_handle_t *hnd) */ attr_region *region = (attr_region *)hnd->attr_base; - memset(hnd->attr_base, 0xff, PAGE_SIZE); - munmap(hnd->attr_base, PAGE_SIZE); + memset(hnd->attr_base, 0xff, page_size); + munmap(hnd->attr_base, page_size); hnd->attr_base = MAP_FAILED; } else @@ -132,7 +133,7 @@ int gralloc_buffer_attr_free(private_handle_t *hnd) if (hnd->attr_base != MAP_FAILED) { ALOGW("Warning shared attribute region mapped at free. Unmapping"); - munmap(hnd->attr_base, PAGE_SIZE); + munmap(hnd->attr_base, getpagesize()); hnd->attr_base = MAP_FAILED; } diff --git a/gralloc960/gralloc_buffer_priv.h b/gralloc960/gralloc_buffer_priv.h index 122ee2a6..df7acd47 100644 --- a/gralloc960/gralloc_buffer_priv.h +++ b/gralloc960/gralloc_buffer_priv.h @@ -83,7 +83,8 @@ static inline int gralloc_buffer_attr_map(struct private_handle_t *hnd, int read prot_flags |= PROT_WRITE; } - hnd->attr_base = mmap(NULL, PAGE_SIZE, prot_flags, MAP_SHARED, hnd->share_attr_fd, 0); + hnd->attr_base = + mmap(NULL, getpagesize(), prot_flags, MAP_SHARED, hnd->share_attr_fd, 0); if (hnd->attr_base == MAP_FAILED) { @@ -113,7 +114,7 @@ static inline int gralloc_buffer_attr_unmap(struct private_handle_t *hnd) if (hnd->attr_base != MAP_FAILED) { - if (munmap(hnd->attr_base, PAGE_SIZE) == 0) + if (munmap(hnd->attr_base, getpagesize()) == 0) { hnd->attr_base = MAP_FAILED; rval = 0; diff --git a/gralloc960/gralloc_helper.h b/gralloc960/gralloc_helper.h index 3d2b4210..826e8ec1 100644 --- a/gralloc960/gralloc_helper.h +++ b/gralloc960/gralloc_helper.h @@ -45,7 +45,8 @@ static inline size_t round_up_to_page_size(size_t x) { - return (x + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); + const size_t page_size = getpagesize(); + return (x + (page_size - 1)) & ~(page_size - 1); } #endif /* GRALLOC_HELPER_H_ */ |