Skip to content

Commit 3947484

Browse files
committed
Add test macro for handler hook support.
1 parent 4f8bf8a commit 3947484

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

asio/include/asio/detail/config.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,19 @@
512512
# endif // defined(ASIO_MSVC) && (ASIO_MSVC >= 1400) && !defined(UNDER_CE)
513513
#endif // !defined(ASIO_DISABLE_SECURE_RTL)
514514

515+
// Handler hooking. Disabled for ancient Borland C++ and gcc compilers.
516+
#if !defined(ASIO_DISABLE_HANDLER_HOOKS)
517+
# if defined(__GNUC__)
518+
# if (__GNUC__ >= 3)
519+
# if !defined(ASIO_HAS_HANDLER_HOOKS)
520+
# define ASIO_HAS_HANDLER_HOOKS 1
521+
# endif // !defined(ASIO_HAS_HANDLER_HOOKS)
522+
# endif // (__GNUC__ >= 3)
523+
# elif !defined(__BORLANDC__)
524+
# if !defined(ASIO_HAS_HANDLER_HOOKS)
525+
# define ASIO_HAS_HANDLER_HOOKS 1
526+
# endif // !defined(ASIO_HAS_HANDLER_HOOKS)
527+
# endif // !defined(__BORLANDC__)
528+
#endif // !defined(ASIO_DISABLE_HANDLER_HOOKS)
529+
515530
#endif // ASIO_DETAIL_CONFIG_HPP

asio/include/asio/detail/handler_alloc_helpers.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
1717

1818
#include "asio/detail/config.hpp"
19-
#include <boost/detail/workaround.hpp>
2019
#include "asio/detail/addressof.hpp"
2120
#include "asio/detail/noncopyable.hpp"
2221
#include "asio/handler_alloc_hook.hpp"
@@ -31,8 +30,7 @@ namespace asio_handler_alloc_helpers {
3130
template <typename Handler>
3231
inline void* allocate(std::size_t s, Handler& h)
3332
{
34-
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
35-
|| BOOST_WORKAROUND(__GNUC__, < 3)
33+
#if !defined(ASIO_HAS_HANDLER_HOOKS)
3634
return ::operator new(s);
3735
#else
3836
using asio::asio_handler_allocate;
@@ -43,8 +41,7 @@ inline void* allocate(std::size_t s, Handler& h)
4341
template <typename Handler>
4442
inline void deallocate(void* p, std::size_t s, Handler& h)
4543
{
46-
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
47-
|| BOOST_WORKAROUND(__GNUC__, < 3)
44+
#if !defined(ASIO_HAS_HANDLER_HOOKS)
4845
::operator delete(p);
4946
#else
5047
using asio::asio_handler_deallocate;

asio/include/asio/detail/handler_invoke_helpers.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
1717

1818
#include "asio/detail/config.hpp"
19-
#include <boost/detail/workaround.hpp>
2019
#include "asio/detail/addressof.hpp"
2120
#include "asio/handler_invoke_hook.hpp"
2221

@@ -30,8 +29,7 @@ namespace asio_handler_invoke_helpers {
3029
template <typename Function, typename Context>
3130
inline void invoke(Function& function, Context& context)
3231
{
33-
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
34-
|| BOOST_WORKAROUND(__GNUC__, < 3)
32+
#if !defined(ASIO_HAS_HANDLER_HOOKS)
3533
Function tmp(function);
3634
tmp();
3735
#else
@@ -43,8 +41,7 @@ inline void invoke(Function& function, Context& context)
4341
template <typename Function, typename Context>
4442
inline void invoke(const Function& function, Context& context)
4543
{
46-
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
47-
|| BOOST_WORKAROUND(__GNUC__, < 3)
44+
#if !defined(ASIO_HAS_HANDLER_HOOKS)
4845
Function tmp(function);
4946
tmp();
5047
#else

0 commit comments

Comments
 (0)