Ignore:
Timestamp:
Jul 5, 2026, 11:13:26 PM (4 days ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
97c75bf
Parents:
3859adb
git-author:
Peter A. Buhr <pabuhr@…> (07/05/26 23:05:57)
git-committer:
Peter A. Buhr <pabuhr@…> (07/05/26 23:13:26)
Message:

move libcfa/src/concurrency/atomic.hfa to libcfa/src/bits/atomic.hfa, and update all the atomic operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/heap.cfa

    r3859adb r34d194c  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu May 15 16:47:35 2025
    13 // Update Count     : 1647
     12// Last Modified On : Sat Jul  4 16:17:06 2026
     13// Update Count     : 1658
    1414//
    1515
     
    2525
    2626#include "heap.hfa"
    27 #include "bits/align.hfa"                                                               // libAlign
    28 #include "bits/defs.hfa"                                                                // likely, unlikely
     27#include "bits/align.hfa"                                                               // libAlign, Pause, likely, unlikely
    2928#include "concurrency/kernel/fwd.hfa"                                   // disable_interrupts, enable_interrupts
    3029#include "startup.hfa"                                                                  // STARTUP_PRIORITY_MEMORY
     
    129128} // Bsearchl
    130129
    131 
    132 // pause to prevent excess processor bus usage
    133 #if defined( __i386 ) || defined( __x86_64 )
    134         #define Pause() __asm__ __volatile__ ( "pause" : : : )
    135 #elif defined(__ARM_ARCH)
    136         #define Pause() __asm__ __volatile__ ( "YIELD" : : : )
    137 #else
    138         #error unsupported architecture
    139 #endif
    140 
    141130typedef volatile uintptr_t SpinLock_t;
    142131
     
    146135
    147136        for ( unsigned int i = 1;; i += 1 ) {
    148           if ( slock == 0 && __atomic_test_and_set( &slock, __ATOMIC_ACQUIRE ) == 0 ) break; // Fence
     137          if ( slock == 0 && AtomicTas( slock ) == 0 ) break; // Fence
    149138                for ( volatile unsigned int s = 0; s < spin; s += 1 ) Pause(); // exponential spin
    150139                spin += spin;                                                                   // powers of 2
     
    155144
    156145static inline __attribute__((always_inline)) void unlock( volatile SpinLock_t & slock ) {
    157         __atomic_clear( &slock, __ATOMIC_RELEASE );                     // Fence
     146        AtomicClr( slock );                                                                     // Fence
    158147} // spin_unlock
    159148
     
    1003992                                unlock( freeHead->returnLock );
    1004993                                #else
    1005                                 block = __atomic_exchange_n( &freeHead->returnList, 0p, __ATOMIC_SEQ_CST );
     994                                block = AtomicFas( freeHead->returnList, 0p );
    1006995                                #endif // RETURNSPIN
    1007996
     
    11681157                        header->kind.real.next = freeHead->returnList; // link new node to top node
    11691158                        // CAS resets header->kind.real.next = freeHead->returnList on failure
    1170                         while ( ! __atomic_compare_exchange_n( &freeHead->returnList, &header->kind.real.next, (Heap.Storage *)header,
    1171                                                                                                    false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST ) );
     1159                        while ( ! AtomicCasv( freeHead->returnList, header->kind.real.next, (Heap.Storage *)header );
    11721160
    11731161                        #ifdef __STATISTICS__
Note: See TracChangeset for help on using the changeset viewer.