Mesa (staging/22.1): u_atomic: Fix MSVC p_atomic_add_return
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jul 27 18:15:09 UTC 2022
Module: Mesa
Branch: staging/22.1
Commit: 9f601b6a54e957e136ada5348d468b5b513528b3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f601b6a54e957e136ada5348d468b5b513528b3
Author: Jesse Natalie <jenatali at microsoft.com>
Date: Fri Jul 8 12:29:41 2022 -0700
u_atomic: Fix MSVC p_atomic_add_return
InterlockedExchangeAdd returns the *old* value, not the new one
Cc: mesa-stable
Reviewed-by: Yonggang Luo <luoyonggang at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17529>
(cherry picked from commit 81bbfab5dfa33bf251ed519dde30128f39e7a3f9)
---
.pick_status.json | 2 +-
src/util/u_atomic.h | 6 ++----
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 26e874fc9f9..b6e93df7356 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5422,7 +5422,7 @@
"description": "u_atomic: Fix MSVC p_atomic_add_return",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null
},
diff --git a/src/util/u_atomic.h b/src/util/u_atomic.h
index c1936a52e70..c94a9a45963 100644
--- a/src/util/u_atomic.h
+++ b/src/util/u_atomic.h
@@ -153,10 +153,8 @@
((void) p_atomic_add_return((_v), (_i)))
#define p_atomic_add_return(_v, _i) (\
- sizeof *(_v) == sizeof(char) ? _InterlockedExchangeAdd8 ((char *) (_v), (_i)) : \
- sizeof *(_v) == sizeof(short) ? _InterlockedExchangeAdd16((short *) (_v), (_i)) : \
- sizeof *(_v) == sizeof(long) ? _InterlockedExchangeAdd ((long *) (_v), (_i)) : \
- sizeof *(_v) == sizeof(__int64) ? InterlockedExchangeAdd64((__int64 *)(_v), (_i)) : \
+ sizeof *(_v) == sizeof(long) ? InterlockedAdd ((long *) (_v), (_i)) : \
+ sizeof *(_v) == sizeof(__int64) ? InterlockedAdd64((__int64 *)(_v), (_i)) : \
(assert(!"should not get here"), 0))
#define p_atomic_cmpxchg(_v, _old, _new) (\
More information about the mesa-commit
mailing list