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@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17529>
This commit is contained in:
Jesse Natalie 2022-07-08 12:29:41 -07:00 committed by Marge Bot
parent 104c301658
commit 81bbfab5df
1 changed files with 2 additions and 4 deletions

View File

@ -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) (\