summaryrefslogtreecommitdiff
path: root/gralloc/gr_priv_handle.h
diff options
context:
space:
mode:
Diffstat (limited to 'gralloc/gr_priv_handle.h')
-rw-r--r--gralloc/gr_priv_handle.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/gralloc/gr_priv_handle.h b/gralloc/gr_priv_handle.h
index ae76e6a9..cbfc8676 100644
--- a/gralloc/gr_priv_handle.h
+++ b/gralloc/gr_priv_handle.h
@@ -34,6 +34,7 @@ typedef gralloc1_error_t (*GRALLOC1_PFN_PERFORM)(gralloc1_device_t *device, int
#define PRIV_HANDLE_CONST(exp) static_cast<const private_handle_t *>(exp)
+#pragma pack(push, 4)
struct private_handle_t : public native_handle_t {
enum {
PRIV_FLAGS_FRAMEBUFFER = 0x00000001,
@@ -75,15 +76,15 @@ struct private_handle_t : public native_handle_t {
int format;
int buffer_type;
unsigned int layer_count;
- uint64_t id __attribute__((aligned(8)));
- uint64_t usage __attribute__((aligned(8)));
+ uint64_t id;
+ uint64_t usage;
unsigned int size;
unsigned int offset;
unsigned int offset_metadata;
- uint64_t base __attribute__((aligned(8)));
- uint64_t base_metadata __attribute__((aligned(8)));
- uint64_t gpuaddr __attribute__((aligned(8)));
+ uint64_t base;
+ uint64_t base_metadata;
+ uint64_t gpuaddr;
static const int kNumFds = 2;
static const int kMagic = 'gmsm';
@@ -131,12 +132,14 @@ struct private_handle_t : public native_handle_t {
static int validate(const native_handle *h) {
auto *hnd = static_cast<const private_handle_t *>(h);
if (!h || h->version != sizeof(native_handle) || h->numInts != NumInts() ||
- h->numFds != kNumFds || hnd->magic != kMagic) {
- ALOGE(
- "Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) "
- "magic(%c%c%c%c/%c%c%c%c)",
+ h->numFds != kNumFds) {
+ ALOGE("Invalid gralloc handle (at %p): ver(%d/%zu) ints(%d/%d) fds(%d/%d) ",
h, h ? h->version : -1, sizeof(native_handle), h ? h->numInts : -1, NumInts(),
- h ? h->numFds : -1, kNumFds,
+ h ? h->numFds : -1, kNumFds);
+ return -EINVAL;
+ }
+ if (hnd->magic != kMagic) {
+ ALOGE("magic(%c%c%c%c/%c%c%c%c)",
hnd ? (((hnd->magic >> 24) & 0xFF) ? ((hnd->magic >> 24) & 0xFF) : '-') : '?',
hnd ? (((hnd->magic >> 16) & 0xFF) ? ((hnd->magic >> 16) & 0xFF) : '-') : '?',
hnd ? (((hnd->magic >> 8) & 0xFF) ? ((hnd->magic >> 8) & 0xFF) : '-') : '?',
@@ -173,5 +176,6 @@ struct private_handle_t : public native_handle_t {
uint64_t GetBackingstore() const { return id; }
};
+#pragma pack(pop)
#endif // __GR_PRIV_HANDLE_H__