Skip to content

Fix MacOS Posix port #957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 28, 2024
Prev Previous commit
Next Next commit
The PTHREAD_ONCE_INIT and struct is a typedef for 0 on linux. On MacO…
…S it needs a specific value, so need to wrap the setting of it for the difference in the two OSs
  • Loading branch information
Skptak committed Jan 18, 2024
commit 21f429f0b46ba1b640a91d338e0703c4a7919880
11 changes: 8 additions & 3 deletions portable/ThirdParty/GCC/Posix/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

#include <errno.h>
#include <pthread.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -268,9 +269,13 @@ BaseType_t xPortStartScheduler( void )

/* Reset pthread_once_t, needed to restart the scheduler again.
* memset the internal struct members for MacOS/Linux Compatability */
memset( ( void * ) &hSigSetupThread.__sig, _PTHREAD_ONCE_SIG_init, sizeof(_PTHREAD_ONCE_SIG_init));
memset( ( void * ) &hSigSetupThread.__opaque, 0, sizeof(hSigSetupThread.__opaque));

#if __APPLE__
memset( ( void * ) &hSigSetupThread.__sig, _PTHREAD_ONCE_SIG_init, sizeof(_PTHREAD_ONCE_SIG_init));
memset( ( void * ) &hSigSetupThread.__opaque, 0, sizeof(hSigSetupThread.__opaque));
#else /* Linux PTHREAD library*/
hSigSetupThread = PTHREAD_ONCE_INIT;
#endif /* __APPLE__*/

/* Restore original signal mask. */
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );

Expand Down