Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1054 add unix platform
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Eltzschig <me@elchris.org>
  • Loading branch information
elfenpiff committed Feb 4, 2022
1 parent 1db8749 commit cd27ecf
Show file tree
Hide file tree
Showing 35 changed files with 854 additions and 6 deletions.
2 changes: 2 additions & 0 deletions iceoryx_hoofs/cmake/IceoryxPlatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ elseif(WIN32)
set(ICEORYX_CXX_STANDARD 17)
elseif(APPLE)
set(ICEORYX_CXX_STANDARD 17)
elseif(UNIX)
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,7 +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,
cxx::expected<mqd_t, IpcChannelError> open(const IpcChannelName_t& name,
const IpcChannelSide channelSide) noexcept;

cxx::expected<IpcChannelError> close() noexcept;
Expand Down
3 changes: 3 additions & 0 deletions iceoryx_hoofs/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ 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/)
message(WARNING "The unix platform is not officially supported (not run as CI target) but should work.")
else()
message(WARNING "Could not detect supported platform, but I'm feeling lucky today." )
endif()
Expand Down
22 changes: 22 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,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_LINUX_PLATFORM_ACL_HPP
#define IOX_HOOFS_LINUX_PLATFORM_ACL_HPP

#include <sys/acl.h>

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_DLFCN_HPP
#define IOX_HOOFS_LINUX_PLATFORM_DLFCN_HPP

#include <dlfcn.h>

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_ERRNO_HPP
#define IOX_HOOFS_LINUX_PLATFORM_ERRNO_HPP

#include <errno.h>

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_FCNTL_HPP
#define IOX_HOOFS_LINUX_PLATFORM_FCNTL_HPP

#include <fcntl.h>

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

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_FILE_HPP
#define IOX_HOOFS_LINUX_PLATFORM_FILE_HPP

#include <sys/file.h>

int iox_flock(int fd, int op);

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_GETOPT_HPP
#define IOX_HOOFS_LINUX_PLATFORM_GETOPT_HPP

#include <getopt.h>

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_GRP_HPP
#define IOX_HOOFS_LINUX_PLATFORM_GRP_HPP

#include <grp.h>

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

#endif // IOX_HOOFS_LINUX_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_LINUX_PLATFORM_INET_HPP
#define IOX_HOOFS_LINUX_PLATFORM_INET_HPP

#include <arpa/inet.h>

#endif // IOX_HOOFS_LINUX_PLATFORM_INET_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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_LINUX_PLATFORM_MMAN_HPP
#define IOX_HOOFS_LINUX_PLATFORM_MMAN_HPP

#include <sys/mman.h>

int iox_shm_open(const char* name, int oflag, mode_t mode);
int iox_shm_unlink(const char* name);

#endif // IOX_HOOFS_LINUX_PLATFORM_MMAN_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// 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_LINUX_PLATFORM_MQUEUE_HPP
#define IOX_HOOFS_LINUX_PLATFORM_MQUEUE_HPP

#include <mqueue.h>

mqd_t iox_mq_open2(const char* name, int oflag);
mqd_t iox_mq_open4(const char* name, int oflag, mode_t mode, struct mq_attr* attr);

#endif // IOX_HOOFS_LINUX_PLATFORM_MQUEUE_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// 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_LINUX_PLATFORM_PLATFORM_CORRECTION_HPP
#define IOX_HOOFS_LINUX_PLATFORM_PLATFORM_CORRECTION_HPP


#endif // IOX_HOOFS_LINUX_PLATFORM_PLATFORM_CORRECTION_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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_LINUX_PLATFORM_PLATFORM_SETTINGS_HPP
#define IOX_HOOFS_LINUX_PLATFORM_PLATFORM_SETTINGS_HPP

#include <cstdint>
#include <limits.h>

namespace iox
{
namespace posix
{
class UnixDomainSocket;
} // namespace posix

namespace platform
{
constexpr uint64_t IOX_MAX_FILENAME_LENGTH = 255U;
constexpr uint64_t IOX_MAX_PATH_LENGTH = 1023U;
constexpr bool IOX_SHM_WRITE_ZEROS_ON_CREATION = true;
constexpr uint64_t IOX_MAX_SHM_NAME_LENGTH = PATH_MAX;
constexpr const char IOX_PATH_SEPARATORS[] = "/";
constexpr uint64_t IOX_UDS_SOCKET_MAX_MESSAGE_SIZE = 4096;
constexpr const char IOX_UDS_SOCKET_PATH_PREFIX[] = "/tmp/";
constexpr const char IOX_LOCK_FILE_PATH_PREFIX[] = "/tmp/";
using IoxIpcChannelType = iox::posix::UnixDomainSocket;
} // namespace platform
} // namespace iox

#endif // IOX_HOOFS_LINUX_PLATFORM_PLATFORM_SETTINGS_HPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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_LINUX_PLATFORM_PTHREAD_HPP
#define IOX_HOOFS_LINUX_PLATFORM_PTHREAD_HPP

#include <pthread.h>

#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
#define PTHREAD_MUTEX_FAST_NP PTHREAD_MUTEX_DEFAULT

inline int iox_pthread_setname_np(pthread_t thread, const char* name)
{
return pthread_setname_np(thread, name);
}

#endif // IOX_HOOFS_LINUX_PLATFORM_PTHREAD_HPP
Loading

0 comments on commit cd27ecf

Please sign in to comment.