Changeset d9235b6b


Ignore:
Timestamp:
Jul 8, 2026, 5:56:10 PM (20 hours ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
de67ab8
Parents:
c67158d7
Message:

restructure test program to eliminate warning message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrency/suspend_then.cfa

    rc67158d7 rd9235b6b  
    55#include <stdlib.hfa>
    66#include <string.h>
     7#include <bits/atomic.hfa>
    78
    89#define __kick_rate 150000ul
     
    3031
    3132volatile bool done = false;
    32 Coroutine * volatile the_cor = 0p;
     33Coroutine c;
     34Coroutine * the_cor = &c;
    3335
    34 void store(Coroutine & cor) {
    35         __atomic_store_n( &the_cor, &cor, __ATOMIC_SEQ_CST );
     36void store( Coroutine & cor ) {
     37        AtomicStr( the_cor, &cor );
    3638}
    3739
    3840Coroutine * take( void ) {
    3941        Coroutine * val = 0p;
    40         Coroutine * ret = __atomic_exchange_n( &the_cor, val, __ATOMIC_SEQ_CST );
     42        Coroutine * ret = AtomicFas( the_cor, val );
    4143        assert( ! ret || ! the_cor );
    4244        return ret;
     
    6870                mine = take();
    6971                if ( ! mine ) continue;
    70 
    7172                print( "T - took\n" );
    7273                resume( *mine );
     
    7778int main() {
    7879        processor p[2];
    79         Coroutine c;
    80         resume( c ); // Prime the coroutine to avoid one of the threads being its starter
    81 
    82 #if defined(__GNUC__) && __GNUC__ == 12
    83         #pragma GCC diagnostic push
    84         #pragma GCC diagnostic ignored "-Wdangling-pointer"     // this assignment is ok
    85 #endif // defined(__GNUC__) && __GNUC__ == 12
    86         the_cor = &c;
    87 #if defined(__GNUC__) && __GNUC__ == 12
    88         #pragma GCC diagnostic pop
    89 #endif // defined(__GNUC__) && __GNUC__ == 12
    90 
     80        resume( c );                                                                            // prime coroutine to make program main its starter
    9181        {
    9282                Thread t[2];
Note: See TracChangeset for help on using the changeset viewer.