summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gralloc/gralloc_helper.h3
-rw-r--r--gralloc960/gralloc_buffer_priv.cpp11
-rw-r--r--gralloc960/gralloc_buffer_priv.h5
-rw-r--r--gralloc960/gralloc_helper.h3
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_ */