[Mesa-dev] [PATCH] i965: refactor, remove usage of container_of macro

Tapani Pälli tapani.palli at intel.com
Fri Aug 11 06:05:12 UTC 2017


Remove usage that was introduced by commit 29ba502. This fixes crashes
seen on Android that uses clang for compilation.

See some earlier discussion on container_of:
   https://lists.freedesktop.org/archives/mesa-dev/2017-April/152247.html

Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=102062
---
 src/mesa/drivers/dri/i965/brw_context.c       | 2 +-
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 4 ++--
 src/mesa/drivers/dri/i965/intel_batchbuffer.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 60b1457..5305484 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -934,7 +934,7 @@ brwCreateContext(gl_api api,
 
    intel_fbo_init(brw);
 
-   intel_batchbuffer_init(&brw->batch, brw->bufmgr, brw->has_llc);
+   intel_batchbuffer_init(brw, brw->bufmgr, brw->has_llc);
 
    if (brw->gen >= 6) {
       /* Create a new hardware context.  Using a hardware context means that
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 66b9a28..3aa9c4a 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -58,11 +58,11 @@ uint_key_hash(const void *key)
 }
 
 void
-intel_batchbuffer_init(struct intel_batchbuffer *batch,
+intel_batchbuffer_init(struct brw_context *brw,
                        struct brw_bufmgr *bufmgr,
                        bool has_llc)
 {
-   struct brw_context *brw = container_of(batch, brw, batch);
+   struct intel_batchbuffer *batch = &brw->batch;
 
    if (!has_llc) {
       batch->cpu_map = malloc(BATCH_SZ);
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.h b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
index 4661a2a..dfa35ec 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.h
@@ -38,7 +38,7 @@ extern "C" {
 
 struct intel_batchbuffer;
 
-void intel_batchbuffer_init(struct intel_batchbuffer *batch,
+void intel_batchbuffer_init(struct brw_context *brw,
                             struct brw_bufmgr *bufmgr,
                             bool has_llc);
 void intel_batchbuffer_free(struct intel_batchbuffer *batch);
-- 
2.9.4



More information about the mesa-dev mailing list