Mesa (staging/19.2): util/u_atomic: fix return type of p_atomic_{inc,dec}_return() and p_atomic_{cmp,}xchg()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Oct 17 16:29:37 UTC 2019


Module: Mesa
Branch: staging/19.2
Commit: 4d6fcddc6533b8428663903a72e18730d7a5f9f4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d6fcddc6533b8428663903a72e18730d7a5f9f4

Author: Eric Engestrom <eric.engestrom at intel.com>
Date:   Wed Oct 16 13:58:56 2019 +0100

util/u_atomic: fix return type of p_atomic_{inc,dec}_return() and p_atomic_{cmp,}xchg()

We're trying to cast the return type to the type of the var, but instead
we were casting `sizeof(*v)`.

Fixes: 6df72e970c0e2794a565 ("util: Make u_atomic.h typeless.")
Fixes: 0a7f17cf5b591330a257 ("util/u_atomic: add p_atomic_xchg")
Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
(cherry picked from commit aaab70035a3db8da7c93965301f50e40ddbbbef9)

---

 src/util/u_atomic.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/util/u_atomic.h b/src/util/u_atomic.h
index 5949d85af1e..57c04ccb2ea 100644
--- a/src/util/u_atomic.h
+++ b/src/util/u_atomic.h
@@ -182,7 +182,7 @@
    sizeof(*v) == sizeof(uint64_t) ? atomic_inc_64((uint64_t *)(v)) : \
                                     (assert(!"should not get here"), 0))
 
-#define p_atomic_inc_return(v) ((__typeof(*v)) \
+#define p_atomic_inc_return(v) (__typeof(*v))( \
    sizeof(*v) == sizeof(uint8_t)  ? atomic_inc_8_nv ((uint8_t  *)(v)) : \
    sizeof(*v) == sizeof(uint16_t) ? atomic_inc_16_nv((uint16_t *)(v)) : \
    sizeof(*v) == sizeof(uint32_t) ? atomic_inc_32_nv((uint32_t *)(v)) : \
@@ -196,7 +196,7 @@
    sizeof(*v) == sizeof(uint64_t) ? atomic_dec_64((uint64_t *)(v)) : \
                                     (assert(!"should not get here"), 0))
 
-#define p_atomic_dec_return(v) ((__typeof(*v)) \
+#define p_atomic_dec_return(v) (__typeof(*v))( \
    sizeof(*v) == sizeof(uint8_t)  ? atomic_dec_8_nv ((uint8_t  *)(v)) : \
    sizeof(*v) == sizeof(uint16_t) ? atomic_dec_16_nv((uint16_t *)(v)) : \
    sizeof(*v) == sizeof(uint32_t) ? atomic_dec_32_nv((uint32_t *)(v)) : \
@@ -210,7 +210,7 @@
    sizeof(*v) == sizeof(uint64_t) ? atomic_add_64((uint64_t *)(v), (i)) : \
                                     (assert(!"should not get here"), 0))
 
-#define p_atomic_cmpxchg(v, old, _new) ((__typeof(*v)) \
+#define p_atomic_cmpxchg(v, old, _new) (__typeof(*v))( \
    sizeof(*v) == sizeof(uint8_t)  ? atomic_cas_8 ((uint8_t  *)(v), (uint8_t )(old), (uint8_t )(_new)) : \
    sizeof(*v) == sizeof(uint16_t) ? atomic_cas_16((uint16_t *)(v), (uint16_t)(old), (uint16_t)(_new)) : \
    sizeof(*v) == sizeof(uint32_t) ? atomic_cas_32((uint32_t *)(v), (uint32_t)(old), (uint32_t)(_new)) : \
@@ -246,7 +246,7 @@ static inline uint64_t p_atomic_xchg_64(uint64_t *v, uint64_t i)
    return actual;
 }
 
-#define p_atomic_xchg(v, i) ((__typeof(*(v))) \
+#define p_atomic_xchg(v, i) (__typeof(*(v)))( \
    sizeof(*(v)) == sizeof(uint32_t) ? p_atomic_xchg_32((uint32_t *)(v), (uint32_t)(i)) : \
    sizeof(*(v)) == sizeof(uint64_t) ? p_atomic_xchg_64((uint64_t *)(v), (uint64_t)(i)) : \
                                       (assert(!"should not get here"), 0))




More information about the mesa-commit mailing list