Skip to content

Commit 5e8721b

Browse files
committed
OS/ThreadX: fix amoswap pointer type for libncrt_small
Fix the __AMOSWAP_W call in the SMP ready-thread claim path so the build works with STDCLIB=libncrt_small, where ULONG does not match the expected 32-bit pointer type. Signed-off-by: Huaqi Fang <578567190@qq.com>
1 parent 6820e49 commit 5e8721b

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

  • OS/ThreadX/ports_smp/nuclei

OS/ThreadX/ports_smp/nuclei/port.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
// MUST define SysTick_Handler as eclic_mtip_handler, which is registered in vector table
1717
#define SysTick_Handler eclic_mtip_handler
1818

19-
#if __RISCV_XLEN == 32
20-
#define TX_AMOSWAP __AMOSWAP_W
21-
#else
22-
#define TX_AMOSWAP __AMOSWAP_D
23-
#endif
24-
2519
/* This is the timer interrupt service routine. */
2620
void SysTick_Handler(void)
2721
{
@@ -79,8 +73,12 @@ TX_THREAD* _tx_find_ready_thread(UINT set_current)
7973
__NOP(); __NOP();
8074
rdy_thread = _tx_thread_execute_ptr[coreid];
8175
}
82-
/* Atomically claim this ready thread so only one core can schedule it. */
83-
if (TX_AMOSWAP(&rdy_thread->tx_thread_smp_core_control, 0) == 1) {
76+
/* Atomically claim this ready thread so only one core can schedule it. tx_thread_smp_core_control type is ULONG */
77+
#if __RISCV_XLEN == 32
78+
if (__AMOSWAP_W((volatile uint32_t *)&rdy_thread->tx_thread_smp_core_control, 0) == 1) {
79+
#else
80+
if (__AMOSWAP_D((volatile uint64_t *)&rdy_thread->tx_thread_smp_core_control, 0) == 1) {
81+
#endif
8482
break;
8583
}
8684
} while (1);

0 commit comments

Comments
 (0)