From dc3ac8592b25a7526dd880382c829ec10bc8068c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 22 Dec 2022 11:45:10 +0100 Subject: [PATCH] heimbase-atomics: let heim_base_atomic_* use 'long' instead of 'int' on AIX As the atomics are signed on AIX, we better try to use the largest possible max value. The 'int' API uses 32-bit values for both 32-bit and 64-bit binaries: typedef int *atomic_p; int fetch_and_add(atomic_p addr, int value); The 'long' API uses 32-bit values for 32-bit binaries and 64-bit values for 64-bit binaries: typedef long *atomic_l; long fetch_and_addlp(atomic_l addr, long value); So we better use the 'long' API in order to avoid any potential problems with the heim_base_atomic_integer_max magic value, where INT[32]_MAX would be a little bit low compared to 64-bit pointer space. Signed-off-by: Stefan Metzmacher --- lib/base/heimbase-atomics.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/base/heimbase-atomics.h b/lib/base/heimbase-atomics.h index 6401f60de..271c39276 100644 --- a/lib/base/heimbase-atomics.h +++ b/lib/base/heimbase-atomics.h @@ -103,10 +103,10 @@ #define heim_base_atomic_barrier() __isync() -#define heim_base_atomic_inc(x) (fetch_and_add((atomic_p)(x), 1) + 1) -#define heim_base_atomic_dec(x) (fetch_and_add((atomic_p)(x), -1) - 1) -#define heim_base_atomic_integer_type int -#define heim_base_atomic_integer_max INT_MAX +#define heim_base_atomic_inc(x) (fetch_and_addlp((atomic_l)(x), 1) + 1) +#define heim_base_atomic_dec(x) (fetch_and_addlp((atomic_l)(x), -1) - 1) +#define heim_base_atomic_integer_type long +#define heim_base_atomic_integer_max LONG_MAX static inline void * heim_base_exchange_pointer(void *p, void *newval)