Skip to content

add support QNX 7.1/8.0 #1591

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions asio/include/asio/detail/impl/posix_thread.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2025 Pavlo Kleymonov (pkleymonov at qnx dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -47,6 +48,11 @@ std::size_t posix_thread::hardware_concurrency()
{
#if defined(_SC_NPROCESSORS_ONLN)
long result = sysconf(_SC_NPROCESSORS_ONLN);

#if defined(__QNX__)
result &= 0xFFFFFFFF;
#endif //defined(__QNX__)

if (result > 0)
return result;
#endif // defined(_SC_NPROCESSORS_ONLN)
Expand Down
9 changes: 8 additions & 1 deletion asio/include/asio/detail/socket_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2025 Pavlo Kleymonov (pkleymonov at qnx dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -411,7 +412,13 @@ const int max_iov_len = IOV_MAX;
// POSIX platforms are not required to define IOV_MAX.
const int max_iov_len = 16;
# endif
# define ASIO_OS_DEF_SA_RESTART SA_RESTART
// Note: QNX does not support SA_RESTART
// Therefore they are specifically excluded here.
# if defined(__QNX__)
# define ASIO_OS_DEF_SA_RESTART 0
# else
# define ASIO_OS_DEF_SA_RESTART SA_RESTART
# endif
# define ASIO_OS_DEF_SA_NOCLDSTOP SA_NOCLDSTOP
# define ASIO_OS_DEF_SA_NOCLDWAIT SA_NOCLDWAIT
#endif
Expand Down
9 changes: 9 additions & 0 deletions asio/src/examples/cpp11/local/fd_passing_stream_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2021 Heiko Hund (heiko at openvpn dot net)
// Copyright (c) 2025 Pavlo Kleymonov (pkleymonov at qnx dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -23,6 +24,14 @@
#include <sys/types.h>
#include <sys/socket.h>

#if defined(__QNX__)
#undef CMSG_ALIGN
#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))

#undef CMSG_SPACE
#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
#endif //defined(__QNX__)

using asio::local::stream_protocol;

constexpr std::size_t max_length = 1024;
Expand Down
9 changes: 9 additions & 0 deletions asio/src/examples/cpp11/local/fd_passing_stream_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2021 Heiko Hund (heiko at openvpn dot net)
// Copyright (c) 2025 Pavlo Kleymonov (pkleymonov at qnx dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand All @@ -22,6 +23,14 @@

#if defined(ASIO_HAS_LOCAL_SOCKETS)

#if defined(__QNX__)
#undef CMSG_ALIGN
#define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) & (size_t) ~(sizeof (size_t) - 1))

#undef CMSG_SPACE
#define CMSG_SPACE(len) (CMSG_ALIGN (len) + CMSG_ALIGN (sizeof (struct cmsghdr)))
#endif //defined(__QNX__)

using asio::local::stream_protocol;

class session
Expand Down
10 changes: 7 additions & 3 deletions asio/src/tests/unit/ip/multicast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// ~~~~~~~~~~~~~
//
// Copyright (c) 2003-2025 Christopher M. Kohlhoff (chris at kohlhoff dot com)
// Copyright (c) 2025 Pavlo Kleymonov (pkleymonov at qnx dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -146,17 +147,20 @@ void test()
#if (defined(__MACH__) && defined(__APPLE__)) \
|| defined(__FreeBSD__) \
|| defined(__NetBSD__) \
|| defined(__OpenBSD__)
|| defined(__OpenBSD__) \
|| defined(__QNX__)
const ip::address multicast_address_v6 = ip::make_address("ff02::1%lo0", ec);
#else // (defined(__MACH__) && defined(__APPLE__))
// || defined(__FreeBSD__)
// || defined(__NetBSD__)
// || defined(__OpenBSD__)
// || defined(__QNX__)
const ip::address multicast_address_v6 = ip::make_address("ff01::1", ec);
#endif // (defined(__MACH__) && defined(__APPLE__))
// || defined(__FreeBSD__)
// || defined(__NetBSD__)
// || defined(__OpenBSD__)
// || defined(__QNX__)
ASIO_CHECK(!have_v6 || !ec);

// join_group class.
Expand Down Expand Up @@ -207,11 +211,11 @@ void test()

if (have_v6)
{
#if defined(__hpux)
#if defined(__hpux) || defined(__QNX__)
ip::multicast::outbound_interface outbound_interface(if_nametoindex("lo0"));
#else
ip::multicast::outbound_interface outbound_interface(1);
#endif
#endif // defined(__hpux) || defined(__QNX__)
sock_v6.set_option(outbound_interface, ec);
ASIO_CHECK_MESSAGE(!ec, ec.value() << ", " << ec.message());
}
Expand Down