vcpkg/ports/freeopcua/boost-compatibility.patch
2024-11-19 22:42:29 +00:00

196 lines
5.6 KiB
Diff

diff --git a/include/opc/ua/services/services.h b/include/opc/ua/services/services.h
index f138831..4732a59 100644
--- a/include/opc/ua/services/services.h
+++ b/include/opc/ua/services/services.h
@@ -26,20 +26,7 @@
#include <vector>
#include <boost/version.hpp>
-
-
-namespace boost
-{
-namespace asio
-{
-#if BOOST_VERSION < 106600
- class io_service;
-#else
- class io_context;
- typedef io_context io_service;
-#endif
-}
-}
+#include <boost/asio/io_service.hpp>
namespace OpcUa
{
diff --git a/src/core/subscription.cpp b/src/core/subscription.cpp
index b690d3a..fdac2f3 100644
--- a/src/core/subscription.cpp
+++ b/src/core/subscription.cpp
@@ -17,11 +17,10 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
******************************************************************************/
-
-#include <opc/ua/subscription.h>
+#include <boost/asio.hpp>
#include <opc/ua/protocol/string_utils.h>
+#include <opc/ua/subscription.h>
-#include <boost/asio.hpp>
#include <iostream>
namespace OpcUa
diff --git a/src/server/asio_addon.cpp b/src/server/asio_addon.cpp
index 795a6b2..532ac3c 100644
--- a/src/server/asio_addon.cpp
+++ b/src/server/asio_addon.cpp
@@ -17,9 +17,9 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
******************************************************************************/
+#include <boost/asio.hpp>
#include <opc/ua/server/addons/asio_addon.h>
-#include <boost/asio.hpp>
#include <iostream>
#include <thread>
diff --git a/src/server/internal_subscription.cpp b/src/server/internal_subscription.cpp
index edf4715..32f6a2b 100644
--- a/src/server/internal_subscription.cpp
+++ b/src/server/internal_subscription.cpp
@@ -14,7 +14,7 @@ InternalSubscription::InternalSubscription(SubscriptionServiceInternal & service
, CurrentSession(SessionAuthenticationToken)
, Callback(callback)
, io(service.GetIOService())
- , Timer(io, boost::posix_time::milliseconds(data.RevisedPublishingInterval))
+ , Timer(io, boost::posix_time::milliseconds((int)data.RevisedPublishingInterval))
, LifeTimeCount(data.RevisedLifetimeCount)
, Logger(logger)
{
@@ -105,7 +105,7 @@ void InternalSubscription::PublishResults(const boost::system::error_code & erro
}
TimerStopped = false;
- Timer.expires_at(Timer.expires_at() + boost::posix_time::milliseconds(Data.RevisedPublishingInterval));
+ Timer.expires_at(Timer.expires_at() + boost::posix_time::milliseconds((int)Data.RevisedPublishingInterval));
std::shared_ptr<InternalSubscription> self = shared_from_this();
Timer.async_wait([self](const boost::system::error_code & error) { self->PublishResults(error); });
}
diff --git a/src/server/internal_subscription.h b/src/server/internal_subscription.h
index d42aa65..440c7ee 100644
--- a/src/server/internal_subscription.h
+++ b/src/server/internal_subscription.h
@@ -1,6 +1,7 @@
#pragma once
+#include <boost/asio.hpp>
//#include "address_space_internal.h"
#include "subscription_service_internal.h"
@@ -11,7 +12,6 @@
#include <opc/ua/protocol/string_utils.h>
#include <opc/ua/services/attributes.h>
-#include <boost/asio.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <chrono>
#include <iostream>
diff --git a/src/server/opc_tcp_async.cpp b/src/server/opc_tcp_async.cpp
index dc700c2..c761a9e 100644
--- a/src/server/opc_tcp_async.cpp
+++ b/src/server/opc_tcp_async.cpp
@@ -17,6 +17,7 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
******************************************************************************/
+#include <boost/asio.hpp>
#include "opc_tcp_processor.h"
#include <opc/ua/server/opc_tcp_async.h>
@@ -29,7 +30,6 @@
#include <opc/ua/protocol/input_from_buffer.h>
#include <array>
-#include <boost/asio.hpp>
#include <future>
#include <iostream>
#include <set>
@@ -106,7 +106,11 @@ public:
*/
typedef std::promise<void> Promise;
Promise promise;
+#if BOOST_VERSION >= 107000
+ boost::asio::post(Socket.get_executor(), bind(&Promise::set_value, &promise));
+#else
Socket.get_io_service().post(bind(&Promise::set_value, &promise));
+#endif
promise.get_future().wait();
}
@@ -372,7 +376,11 @@ void OpcTcpServer::Shutdown()
*/
typedef std::promise<void> Promise;
Promise promise;
+#if BOOST_VERSION >= 107000
+ boost::asio::post(acceptor.get_executor(), bind(&Promise::set_value, &promise));
+#else
acceptor.get_io_service().post(bind(&Promise::set_value, &promise));
+#endif
promise.get_future().wait();
}
diff --git a/src/server/subscription_service_internal.h b/src/server/subscription_service_internal.h
index 6b16e1d..53cfd22 100644
--- a/src/server/subscription_service_internal.h
+++ b/src/server/subscription_service_internal.h
@@ -9,6 +9,7 @@
#pragma once
+#include <boost/asio.hpp>
#include "address_space_addon.h"
#include "internal_subscription.h"
@@ -20,7 +21,6 @@
#include <opc/ua/protocol/strings.h>
#include <opc/ua/protocol/string_utils.h>
-#include <boost/asio.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <ctime>
#include <limits>
diff --git a/src/server/tcp_server.cpp b/src/server/tcp_server.cpp
index b4f2000..b7f4df1 100644
--- a/src/server/tcp_server.cpp
+++ b/src/server/tcp_server.cpp
@@ -8,9 +8,6 @@
/// http://www.gnu.org/licenses/lgpl.html)
///
-#ifdef _WIN32
-#include <windows.h>
-#endif
#include "tcp_server.h"
@@ -36,6 +33,15 @@
#ifdef _WIN32
+#if !defined SHUT_RD && defined SD_RECEIVE
+#define SHUT_RD SD_RECEIVE
+#endif
+#if !defined SHUT_WR && defined SD_SEND
+#define SHUT_WR SD_SEND
+#endif
+#if !defined SHUT_RDWR && defined SD_BOTH
+#define SHUT_RDWR SD_BOTH
+#endif
#else
#include <arpa/inet.h>
#include <netdb.h>