Skip to content

Commit 612ecf3

Browse files
committed
Add ARM64 (aarch64) support to s_lock.h.
Use the same gcc atomic functions as we do on newer ARM chips. (Basically this is a copy and paste of the __arm__ code block, but omitting the SWPB option since that definitely won't work.) Back-patch to 9.2. The patch would work further back, but we'd also need to update config.guess/config.sub in older branches to make them build out-of-the-box, and there hasn't been demand for it. Mark Salter
1 parent 81fe138 commit 612ecf3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/include/storage/s_lock.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,29 @@ tas(volatile slock_t *lock)
335335
#endif /* __arm__ */
336336

337337

338+
/*
339+
* On ARM64, we use __sync_lock_test_and_set(int *, int) if available.
340+
*/
341+
#if defined(__aarch64__) || defined(__aarch64)
342+
#ifdef HAVE_GCC_INT_ATOMICS
343+
#define HAS_TEST_AND_SET
344+
345+
#define TAS(lock) tas(lock)
346+
347+
typedef int slock_t;
348+
349+
static __inline__ int
350+
tas(volatile slock_t *lock)
351+
{
352+
return __sync_lock_test_and_set(lock, 1);
353+
}
354+
355+
#define S_UNLOCK(lock) __sync_lock_release(lock)
356+
357+
#endif /* HAVE_GCC_INT_ATOMICS */
358+
#endif /* __aarch64__ */
359+
360+
338361
/* S/390 and S/390x Linux (32- and 64-bit zSeries) */
339362
#if defined(__s390__) || defined(__s390x__)
340363
#define HAS_TEST_AND_SET

0 commit comments

Comments
 (0)