aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/include
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2009-06-16 18:25:52 -0600
committerBrian Paul <[email protected]>2009-06-16 18:25:52 -0600
commit8d482227915552c414e13743652e6794c4313ae2 (patch)
tree27bb35b40ec242836320180370d7fd5fa3820f41 /src/gallium/include
parent4ef1f8e3b52a06fcf58f78c9c36738531b91dbac (diff)
parent6b917d0b1787280f976c2f0d1ead0e5d7587a3e9 (diff)
Merge branch 'mesa_7_5_branch'
Conflicts: src/mesa/main/api_validate.c
Diffstat (limited to 'src/gallium/include')
-rw-r--r--src/gallium/include/pipe/p_refcnt.h28
-rw-r--r--src/gallium/include/pipe/p_thread.h1
2 files changed, 15 insertions, 14 deletions
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h
index 1f89453e09a..1f9088b3e9c 100644
--- a/src/gallium/include/pipe/p_refcnt.h
+++ b/src/gallium/include/pipe/p_refcnt.h
@@ -62,29 +62,29 @@ pipe_is_referenced(struct pipe_reference *reference)
* Set 'ptr' to point to 'reference' and update reference counting.
* The old thing pointed to, if any, will be unreferenced first.
* 'reference' may be NULL.
- *
- * XXX: thread safety issues!
*/
static INLINE bool
pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
{
bool destroy = FALSE;
- /* bump the reference.count first */
- if (reference) {
- assert(pipe_is_referenced(reference));
- p_atomic_inc(&reference->count);
- }
-
- if (*ptr) {
- assert(pipe_is_referenced(*ptr));
- if (p_atomic_dec_zero(&(*ptr)->count)) {
- destroy = TRUE;
+ if(*ptr != reference) {
+ /* bump the reference.count first */
+ if (reference) {
+ assert(pipe_is_referenced(reference));
+ p_atomic_inc(&reference->count);
}
+
+ if (*ptr) {
+ assert(pipe_is_referenced(*ptr));
+ if (p_atomic_dec_zero(&(*ptr)->count)) {
+ destroy = TRUE;
+ }
+ }
+
+ *ptr = reference;
}
- *ptr = reference;
-
return destroy;
}
diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h
index df6d38904a6..96e8e087447 100644
--- a/src/gallium/include/pipe/p_thread.h
+++ b/src/gallium/include/pipe/p_thread.h
@@ -36,6 +36,7 @@
#include "pipe/p_compiler.h"
+#include "util/u_debug.h" /* for assert */
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)