@@ -465,59 +465,61 @@ _PyRWMutex_Unlock(_PyRWMutex *rwmutex)
465465void _PySeqLock_LockWrite (_PySeqLock * seqlock )
466466{
467467 // lock the entry by setting by moving to an odd sequence number
468- int prev = seqlock -> sequence ;
468+ uint32_t prev = _Py_atomic_load_uint32_relaxed ( & seqlock -> sequence ) ;
469469 while (1 ) {
470470 if (SEQLOCK_IS_UPDATING (prev )) {
471471 // Someone else is currently updating the cache
472472 _Py_yield ();
473- prev = _Py_atomic_load_int32_relaxed (& seqlock -> sequence );
474- } else if (_Py_atomic_compare_exchange_int32 (& seqlock -> sequence , & prev , prev + 1 )) {
473+ prev = _Py_atomic_load_uint32_relaxed (& seqlock -> sequence );
474+ }
475+ else if (_Py_atomic_compare_exchange_uint32 (& seqlock -> sequence , & prev , prev + 1 )) {
475476 // We've locked the cache
476477 break ;
477- } else {
478+ }
479+ else {
478480 _Py_yield ();
479481 }
480482 }
481483}
482484
483485void _PySeqLock_AbandonWrite (_PySeqLock * seqlock )
484486{
485- int new_seq = seqlock -> sequence - 1 ;
487+ uint32_t new_seq = seqlock -> sequence - 1 ;
486488 assert (!SEQLOCK_IS_UPDATING (new_seq ));
487- _Py_atomic_exchange_int32 (& seqlock -> sequence , new_seq );
489+ _Py_atomic_store_uint32 (& seqlock -> sequence , new_seq );
488490}
489491
490492void _PySeqLock_UnlockWrite (_PySeqLock * seqlock )
491493{
492- int new_seq = seqlock -> sequence + 1 ;
494+ uint32_t new_seq = seqlock -> sequence + 1 ;
493495 assert (!SEQLOCK_IS_UPDATING (new_seq ));
494- _Py_atomic_exchange_int32 (& seqlock -> sequence , new_seq );
496+ _Py_atomic_store_uint32 (& seqlock -> sequence , new_seq );
495497}
496498
497- int _PySeqLock_BeginRead (_PySeqLock * seqlock )
499+ uint32_t _PySeqLock_BeginRead (_PySeqLock * seqlock )
498500{
499- int sequence = _Py_atomic_load_int_acquire (& seqlock -> sequence );
501+ uint32_t sequence = _Py_atomic_load_uint32_acquire (& seqlock -> sequence );
500502 while (SEQLOCK_IS_UPDATING (sequence )) {
501503 _Py_yield ();
502- sequence = _Py_atomic_load_int_acquire (& seqlock -> sequence );
504+ sequence = _Py_atomic_load_uint32_acquire (& seqlock -> sequence );
503505 }
504506
505507 return sequence ;
506508}
507509
508- int _PySeqLock_EndRead (_PySeqLock * seqlock , int previous )
510+ uint32_t _PySeqLock_EndRead (_PySeqLock * seqlock , uint32_t previous )
509511{
510512 // Synchronize again and validate that the entry hasn't been updated
511513 // while we were readying the values.
512- if (_Py_atomic_load_int_acquire (& seqlock -> sequence ) == previous ) {
514+ if (_Py_atomic_load_uint32_acquire (& seqlock -> sequence ) == previous ) {
513515 return 1 ;
514516 }
515517
516518 _Py_yield ();
517519 return 0 ;
518520}
519521
520- int _PySeqLock_AfterFork (_PySeqLock * seqlock )
522+ uint32_t _PySeqLock_AfterFork (_PySeqLock * seqlock )
521523{
522524 // Synchronize again and validate that the entry hasn't been updated
523525 // while we were readying the values.
0 commit comments