From f0b070ef70c4dab12f2c60d3f4bfbf3ddf7fc2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 7 Aug 2024 18:00:17 +0200 Subject: [PATCH 1/2] Fix types in call to atomic_store_explicit Deals with the following compilation error: src/misc/util/utilPth.c:106:9: error: no matching function for call to 'atomic_store_explicit' atomic_store_explicit(&pThData->fWorking, 0, memory_order_release); ^~~~~~~~~~~~~~~~~~~~~ ... /include/c++/v1/atomic:1911:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('bool' vs. 'int') atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT ^ --- src/misc/util/utilPth.c | 8 ++++---- src/proof/ssw/sswPart.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/misc/util/utilPth.c b/src/misc/util/utilPth.c index 06581e9fe..88ce2a206 100644 --- a/src/misc/util/utilPth.c +++ b/src/misc/util/utilPth.c @@ -103,7 +103,7 @@ void * Util_Thread( void * pArg ) return NULL; } pThData->pUserFunc( pThData->pUserData ); - atomic_store_explicit(&pThData->fWorking, 0, memory_order_release); + atomic_store_explicit(&pThData->fWorking, false, memory_order_release); } assert( 0 ); return NULL; @@ -133,7 +133,7 @@ void Util_ProcessThreads( int (*pUserFunc)(void *), void * vData, int nProcs, in ThData[i].pUserFunc = pUserFunc; ThData[i].iThread = i; ThData[i].nTimeOut = TimeOut; - atomic_store_explicit(&ThData[i].fWorking, 0, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, false, memory_order_release); status = pthread_create( WorkerThread + i, NULL, Util_Thread, (void *)(ThData + i) ); assert( status == 0 ); } @@ -150,7 +150,7 @@ void Util_ProcessThreads( int (*pUserFunc)(void *), void * vData, int nProcs, in if ( atomic_load_explicit(&ThData[i].fWorking, memory_order_acquire) ) continue; ThData[i].pUserData = Vec_PtrPop( vStack ); - atomic_store_explicit(&ThData[i].fWorking, 1, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, true, memory_order_release); break; } } @@ -168,7 +168,7 @@ void Util_ProcessThreads( int (*pUserFunc)(void *), void * vData, int nProcs, in for ( i = 0; i < nProcs; i++ ) { ThData[i].pUserData = NULL; - atomic_store_explicit(&ThData[i].fWorking, 1, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, true, memory_order_release); } // Join threads diff --git a/src/proof/ssw/sswPart.c b/src/proof/ssw/sswPart.c index a01885b2f..599e4a8f2 100644 --- a/src/proof/ssw/sswPart.c +++ b/src/proof/ssw/sswPart.c @@ -126,7 +126,7 @@ void * Ssw_GiaWorkerThread( void * pArg ) return NULL; } Cec_ManLSCorrespondenceClasses( pThData->p, &pThData->CorPars ); - atomic_store_explicit(&pThData->fWorking, 0, memory_order_release); + atomic_store_explicit(&pThData->fWorking, false, memory_order_release); } assert( 0 ); return NULL; @@ -154,7 +154,7 @@ void Ssw_SignalCorrespondenceArray( Vec_Ptr_t * vGias, Ssw_Pars_t * pPars ) { ThData[i].CorPars = *pCorPars; ThData[i].iThread = i; - atomic_store_explicit(&ThData[i].fWorking, 0, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, false, memory_order_release); status = pthread_create( WorkerThread + i, NULL, Ssw_GiaWorkerThread, (void *)(ThData + i) ); assert( status == 0 ); } @@ -171,7 +171,7 @@ void Ssw_SignalCorrespondenceArray( Vec_Ptr_t * vGias, Ssw_Pars_t * pPars ) if ( atomic_load_explicit(&ThData[i].fWorking, memory_order_acquire) ) continue; ThData[i].p = (Gia_Man_t*)Vec_PtrPop( vStack ); - atomic_store_explicit(&ThData[i].fWorking, 1, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, true, memory_order_release); break; } } @@ -188,7 +188,7 @@ void Ssw_SignalCorrespondenceArray( Vec_Ptr_t * vGias, Ssw_Pars_t * pPars ) for ( i = 0; i < nProcs; i++ ) { ThData[i].p = NULL; - atomic_store_explicit(&ThData[i].fWorking, 1, memory_order_release); + atomic_store_explicit(&ThData[i].fWorking, true, memory_order_release); } // Join threads From 2d267786d779490747f2b548dad4bd0d3416c4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 7 Aug 2024 18:13:45 +0200 Subject: [PATCH 2/2] Include `stdbool.h` for portability of atomic calls --- src/misc/util/utilPth.c | 1 + src/proof/ssw/sswPart.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/misc/util/utilPth.c b/src/misc/util/utilPth.c index 88ce2a206..aeb912597 100644 --- a/src/misc/util/utilPth.c +++ b/src/misc/util/utilPth.c @@ -36,6 +36,7 @@ using namespace std; #else #include +#include #endif #endif diff --git a/src/proof/ssw/sswPart.c b/src/proof/ssw/sswPart.c index 599e4a8f2..89b680684 100644 --- a/src/proof/ssw/sswPart.c +++ b/src/proof/ssw/sswPart.c @@ -37,6 +37,7 @@ using namespace std; #else #include +#include #endif #endif