mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 08:50:13 +01:00
util/u_atomic: Use _Interlocked* intrinsics for non 64bits.
The intrinsics are universally available, whereas older Windows SDKs (e.g. 7.0.7600) don't have the non-intrisic entrypoint. Reviewed-by: Roland Scheidegger <sroland@vmware.com>
This commit is contained in:
parent
a7eec6d620
commit
d7f2dfb67e
1 changed files with 12 additions and 12 deletions
|
|
@ -71,8 +71,8 @@
|
|||
|
||||
#define PIPE_ATOMIC "MSVC Intrinsics"
|
||||
|
||||
/* We use the Windows header's Interlocked* functions instead of the
|
||||
* _Interlocked* intrinsics wherever we can, as support for the latter varies
|
||||
/* We use the Windows header's Interlocked*64 functions instead of the
|
||||
* _Interlocked*64 intrinsics wherever we can, as support for the latter varies
|
||||
* with target CPU, whereas Windows headers take care of all portability
|
||||
* issues: using intrinsics where available, falling back to library
|
||||
* implementations where not.
|
||||
|
|
@ -102,25 +102,25 @@
|
|||
((void) p_atomic_inc_return(_v))
|
||||
|
||||
#define p_atomic_inc_return(_v) (\
|
||||
sizeof *(_v) == sizeof(short) ? InterlockedIncrement16((short *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(long) ? InterlockedIncrement ((long *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedIncrement64((__int64 *)(_v)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _InterlockedIncrement16((short *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _InterlockedIncrement ((long *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedIncrement64 ((__int64 *)(_v)) : \
|
||||
(assert(!"should not get here"), 0))
|
||||
|
||||
#define p_atomic_dec(_v) \
|
||||
((void) p_atomic_dec_return(_v))
|
||||
|
||||
#define p_atomic_dec_return(_v) (\
|
||||
sizeof *(_v) == sizeof(short) ? InterlockedDecrement16((short *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(long) ? InterlockedDecrement ((long *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedDecrement64((__int64 *)(_v)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _InterlockedDecrement16((short *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _InterlockedDecrement ((long *) (_v)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedDecrement64 ((__int64 *)(_v)) : \
|
||||
(assert(!"should not get here"), 0))
|
||||
|
||||
#define p_atomic_cmpxchg(_v, _old, _new) (\
|
||||
sizeof *(_v) == sizeof(char) ? _InterlockedCompareExchange8((char *) (_v), (char) (_new), (char) (_old)) : \
|
||||
sizeof *(_v) == sizeof(short) ? InterlockedCompareExchange16((short *) (_v), (short) (_new), (short) (_old)) : \
|
||||
sizeof *(_v) == sizeof(long) ? InterlockedCompareExchange ((long *) (_v), (long) (_new), (long) (_old)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedCompareExchange64((__int64 *)(_v), (__int64)(_new), (__int64)(_old)) : \
|
||||
sizeof *(_v) == sizeof(char) ? _InterlockedCompareExchange8 ((char *) (_v), (char) (_new), (char) (_old)) : \
|
||||
sizeof *(_v) == sizeof(short) ? _InterlockedCompareExchange16((short *) (_v), (short) (_new), (short) (_old)) : \
|
||||
sizeof *(_v) == sizeof(long) ? _InterlockedCompareExchange ((long *) (_v), (long) (_new), (long) (_old)) : \
|
||||
sizeof *(_v) == sizeof(__int64) ? InterlockedCompareExchange64 ((__int64 *)(_v), (__int64)(_new), (__int64)(_old)) : \
|
||||
(assert(!"should not get here"), 0))
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue