| diff --git a/platform2/aosp/system/libfmq/include/fmq/MessageQueue.h b/platform2/aosp/system/libfmq/include/fmq/MessageQueue.h |
| index 848b77f..a01f1ae 100644 |
| --- a/platform2/aosp/system/libfmq/include/fmq/MessageQueue.h |
| +++ b/platform2/aosp/system/libfmq/include/fmq/MessageQueue.h |
| @@ -23,6 +23,7 @@ |
| #include <hidl/MQDescriptor.h> |
| #include <new> |
| #include <sys/mman.h> |
| +#include <unistd.h> |
| #include <utils/Log.h> |
| #include <utils/SystemClock.h> |
| |
| @@ -235,6 +236,10 @@ struct MessageQueue { |
| struct MemRegion { |
| MemRegion() : MemRegion(nullptr, 0) {} |
| |
| + MemRegion(const MemRegion& other) { |
| + *this = other; |
| + } |
| + |
| MemRegion(T* base, size_t size) : address(base), length(size) {} |
| |
| MemRegion& operator=(const MemRegion &other) { |
| @@ -659,9 +664,10 @@ MessageQueue<T, flavor>::MessageQueue(size_t numElementsInQueue, bool configureE |
| * kQueueSizeBytes needs to be aligned to word boundary so that all offsets |
| * in the grantorDescriptor will be word aligned. |
| */ |
| + size_t page_size = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); |
| size_t kAshmemSizePageAligned = |
| - (Descriptor::alignToWordBoundary(kQueueSizeBytes) + kMetaDataSize + PAGE_SIZE - 1) & |
| - ~(PAGE_SIZE - 1); |
| + (Descriptor::alignToWordBoundary(kQueueSizeBytes) + kMetaDataSize + page_size - 1) & |
| + ~(page_size - 1); |
| |
| /* |
| * Create an ashmem region to map the memory for the ringbuffer, |
| @@ -1177,7 +1183,8 @@ void* MessageQueue<T, flavor>::mapGrantorDescr(uint32_t grantorIdx) { |
| /* |
| * Offset for mmap must be a multiple of PAGE_SIZE. |
| */ |
| - int mapOffset = (grantors[grantorIdx].offset / PAGE_SIZE) * PAGE_SIZE; |
| + size_t page_size = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); |
| + int mapOffset = (grantors[grantorIdx].offset / page_size) * page_size; |
| int mapLength = |
| grantors[grantorIdx].offset - mapOffset + grantors[grantorIdx].extent; |
| |
| @@ -1197,7 +1204,8 @@ void MessageQueue<T, flavor>::unmapGrantorDescr(void* address, |
| return; |
| } |
| |
| - int mapOffset = (grantors[grantorIdx].offset / PAGE_SIZE) * PAGE_SIZE; |
| + size_t page_size = static_cast<size_t>(sysconf(_SC_PAGE_SIZE)); |
| + int mapOffset = (grantors[grantorIdx].offset / page_size) * page_size; |
| int mapLength = |
| grantors[grantorIdx].offset - mapOffset + grantors[grantorIdx].extent; |
| void* baseAddress = reinterpret_cast<uint8_t*>(address) - |