From cb1b2be86e0071f83814da1ac21e740ae7fc27eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 9 Apr 2026 17:35:07 +0000 Subject: [PATCH] [Cocoa] Replace deprecated OSAtomicIncrement/Decrement32 in callback.c Instead use the methods from stdatomic.h introduced in the C11 standard: - https://en.cppreference.com/w/c/atomic/atomic_fetch_add - https://en.cppreference.com/w/c/atomic/atomic_fetch_sub - https://en.cppreference.com/w/c/language/atomic.html - https://en.cppreference.com/w/c/atomic/memory_order Contributes to - https://github.com/eclipse-platform/eclipse.platform.swt/issues/3186 Co-authored-by: HannesWell --- .../Eclipse SWT/common/library/callback.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c index 9a022c1651..e19c875857 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c @@ -29,7 +29,12 @@ static CALLBACK_DATA callbackData[MAX_CALLBACKS]; static int callbackEnabled = 1; +#ifdef ATOMIC +#include +static _Atomic int callbackEntryCount = 0; +#else static int callbackEntryCount = 0; +#endif static int initialized = 0; static jmethodID mid_Throwable_addSuppressed = NULL; @@ -45,9 +50,8 @@ static jmethodID mid_Throwable_addSuppressed = NULL; #endif #ifdef ATOMIC -#include -#define ATOMIC_INC(value) OSAtomicIncrement32(&value); -#define ATOMIC_DEC(value) OSAtomicDecrement32(&value); +#define ATOMIC_INC(value) atomic_fetch_add_explicit(&value, 1, memory_order_relaxed); +#define ATOMIC_DEC(value) atomic_fetch_sub_explicit(&value, 1, memory_order_relaxed); #else #define ATOMIC_INC(value) value++; #define ATOMIC_DEC(value) value--;