-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
os/posix: port of the posix implementation to macOS
- Loading branch information
Showing
59 changed files
with
3,369 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: CI macOS | ||
|
||
on: push | ||
|
||
jobs: | ||
test: | ||
name: Test job | ||
runs-on: macOS-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
|
||
- name: "Run CI task" | ||
run: | | ||
make test | ||
# TODO: The timer-add-api-test test is known to fail sometimes on GitHub Actions (both macOS and Linux, but macOS | ||
# is more often). The current hypothesis is that the timer cannot catch up when running on the (elastic) VMs. | ||
# Run tests more than once to increase the reproducibility. | ||
# Revert this change when the macOS branch is ready and create a separate ticket to track this for macOS and | ||
# Linux. | ||
- name: "Run flaky CI task #1" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #2" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #3" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #4" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #5" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #6" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #7" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #8" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #9" | ||
run: | | ||
make test_flaky | ||
- name: "Run flaky CI task #10" | ||
run: | | ||
make test_flaky |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
default: | ||
mkdir -p build | ||
cd build && cmake -DENABLE_UNIT_TESTS=true -DCMAKE_VERBOSE_MAKEFILE=1 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DOSAL_SYSTEM_BSPTYPE=generic-linux -DOSAL_SYSTEM_OSTYPE=posixmacos --graphviz=test.dot .. | ||
# dot -Tpng build/test.dot -o build/graph.png | ||
cd build && make | ||
|
||
test: default | ||
cd build && CTEST_OUTPUT_ON_FAILURE=1 make test | ||
|
||
test_flaky: default | ||
cd build && CTEST_OUTPUT_ON_FAILURE=1 ctest --output-on-failure -R timer-add-api-test | ||
cd build && CTEST_OUTPUT_ON_FAILURE=1 ctest --output-on-failure -R queue-test | ||
cd build && CTEST_OUTPUT_ON_FAILURE=1 ctest --output-on-failure -R sem-speed-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
###################################################################### | ||
# | ||
# CMAKE build recipe for POSIX OSAL implementation | ||
# | ||
###################################################################### | ||
|
||
# This CMake script generates targets specific to the POSIX implementation | ||
set(POSIX_BASE_MAIN_INCLIST_DIR ${CMAKE_SOURCE_DIR}/src/os/posix/inc) | ||
set(POSIX_BASE_MAIN_SRCLIST_DIR ${CMAKE_SOURCE_DIR}/src/os/posix/src) | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) | ||
include_directories(${POSIX_BASE_MAIN_INCLIST_DIR}) | ||
|
||
# The basic set of files which are always built | ||
set(POSIX_BASE_SRCLIST | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-binsem.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-common.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-console.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-countsem.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-dirs.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-errors.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-files.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-filesys.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-heap.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-idmap.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-mutex.c | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-queues.c | ||
src/os-impl-tasks.c | ||
src/os-impl-timebase.c | ||
) | ||
|
||
set(POSIX_MACOS_SRCLIST | ||
src/posix-macos-addons/semaphore/posix-macos-semaphore.c | ||
src/posix-macos-addons/mqueue/mq_internal_fs.c | ||
src/posix-macos-addons/mqueue/mq_notify.c | ||
src/posix-macos-addons/mqueue/mq_open.c | ||
src/posix-macos-addons/mqueue/mq_receive.c | ||
src/posix-macos-addons/mqueue/mq_timedreceive.c | ||
src/posix-macos-addons/mqueue/mq_timedsend.c | ||
src/posix-macos-addons/mqueue/mq_close.c | ||
src/posix-macos-addons/mqueue/mq_unlink.c | ||
src/posix-macos-addons/pthread/posix-macos-pthread.c | ||
src/posix-macos-addons/time/posix-macos-time.c | ||
src/posix-macos-addons/timer/posix-macos-timer.c | ||
) | ||
|
||
add_library(rt src/posix-macos-addons/stubs/rt.c) | ||
|
||
# Use portable blocks for basic I/O | ||
set(POSIX_IMPL_SRCLIST | ||
../portable/os-impl-posix-gettime.c | ||
../portable/os-impl-console-bsp.c | ||
../portable/os-impl-bsd-select.c | ||
../portable/os-impl-posix-io.c | ||
../portable/os-impl-posix-files.c | ||
../portable/os-impl-posix-dirs.c | ||
) | ||
|
||
if (OSAL_CONFIG_INCLUDE_SHELL) | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-shell.c | ||
) | ||
else () | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
../portable/os-impl-no-shell.c | ||
) | ||
endif () | ||
|
||
# If some form of module loading is configured, | ||
# then build the module loader | ||
if (OSAL_CONFIG_INCLUDE_DYNAMIC_LOADER) | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-loader.c | ||
../portable/os-impl-posix-dl-loader.c | ||
../portable/os-impl-posix-dl-symtab.c | ||
) | ||
else () | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
${POSIX_BASE_MAIN_SRCLIST_DIR}/os-impl-no-module.c | ||
../portable/os-impl-no-loader.c | ||
../portable/os-impl-no-symtab.c | ||
) | ||
endif () | ||
|
||
if (OSAL_CONFIG_INCLUDE_NETWORK) | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
../portable/os-impl-bsd-sockets.c # Use BSD socket layer implementation | ||
../portable/os-impl-posix-network.c # Use POSIX-defined hostname/id implementation | ||
) | ||
else() | ||
list(APPEND POSIX_IMPL_SRCLIST | ||
../portable/os-impl-no-network.c # non-implemented versions of all network APIs | ||
../portable/os-impl-no-sockets.c # non-implemented versions of all socket APIs | ||
) | ||
endif () | ||
|
||
# Defines an OBJECT target named "osal_posix_impl" with selected source files | ||
add_library(osal_posixmacos_impl OBJECT | ||
${POSIX_BASE_SRCLIST} | ||
${POSIX_MACOS_SRCLIST} | ||
${POSIX_IMPL_SRCLIST} | ||
) | ||
|
||
target_link_libraries(osal_posixmacos_impl PUBLIC posix-macos-addons) | ||
|
||
# TODO: Defining this globally but can be made more focused. | ||
# /usr/include/sys/ucred.h:96:11: error: unknown type name 'u_long'; did you mean 'long'? | ||
# volatile u_long cr_ref; /* reference count */ | ||
target_compile_definitions(osal_posixmacos_impl PRIVATE -D_DARWIN_C_SOURCE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
########################################################################## | ||
# | ||
# Build options for "posix" implementation layer | ||
# | ||
########################################################################## | ||
|
||
# this file is a placeholder for POSIX-specific compile tuning | ||
# currently no extra flags/definitions needed | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _MQUEUE_INTERNAL_H_ | ||
#define _MQUEUE_INTERNAL_H_ | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
extern const size_t MQ_FS_NAME_MAX; | ||
int mq_get_fs_pathname(const char *const pathname, char *const out_pathname); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* _MQUEUE_INTERNAL_H_ */ |
Oops, something went wrong.