Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc32fcac

Browse files
committed
Add RISC-V spinlock support in s_lock.h.
Like the ARM case, just use gcc's __sync_lock_test_and_set();that will compile into AMOSWAP.W.AQ which does what we need.At some point it might be worth doing some work on atomic opsfor RISC-V, but this should be enough for a creditable port.Back-patch to all supported branches, just in case somebodywants to try them on RISC-V.Marek SzubaDiscussion:https://postgr.es/m/dea97b6d-f55f-1f6d-9109-504aa7dfa421@gentoo.org
1 parent4279e5b commitc32fcac

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎src/include/storage/s_lock.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ tas(volatile slock_t *lock)
314314
#endif/* __INTEL_COMPILER */
315315
#endif/* __ia64__ || __ia64 */
316316

317+
317318
/*
318319
* On ARM and ARM64, we use __sync_lock_test_and_set(int *, int) if available.
319320
*
@@ -340,6 +341,29 @@ tas(volatile slock_t *lock)
340341
#endif/* __arm__ || __arm || __aarch64__ || __aarch64 */
341342

342343

344+
/*
345+
* RISC-V likewise uses __sync_lock_test_and_set(int *, int) if available.
346+
*/
347+
#if defined(__riscv)
348+
#ifdefHAVE_GCC__SYNC_INT32_TAS
349+
#defineHAS_TEST_AND_SET
350+
351+
#defineTAS(lock) tas(lock)
352+
353+
typedefintslock_t;
354+
355+
static __inline__int
356+
tas(volatileslock_t*lock)
357+
{
358+
return__sync_lock_test_and_set(lock,1);
359+
}
360+
361+
#defineS_UNLOCK(lock) __sync_lock_release(lock)
362+
363+
#endif/* HAVE_GCC__SYNC_INT32_TAS */
364+
#endif/* __riscv */
365+
366+
343367
/* S/390 and S/390x Linux (32- and 64-bit zSeries) */
344368
#if defined(__s390__)|| defined(__s390x__)
345369
#defineHAS_TEST_AND_SET

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp