Skip to content

Commit b1ee2e6

Browse files
Skptakchinglee-iotaggarg
authored
Fix MacOS Posix port (#957)
PR #914 caused Posix Port to fail to build on MacOS. This PR fixes teh build failure. This PR also adds a Matrix configuration to the GitHub kernel-demo workflow to build the Posix Demos on MacOS. --------- Co-authored-by: chinglee-iot <61685396+chinglee-iot@users.noreply.github.com> Co-authored-by: Gaurav-Aggarwal-AWS <33462878+aggarg@users.noreply.github.com>
1 parent 14dd5b5 commit b1ee2e6

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.github/workflows/kernel-demos.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,13 @@ jobs:
6565
6666
POSIX-GCC:
6767
name: Native GCC
68-
runs-on: ubuntu-latest
68+
strategy:
69+
fail-fast: false
70+
matrix:
71+
os:
72+
- macos-latest
73+
- ubuntu-latest
74+
runs-on: ${{ matrix.os }}
6975
steps:
7076
- name: Checkout the FreeRTOS/FreeRTOS Repository
7177
uses: actions/checkout@v3
@@ -83,6 +89,7 @@ jobs:
8389

8490
- name: Install GCC
8591
shell: bash
92+
if: matrix.os == 'ubuntu-latest'
8693
run: |
8794
sudo apt-get -y update
8895
sudo apt-get -y install build-essential

portable/ThirdParty/GCC/Posix/port.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757

5858
#include <errno.h>
5959
#include <pthread.h>
60+
#include <limits.h>
6061
#include <signal.h>
6162
#include <stdio.h>
6263
#include <stdlib.h>
@@ -281,10 +282,15 @@ BaseType_t xPortStartScheduler( void )
281282
*/
282283
xSchedulerEnd = pdFALSE;
283284

284-
/* Reset the pthread_once_t structure. This is required if the port
285-
* starts the scheduler again. */
286-
hSigSetupThread = PTHREAD_ONCE_INIT;
287-
285+
/* Reset pthread_once_t, needed to restart the scheduler again.
286+
* memset the internal struct members for MacOS/Linux Compatability */
287+
#if __APPLE__
288+
hSigSetupThread.__sig = _PTHREAD_ONCE_SIG_init;
289+
memset( ( void * ) &hSigSetupThread.__opaque, 0, sizeof(hSigSetupThread.__opaque));
290+
#else /* Linux PTHREAD library*/
291+
hSigSetupThread = PTHREAD_ONCE_INIT;
292+
#endif /* __APPLE__*/
293+
288294
/* Restore original signal mask. */
289295
( void ) pthread_sigmask( SIG_SETMASK, &xSchedulerOriginalSignalMask, NULL );
290296

0 commit comments

Comments
 (0)