summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/pipebuffer
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2009-12-03 23:15:38 +0100
committerRoland Scheidegger <[email protected]>2009-12-03 23:15:38 +0100
commit35a15f02634a31c1517363d91aaef8f190e24687 (patch)
treecfeb5f3a64265812737faab11788706728d1c56e /src/gallium/auxiliary/pipebuffer
parentcdb6849fc1fa0c6e360c89a6388dc8bf19a746ca (diff)
gallium: fix reference counting functions to be strict-aliasing compliant
Historically, parts of mesa code are not strict-aliasing safe, hence -fno-strict-aliasing is needed to compile (this got forgotten for scons builds for gallium, which indeed not only caused compiler warnings but also unexplicable crashes in non-debug builds). However, we should try to eliminate code not complying with strict-aliasing code at least for gallium. Hence change pipe_reference functions to make them strict-aliasing compliant. This adds a bit more complexity (especially for derived classes) but is the right thing to do, and it does in fact fix a segfault.
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h3
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c5
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c3
3 files changed, 9 insertions, 2 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 4ef372233f0..eb7e84be848 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -237,8 +237,9 @@ pb_reference(struct pb_buffer **dst,
{
struct pb_buffer *old = *dst;
- if (pipe_reference((struct pipe_reference**)dst, &src->base.reference))
+ if (pipe_reference(&(*dst)->base.reference, &src->base.reference))
pb_destroy( old );
+ *dst = src;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index 2f973684f67..a9375abd218 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -243,6 +243,7 @@ fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list,
struct pb_fence_ops *ops = fenced_list->ops;
struct list_head *curr, *next;
struct fenced_buffer *fenced_buf;
+ struct pb_buffer *pb_buf;
struct pipe_fence_handle *prev_fence = NULL;
curr = fenced_list->delayed.next;
@@ -271,7 +272,9 @@ fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list,
fenced_buffer_remove_locked(fenced_list, fenced_buf);
pipe_mutex_unlock(fenced_buf->mutex);
- pb_reference((struct pb_buffer **)&fenced_buf, NULL);
+ pb_buf = &fenced_buf->base;
+ pb_reference(&pb_buf, NULL);
+
curr = next;
next = curr->next;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 57d1ede45a4..f0c88a0ccbf 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -293,8 +293,11 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
if(buf) {
LIST_DEL(&buf->head);
pipe_mutex_unlock(mgr->mutex);
+#if 0
+ /* XXX this didn't do anything right??? */
/* Increase refcount */
pb_reference((struct pb_buffer**)&buf, &buf->base);
+#endif
return &buf->base;
}