@@ -1419,6 +1419,69 @@ typedef DWORD LCID;
14191419#define OUT_OF_PROCESS_FUNCTION_TABLE_CALLBACK_EXPORT_NAME "OutOfProcessFunctionTableCallback"
14201420#endif /* defined(__x86_64) && !defined(RC_INVOKED) */
14211421
1422+ #if defined(__TINYC__ ) && (defined(__aarch64__ ) || defined(__arm64__ )) && !defined(RC_INVOKED )
1423+
1424+ #define __TCC_WINNT_ATOMIC_SEQ_CST 5
1425+ /* TCC lowers __atomic_compare_exchange's fourth argument as weak, but the
1426+ ARM64 helper reads it as success_memorder. Strong CAS passes weak == 0,
1427+ so keep Interlocked's barriers explicit here. */
1428+ #define __TCC_WINNT_MEMORY_BARRIER () __asm__ __volatile__("dmb ish" : : : "memory")
1429+
1430+ /* This covers the LONG operations needed by TCC's semaphore code and the
1431+ pointer helpers that winbase.h exposes through Interlocked pointer macros.
1432+ Add local helpers before relying on increment/decrement, add/exchange-add,
1433+ bitwise, or 64-bit Interlocked forms on Windows ARM64 with TCC. */
1434+
1435+ __CRT_INLINE LONG InterlockedExchange (LONG volatile * Target ,LONG Value ) {
1436+ LONG Old ;
1437+ __atomic_load (Target ,& Old ,__TCC_WINNT_ATOMIC_SEQ_CST );
1438+ __TCC_WINNT_MEMORY_BARRIER ();
1439+ while (!__atomic_compare_exchange (Target ,& Old ,& Value ,0 ,
1440+ __TCC_WINNT_ATOMIC_SEQ_CST ,__TCC_WINNT_ATOMIC_SEQ_CST ))
1441+ ;
1442+ __TCC_WINNT_MEMORY_BARRIER ();
1443+ return Old ;
1444+ }
1445+ __CRT_INLINE LONG InterlockedCompareExchange (LONG volatile * Destination ,LONG ExChange ,LONG Comperand ) {
1446+ LONG Old = Comperand ;
1447+ __TCC_WINNT_MEMORY_BARRIER ();
1448+ __atomic_compare_exchange (Destination ,& Old ,& ExChange ,0 ,
1449+ __TCC_WINNT_ATOMIC_SEQ_CST ,__TCC_WINNT_ATOMIC_SEQ_CST );
1450+ __TCC_WINNT_MEMORY_BARRIER ();
1451+ return Old ;
1452+ }
1453+ __CRT_INLINE PVOID __TCC_WINNT_InterlockedExchangePointer (PVOID volatile * Target ,PVOID Value ) {
1454+ PVOID Old ;
1455+ __atomic_load (Target ,& Old ,__TCC_WINNT_ATOMIC_SEQ_CST );
1456+ __TCC_WINNT_MEMORY_BARRIER ();
1457+ while (!__atomic_compare_exchange (Target ,& Old ,& Value ,0 ,
1458+ __TCC_WINNT_ATOMIC_SEQ_CST ,__TCC_WINNT_ATOMIC_SEQ_CST ))
1459+ ;
1460+ __TCC_WINNT_MEMORY_BARRIER ();
1461+ return Old ;
1462+ }
1463+ __CRT_INLINE PVOID __TCC_WINNT_InterlockedCompareExchangePointer (PVOID volatile * Destination ,PVOID ExChange ,PVOID Comperand ) {
1464+ PVOID Old = Comperand ;
1465+ __TCC_WINNT_MEMORY_BARRIER ();
1466+ __atomic_compare_exchange (Destination ,& Old ,& ExChange ,0 ,
1467+ __TCC_WINNT_ATOMIC_SEQ_CST ,__TCC_WINNT_ATOMIC_SEQ_CST );
1468+ __TCC_WINNT_MEMORY_BARRIER ();
1469+ return Old ;
1470+ }
1471+
1472+ #define InterlockedExchangePointer __TCC_WINNT_InterlockedExchangePointer
1473+ #define InterlockedCompareExchangePointer __TCC_WINNT_InterlockedCompareExchangePointer
1474+ #define InterlockedCompareExchangePointerAcquire InterlockedCompareExchangePointer
1475+ #define InterlockedCompareExchangePointerRelease InterlockedCompareExchangePointer
1476+
1477+ #define InterlockedCompareExchangeAcquire InterlockedCompareExchange
1478+ #define InterlockedCompareExchangeRelease InterlockedCompareExchange
1479+
1480+ #undef __TCC_WINNT_MEMORY_BARRIER
1481+ #undef __TCC_WINNT_ATOMIC_SEQ_CST
1482+
1483+ #endif /* defined(__TINYC__) && (defined(__aarch64__) || defined(__arm64__)) && !defined(RC_INVOKED) */
1484+
14221485#if defined(_ARM64_ )
14231486
14241487/* ARM64 Context Definition */
0 commit comments