diff options
author | Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> | 2023-03-26 00:03:30 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-04-11 12:57:15 +0000 |
commit | 1c2d90f17ac29c227e900e0bac49425438e3f784 (patch) | |
tree | 51a638ec12d8df9d091a4713d3cc57b250af746b /src/util | |
parent | 9ccaf5583f6b9d7182c0e3ab74bd86ca6c739754 (diff) | |
download | mesa-1c2d90f17ac29c227e900e0bac49425438e3f784.tar.gz mesa-1c2d90f17ac29c227e900e0bac49425438e3f784.tar.bz2 mesa-1c2d90f17ac29c227e900e0bac49425438e3f784.zip |
util: Add aligned int64_t types for x86(non 64).
To avoid split locks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22121>
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/u_atomic.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util/u_atomic.h b/src/util/u_atomic.h index ec4569d24f7..ec77bb4d39c 100644 --- a/src/util/u_atomic.h +++ b/src/util/u_atomic.h @@ -340,4 +340,16 @@ static inline uint64_t p_atomic_xchg_64(uint64_t *v, uint64_t i) (assert(!"should not get here"), 0)) #endif +/* On x86 we can have sizeof(uint64_t) = 8 and _Alignof(uint64_t) = 4. causing split locks. The + * implementation does handle that correctly, but with an internal mutex. Extend the alignment to + * avoid this. + */ +#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__) && defined(USE_GCC_ATOMIC_BUILTINS) +typedef int64_t __attribute__((aligned(_Alignof(_Atomic(int64_t))))) p_atomic_int64_t; +typedef uint64_t __attribute__((aligned(_Alignof(_Atomic(uint64_t))))) p_atomic_uint64_t; +#else +typedef int64_t p_atomic_int64_t; +typedef uint64_t p_atomic_uint64_t; +#endif + #endif /* U_ATOMIC_H */ |