OSDN Git Service

fix GRALLOC_DRM_HANDLE_NUM_INTS definition for 64-bit lollipop-x86
authorMauro Rossi <issor.oruam@gmail.com>
Sun, 8 Nov 2015 15:29:34 +0000 (16:29 +0100)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 13 Nov 2015 16:18:41 +0000 (00:18 +0800)
As highlighted by pstglia current definition of GRALLOC_DRM_HANDLE_NUM_INTS
causes issues with 64-bit, because a pointer is accounted as having size of
an integer, which is not applicable to 64-bit pointer

The same definition adopted in AOSP hardware/drm_gralloc master branch has
been used, without changing the structure of gralloc_drm_handle_t.

gralloc_drm_handle.h

index 7fc4746..201716e 100644 (file)
@@ -36,9 +36,6 @@ struct gralloc_drm_bo_t;
 struct gralloc_drm_handle_t {
        native_handle_t base;
 
-#define GRALLOC_DRM_HANDLE_MAGIC 0x12345678
-#define GRALLOC_DRM_HANDLE_NUM_INTS 10
-#define GRALLOC_DRM_HANDLE_NUM_FDS 0
        int magic;
 
        int width;
@@ -55,6 +52,12 @@ struct gralloc_drm_handle_t {
        struct gralloc_drm_bo_t *data; /* pointer to struct gralloc_drm_bo_t */
 };
 
+#define GRALLOC_DRM_HANDLE_MAGIC 0x12345678
+#define GRALLOC_DRM_HANDLE_NUM_FDS 0
+#define GRALLOC_DRM_HANDLE_NUM_INTS (                                          \
+       ((sizeof(struct gralloc_drm_handle_t) - sizeof(native_handle_t))/sizeof(int))   \
+        - GRALLOC_DRM_HANDLE_NUM_FDS)
+
 static inline struct gralloc_drm_handle_t *gralloc_drm_handle(buffer_handle_t _handle)
 {
        struct gralloc_drm_handle_t *handle =