Skip to content

Commit 1048ed6

Browse files
CopilotHannesWell
andcommitted
Replace deprecated OSAtomicIncrement/Decrement32 in callback.c for macOS
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 - #3186 Co-authored-by: HannesWell <wellmann.hannes1@gmx.net>
1 parent 596bef6 commit 1048ed6

File tree

1 file changed

+7
-3
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/common/library

1 file changed

+7
-3
lines changed

bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@
2929

3030
static CALLBACK_DATA callbackData[MAX_CALLBACKS];
3131
static int callbackEnabled = 1;
32+
#ifdef ATOMIC
33+
#include <stdatomic.h>
34+
static _Atomic int callbackEntryCount = 0;
35+
#else
3236
static int callbackEntryCount = 0;
37+
#endif
3338
static int initialized = 0;
3439
static jmethodID mid_Throwable_addSuppressed = NULL;
3540

@@ -45,9 +50,8 @@ static jmethodID mid_Throwable_addSuppressed = NULL;
4550
#endif
4651

4752
#ifdef ATOMIC
48-
#include <libkern/OSAtomic.h>
49-
#define ATOMIC_INC(value) OSAtomicIncrement32(&value);
50-
#define ATOMIC_DEC(value) OSAtomicDecrement32(&value);
53+
#define ATOMIC_INC(value) atomic_fetch_add_explicit(&value, 1, memory_order_relaxed);
54+
#define ATOMIC_DEC(value) atomic_fetch_sub_explicit(&value, 1, memory_order_relaxed);
5155
#else
5256
#define ATOMIC_INC(value) value++;
5357
#define ATOMIC_DEC(value) value--;

0 commit comments

Comments
 (0)