Skip to content

Commit

Permalink
Merge pull request #1055 from ApexAI/iox-#1054-unix-platform-support
Browse files Browse the repository at this point in the history
Iox #1054 unix platform support
  • Loading branch information
elfenpiff authored Feb 4, 2022
2 parents 1db8749 + 9571a90 commit 7290937
Show file tree
Hide file tree
Showing 49 changed files with 1,040 additions and 40 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,20 @@ jobs:
- uses: actions/checkout@v2
- run: ./tools/ci/build-test-ubuntu-with-gcc54.sh

# uses macos to run freebsd in a virtualbox
build-test-unix-with-freebsd:
runs-on: macos-10.15
steps:
- uses: actions/checkout@v2
- name: Unix (FreeBSD) test
id: Test
uses: vmactions/freebsd-vm@v0.1.6
with:
usesh: true
mem: 2048
prepare: pkg install -y cmake git ncurses bash wget bison
run: ./tools/ci/build-test-freebsd.sh

coverage-and-docs:
runs-on: ubuntu-20.04
needs: pre-flight-check
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- Add `/tools/scripts/ice_env.sh` shell script to provide simple access to docker containers for CI debugging [#1049](https://github.com/eclipse-iceoryx/iceoryx/issues/1049)
- Introduce `cxx::FunctionalInterface` to enrich nullable classes with `and_then`, `or_else`, `value_or`, `expect` [\#996](https://github.com/eclipse-iceoryx/iceoryx/issues/996)
- Add C++17 `std::perms` as `cxx::perms` to `iceoryx_hoofs/cxx/filesystem.hpp`. [#1059](https://github.com/eclipse-iceoryx/iceoryx/issues/1059)
- Support FreeBSD as a representative for the UNIX platforms [#1054](https://github.com/eclipse-iceoryx/iceoryx/issues/1054)

**Bugfixes:**

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ You can find the full API documentation on 🌐 [https://iceoryx.io](https://ice
| QNX | yes | yes |
| MacOS | no, not planned for implementation | yes |
| Windows 10 | no, not planned for implementation | will be implemented |
| FreeBSD (Unix) | no, not planned for implementation | yes |

In general unix platforms should work with iceoryx but we only test FreeBSD on our CI.

### Where is Eclipse iceoryx used?

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_examples/iceperf/mq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void MQ::open(const std::string& name, const iox::posix::IpcChannelSide channelS
mode_t umaskSaved = umask(0);

auto mqCall = iox::posix::posixCall(iox_mq_open4)(name.c_str(), openFlags, m_filemode, &m_attributes)
.failureReturnValue(ERROR_CODE)
.failureReturnValue(INVALID_DESCRIPTOR)
.ignoreErrnos(ENOENT)
.evaluate()
.or_else([&](auto& r) {
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_examples/iceperf/mq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MQ : public IcePerfBase
static constexpr uint32_t MAX_MESSAGE_SIZE = 4 * IcePerfBase::ONE_KILOBYTE;
static constexpr uint32_t MAX_MESSAGES = 8;
static constexpr int32_t ERROR_CODE = -1;
static constexpr mqd_t INVALID_DESCRIPTOR = -1;
static constexpr mqd_t INVALID_DESCRIPTOR = std::numeric_limits<mqd_t>::max();

MQ(const std::string& publisherName, const std::string& subscriberName) noexcept;
/// @brief Cleans up outdated message queues, e.g. from a previous test
Expand Down
4 changes: 4 additions & 0 deletions iceoryx_hoofs/cmake/IceoryxPlatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ elseif(WIN32)
set(ICEORYX_CXX_STANDARD 17)
elseif(APPLE)
set(ICEORYX_CXX_STANDARD 17)
elseif(UNIX)
set(ICEORYX_CXX_STANDARD 17)
else()
set(ICEORYX_CXX_STANDARD 17)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "iceoryx_hoofs/platform/mqueue.hpp"
#include "iceoryx_hoofs/platform/stat.hpp"

#include <iostream>

namespace iox
{
namespace posix
Expand All @@ -49,7 +47,7 @@ namespace posix
class MessageQueue : public DesignPattern::Creation<MessageQueue, IpcChannelError>
{
public:
static constexpr mqd_t INVALID_DESCRIPTOR = -1;
static constexpr mqd_t INVALID_DESCRIPTOR = std::numeric_limits<mqd_t>::max();
static constexpr int32_t ERROR_CODE = -1;
static constexpr size_t SHORTEST_VALID_QUEUE_NAME = 2;
static constexpr size_t NULL_TERMINATOR_SIZE = 1;
Expand Down Expand Up @@ -100,8 +98,7 @@ class MessageQueue : public DesignPattern::Creation<MessageQueue, IpcChannelErro
const size_t maxMsgSize = MAX_MESSAGE_SIZE,
const uint64_t maxMsgNumber = 10U) noexcept;

cxx::expected<int32_t, IpcChannelError> open(const IpcChannelName_t& name,
const IpcChannelSide channelSide) noexcept;
cxx::expected<mqd_t, IpcChannelError> open(const IpcChannelName_t& name, const IpcChannelSide channelSide) noexcept;

cxx::expected<IpcChannelError> close() noexcept;
cxx::expected<IpcChannelError> unlink() noexcept;
Expand Down
13 changes: 12 additions & 1 deletion iceoryx_hoofs/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ elseif(APPLE)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/mac/)
elseif(WIN32)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/win/)
elseif(UNIX)
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/unix/)
else()
message(WARNING "Could not detect supported platform, but I'm feeling lucky today." )
set(ICEORYX_PLATFORM ${CMAKE_CURRENT_SOURCE_DIR}/unix/)
message(WARNING "Could not detect supported platform, but I'm feeling lucky today. Maybe its Unix." )
endif()

set(ICEORYX_PLATFORM ${ICEORYX_PLATFORM} CACHE PATH "" FORCE)
Expand Down Expand Up @@ -62,4 +65,12 @@ elseif(QNX)
PRIVATE
socket
)
elseif(APPLE)
elseif(WIN32)
elseif(UNIX)
target_link_libraries(iceoryx_platform
PUBLIC
rt
pthread
)
endif()
102 changes: 102 additions & 0 deletions iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/acl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_ACL_HPP
#define IOX_HOOFS_UNIX_PLATFORM_ACL_HPP

#include "iceoryx_hoofs/platform/types.hpp"

#define ACL_USER_OBJ 0
#define ACL_USER 1
#define ACL_GROUP_OBJ 2
#define ACL_GROUP 3
#define ACL_OTHER 4
#define ACL_READ 5
#define ACL_WRITE 6
#define ACL_MASK 7

struct __acl_ext
{
};

using acl_t = struct __acl_ext*;
using acl_permset_t = int;
using acl_perm_t = int;
using acl_entry_t = int;
using acl_tag_t = int;

inline int acl_valid(acl_t)
{
return 0;
}

inline int acl_set_fd(int, acl_t)
{
return 0;
}

inline acl_t acl_init(int)
{
static struct __acl_ext stub;
return &stub;
}

inline int acl_free(void*)
{
return 0;
}

inline int acl_create_entry(acl_t*, acl_entry_t*)
{
return 0;
}

inline int acl_set_tag_type(acl_entry_t, acl_tag_t)
{
return 0;
}

inline int acl_set_qualifier(acl_entry_t, const void*)
{
return 0;
}

inline int acl_get_permset(acl_entry_t, acl_permset_t*)
{
return 0;
}

inline int acl_add_perm(acl_permset_t, acl_perm_t)
{
return 0;
}

inline char* acl_to_text(acl_t, ssize_t*)
{
return nullptr;
}

inline acl_t acl_from_text(const char*)
{
return acl_t();
}

inline acl_t acl_get_fd(int)
{
return acl_t();
}

#endif // IOX_HOOFS_UNIX_PLATFORM_ACL_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_DLFCN_HPP
#define IOX_HOOFS_UNIX_PLATFORM_DLFCN_HPP

#include <dlfcn.h>

#endif // IOX_HOOFS_UNIX_PLATFORM_DLFCN_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_ERRNO_HPP
#define IOX_HOOFS_UNIX_PLATFORM_ERRNO_HPP

#include <errno.h>

#endif // IOX_HOOFS_UNIX_PLATFORM_ERRNO_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_FCNTL_HPP
#define IOX_HOOFS_UNIX_PLATFORM_FCNTL_HPP

#include <fcntl.h>

int iox_open(const char* pathname, int flags, mode_t mode);

#endif // IOX_HOOFS_UNIX_PLATFORM_FCNTL_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_FILE_HPP
#define IOX_HOOFS_UNIX_PLATFORM_FILE_HPP

#include <sys/file.h>

int iox_flock(int fd, int op);

#endif // IOX_HOOFS_UNIX_PLATFORM_FILE_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_GETOPT_HPP
#define IOX_HOOFS_UNIX_PLATFORM_GETOPT_HPP

#include <getopt.h>

#endif // IOX_HOOFS_UNIX_PLATFORM_GETOPT_HPP
24 changes: 24 additions & 0 deletions iceoryx_hoofs/platform/unix/include/iceoryx_hoofs/platform/grp.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_GRP_HPP
#define IOX_HOOFS_UNIX_PLATFORM_GRP_HPP

#include <grp.h>

int iox_getgrouplist(const char* user, gid_t group, gid_t* groups, int* ngroups);

#endif // IOX_HOOFS_UNIX_PLATFORM_GRP_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) 2020 by Robert Bosch GmbH. All rights reserved.
// Copyright (c) 2021 by Apex.AI Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
#ifndef IOX_HOOFS_UNIX_PLATFORM_INET_HPP
#define IOX_HOOFS_UNIX_PLATFORM_INET_HPP

#include <arpa/inet.h>

#endif // IOX_HOOFS_UNIX_PLATFORM_INET_HPP
Loading

0 comments on commit 7290937

Please sign in to comment.