hikey: Remove hardcoded PAGE_SIZE usage

Bug: 310232825
Test: Presubmit
Change-Id: If7517d37a0af3f811beafcbc34a4e71ad78d3ce7
diff --git a/gralloc/gralloc_helper.h b/gralloc/gralloc_helper.h
index c8378f8..79566e6 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 30b49ce..537c397 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 @@
 		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 @@
 	 * 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 @@
 		 */
 		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 @@
 	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 122ee2a..df7acd4 100644
--- a/gralloc960/gralloc_buffer_priv.h
+++ b/gralloc960/gralloc_buffer_priv.h
@@ -83,7 +83,8 @@
 		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 @@
 
 	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 3d2b421..826e8ec 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_ */