From d2be74aa57aef69853e3451839dab43cfad39a02 Mon Sep 17 00:00:00 2001 From: Ashok Bhat Date: Thu, 6 Feb 2014 14:11:08 +0000 Subject: AArch64: Calculate private_handle_t's numInts A constant sNumInts with a value of 6 was being assigned to the numInts attribute in the private_handle_t constructor, and was also used in the validate method. That constant value is appropriate for 32-bit systems but is not appropriate for a 64-bit system where uintptr_t used for base attribute will be 64-bit. sNumInts is now changed to a static inline function that calculates numInts. Change-Id: I482ddb5915c9ff55fb2e2a87887a0ec2dc2299ed Signed-off-by: Marcus Oakland Signed-off-by: Ashok Bhat --- modules/gralloc/gralloc_priv.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/gralloc') diff --git a/modules/gralloc/gralloc_priv.h b/modules/gralloc/gralloc_priv.h index 9f32d58..22a5715 100644 --- a/modules/gralloc/gralloc_priv.h +++ b/modules/gralloc/gralloc_priv.h @@ -79,7 +79,9 @@ struct private_handle_t { int pid; #ifdef __cplusplus - static const int sNumInts = 6; + static inline int sNumInts() { + return (((sizeof(private_handle_t) - sizeof(native_handle_t))/sizeof(int)) - sNumFds); + } static const int sNumFds = 1; static const int sMagic = 0x3141592; @@ -88,7 +90,7 @@ struct private_handle_t { base(0), pid(getpid()) { version = sizeof(native_handle); - numInts = sNumInts; + numInts = sNumInts(); numFds = sNumFds; } ~private_handle_t() { @@ -98,7 +100,7 @@ struct private_handle_t { static int validate(const native_handle* h) { const private_handle_t* hnd = (const private_handle_t*)h; if (!h || h->version != sizeof(native_handle) || - h->numInts != sNumInts || h->numFds != sNumFds || + h->numInts != sNumInts() || h->numFds != sNumFds || hnd->magic != sMagic) { ALOGE("invalid gralloc handle (at %p)", h); -- cgit v1.1