From 7324ad53c3efb8b89c70436f5eb1ca282e37a8bd Mon Sep 17 00:00:00 2001 From: Jakub Tymejczyk Date: Thu, 6 Feb 2025 13:25:30 +0100 Subject: [PATCH] Fix GCC/Posix port compilation on FreeBSD (#1239) On FreeBSD pthread_once_t is a struct and cast is required. Otherwise there's compilation error: ../../mocks/freertos/port.c:261:23: error: expected expression hSigSetupThread = PTHREAD_ONCE_INIT; ^ PTHREAD_ONCE_INIT is defined as: { PTHREAD_NEEDS_INIT, NULL } on FreeBSD --- portable/ThirdParty/GCC/Posix/port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/portable/ThirdParty/GCC/Posix/port.c b/portable/ThirdParty/GCC/Posix/port.c index 66095fb2c..5dc7f45f8 100644 --- a/portable/ThirdParty/GCC/Posix/port.c +++ b/portable/ThirdParty/GCC/Posix/port.c @@ -303,8 +303,8 @@ BaseType_t xPortStartScheduler( void ) memset( ( void * ) &hSigSetupThread.__opaque, 0, sizeof( hSigSetupThread.__opaque ) ); memset( ( void * ) &hThreadKeyOnce.__opaque, 0, sizeof( hThreadKeyOnce.__opaque ) ); #else /* Linux PTHREAD library*/ - hSigSetupThread = PTHREAD_ONCE_INIT; - hThreadKeyOnce = PTHREAD_ONCE_INIT; + hSigSetupThread = ( pthread_once_t ) PTHREAD_ONCE_INIT; + hThreadKeyOnce = ( pthread_once_t ) PTHREAD_ONCE_INIT; #endif /* __APPLE__*/ /* Restore original signal mask. */