Update yasio [ci build]

This commit is contained in:
halx99 2021-06-14 22:54:50 +08:00
parent c0f88c46e1
commit bde4726807
20 changed files with 154 additions and 57 deletions

View File

@ -36,7 +36,6 @@
USING_NS_CC;
using namespace yasio;
using namespace yasio::inet;
class YNSM{
public:

View File

@ -208,7 +208,7 @@
## yasio
- Upstream: https://github.com/yasio/yasio
- Version: 3.37.0
- Version: 3.37.2
- License: MIT WITH Anti-996
## zlib

View File

@ -31,7 +31,6 @@ SOFTWARE.
#include "yasio/bindings/lyasio.hpp"
#include "yasio/bindings/yasio_sol.hpp"
using namespace yasio;
using namespace yasio::inet;
namespace lyasio
{

View File

@ -25,13 +25,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "yasio/bindings/yasio_cclua.hpp"
#include "yasio/bindings/lyasio.hpp"
#include "yasio/detail/object_pool.hpp"
#include "yasio/detail/ref_ptr.hpp"
#include "yasio/cxx17/string_view.hpp"
// A workaround to fix compile issue caused by `CCPlatformMacros.h` doesn't handle `__has_attribute` it properly
# if !__has_attribute(format)
# undef __has_attribute
# endif
#include "cocos2d.h"
using namespace cocos2d;

View File

@ -35,10 +35,13 @@ SOFTWARE.
#include "yasio/obstream.hpp"
#include "yasio/detail/ref_ptr.hpp"
// A workaround to fix compile issue caused by `CCPlatformMacros.h` doesn't handle `__has_attribute` it properly
# if !__has_attribute(format)
# undef __has_attribute
# endif
#include "cocos2d.h"
#include "scripting/js-bindings/manual/cocos2d_specifics.hpp"
using namespace yasio;
using namespace yasio::inet;
using namespace cocos2d;
namespace yasio_jsb

View File

@ -28,7 +28,6 @@ SOFTWARE.
#define YASIO_HEADER_ONLY 1
#define YASIO_HAVE_KCP 1
#include "yasio/bindings/yasio_jsb20.hpp"
#include "yasio/yasio.hpp"
#include "yasio/ibstream.hpp"
#include "yasio/obstream.hpp"
@ -43,20 +42,22 @@ SOFTWARE.
#include "cocos/base/StringUtil.h"
using namespace cc;
#else
#include "cocos2d.h"
// A workaround to fix compile issue caused by `CCLog.h` doesn't handle `__has_attribute` it properly
# if !__has_attribute(format)
# undef __has_attribute
# endif
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
#include "cocos/platform/CCApplication.h"
#include "cocos/base/CCScheduler.h"
#include "cocos2d.h"
using namespace cocos2d;
using StringUtil = StringUtils;
#define StringUtil StringUtils
#define CC_LOG_DEBUG CCLOG
#endif
using namespace yasio;
using namespace yasio::inet;
namespace yasio_jsb
{

View File

@ -43,7 +43,6 @@ SOFTWARE.
#define YASIO_MAX_OPTION_ARGC 5
using namespace yasio;
using namespace yasio::inet;
namespace
{

View File

@ -43,22 +43,47 @@ SOFTWARE.
#endif
#include "yasio/detail/fp16.hpp"
namespace yasio
{
#ifdef _WIN32
// Assuming windows is always little-endian.
# if !defined(YASIO_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
# define YASIO_LITTLE_ENDIAN 1
# endif
# if defined(_MSC_VER) && _MSC_VER >= 1300 && !defined(__INTEL_COMPILER)
// If MSVC has "/RTCc" set, it will complain about truncating casts at
// runtime. This file contains some intentional truncating casts.
# pragma runtime_checks("c", off)
# endif
#else
# ifdef __APPLE__
# include <machine/endian.h> // __BYTE_ORDER
# elif defined(__FreeBSD__)
# include <sys/endian.h> // __BYTE_ORDER
# else
# if !defined(__QNX__)
# include <endian.h> // __BYTE_ORDER
# endif
# endif
# if ((defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)) || (defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN)) && \
!defined(YASIO_DISABLE_LITTLE_ENDIAN_OPT_FOR_TEST)
# define YASIO_LITTLE_ENDIAN 1
# endif
#endif
#if YASIO_LITTLE_ENDIAN
// clang-format off
# define YASIO__SWAP_SHORT(s) ((((s) >> 8) & 0x00ff) | (((s) << 8) & 0xff00))
# define YASIO__SWAP_SHORT(s) s = ((((s) >> 8) & 0x00ff) | (((s) << 8) & 0xff00))
/*
* Byte order conversion functions for 64-bit integers and 32 + 64 bit
* floating-point numbers. IEEE big-endian format is used for the
* network floating point format.
*/
#define YASIO__SWAP_LONG(l) \
# define YASIO__SWAP_LONG(l) l = \
( ( ((l) >> 24) & 0x000000FFL ) | \
( ((l) >> 8) & 0x0000FF00L ) | \
( ((l) << 8) & 0x00FF0000L ) | \
( ((l) << 24) & 0xFF000000L ) )
#define YASIO__SWAP_LONGLONG(l) \
# define YASIO__SWAP_LONGLONG(l) l = \
( ( ((l) >> 56) & 0x00000000000000FFLL ) | \
( ((l) >> 40) & 0x000000000000FF00LL ) | \
( ((l) >> 24) & 0x0000000000FF0000LL ) | \
@ -67,18 +92,24 @@ namespace yasio
( ((l) << 24) & 0x0000FF0000000000LL ) | \
( ((l) << 40) & 0x00FF000000000000LL ) | \
( ((l) << 56) & 0xFF00000000000000LL ) )
#else
# define YASIO__SWAP_SHORT(s) (void)s
# define YASIO__SWAP_LONG(l) (void)l
# define YASIO__SWAP_LONGLONG(l) (void)l
#endif
// clang-format on
namespace yasio
{
inline uint64_t(htonll)(uint64_t Value)
{
const uint64_t Retval = YASIO__SWAP_LONGLONG(Value);
return Retval;
return YASIO__SWAP_LONGLONG(Value);
}
inline uint64_t(ntohll)(uint64_t Value)
{
const uint64_t Retval = YASIO__SWAP_LONGLONG(Value);
return Retval;
return YASIO__SWAP_LONGLONG(Value);
}
YASIO__NS_INLINE
@ -110,8 +141,8 @@ template <typename _Ty> struct byte_order_impl<_Ty, sizeof(int64_t)> {
template <> struct byte_order_impl<fp16_t, sizeof(fp16_t)> {
static inline fp16_t host_to_network(fp16_t value)
{
uint16_t* p = (uint16_t*)&value;
*p = YASIO__SWAP_SHORT(*p);
uint16_t& p = (uint16_t&)value;
YASIO__SWAP_SHORT(p);
return value;
}
static inline fp16_t network_to_host(fp16_t value) { return host_to_network(value); }
@ -121,8 +152,8 @@ template <> struct byte_order_impl<fp16_t, sizeof(fp16_t)> {
template <> struct byte_order_impl<float, sizeof(float)> {
static inline float host_to_network(float value)
{
uint32_t* p = (uint32_t*)&value;
*p = YASIO__SWAP_LONG(*p);
uint32_t& p = (uint32_t&)value;
YASIO__SWAP_LONG(p);
return value;
}
static inline float network_to_host(float value) { return host_to_network(value); }
@ -131,8 +162,8 @@ template <> struct byte_order_impl<float, sizeof(float)> {
template <> struct byte_order_impl<double, sizeof(double)> {
static inline double host_to_network(double value)
{
uint64_t* p = (uint64_t*)&value;
*p = YASIO__SWAP_LONGLONG(*p);
uint64_t& p = (uint64_t&)value;
YASIO__SWAP_LONGLONG(p);
return value;
}
static inline double network_to_host(double value) { return host_to_network(value); }

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////////////////
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// client application.
//////////////////////////////////////////////////////////////////////////////////////////
//
@ -18,6 +18,8 @@
#ifndef YASIO__EVENTFD_SELECT_INTERRUPTER_HPP
#define YASIO__EVENTFD_SELECT_INTERRUPTER_HPP
#include "yasio/compiler/feature_test.hpp"
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
@ -31,11 +33,11 @@
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
class eventfd_select_interrupter
{
class eventfd_select_interrupter {
public:
// Constructor.
inline eventfd_select_interrupter() { open_descriptors(); }

View File

@ -285,11 +285,11 @@ private:
std::vector<char> blob_;
};
using ibstream_view = basic_ibstream_view<::yasio::endian::convert_traits<::yasio::endian::network_convert_tag>>;
using ibstream = basic_ibstream<::yasio::endian::convert_traits<::yasio::endian::network_convert_tag>>;
using ibstream_view = basic_ibstream_view<convert_traits<network_convert_tag>>;
using ibstream = basic_ibstream<convert_traits<network_convert_tag>>;
using fast_ibstream_view = basic_ibstream_view<::yasio::endian::convert_traits<::yasio::endian::host_convert_tag>>;
using fast_ibstream = basic_ibstream<::yasio::endian::convert_traits<::yasio::endian::host_convert_tag>>;
using fast_ibstream_view = basic_ibstream_view<convert_traits<host_convert_tag>>;
using fast_ibstream = basic_ibstream<convert_traits<host_convert_tag>>;
} // namespace yasio

View File

@ -282,8 +282,8 @@ protected:
std::stack<size_t> offset_stack_;
}; // CLASS basic_obstream
using obstream = basic_obstream<::yasio::convert_traits<::yasio::network_convert_tag>>;
using fast_obstream = basic_obstream<::yasio::convert_traits<::yasio::host_convert_tag>>;
using obstream = basic_obstream<convert_traits<network_convert_tag>>;
using fast_obstream = basic_obstream<convert_traits<host_convert_tag>>;
} // namespace yasio

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////////////////
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// client application.
//////////////////////////////////////////////////////////////////////////////////////////
//
@ -18,6 +18,8 @@
#ifndef YASIO__PIPE_SELECT_INTERRUPTER_HPP
#define YASIO__PIPE_SELECT_INTERRUPTER_HPP
#include "yasio/compiler/feature_test.hpp"
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
@ -25,11 +27,10 @@
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
class pipe_select_interrupter
{
class pipe_select_interrupter {
public:
// Constructor.
inline pipe_select_interrupter() { open_descriptors(); }

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////////////////
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// client application.
//////////////////////////////////////////////////////////////////////////////////////////
//
@ -17,6 +17,8 @@
#ifndef YASIO__SELECT_INTERRUPTER_HPP
#define YASIO__SELECT_INTERRUPTER_HPP
#include "yasio/compiler/feature_test.hpp"
#if defined(_WIN32)
# include "socket_select_interrupter.hpp"
#elif defined(__linux__)
@ -27,6 +29,7 @@
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{

View File

@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////////////////
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// client application.
//////////////////////////////////////////////////////////////////////////////////////////
//
@ -21,10 +21,10 @@
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
class socket_select_interrupter
{
class socket_select_interrupter {
public:
// Constructor.
inline socket_select_interrupter() { open_descriptors(); }

View File

@ -27,7 +27,6 @@ SOFTWARE.
#include "yasio/yasio.hpp"
using namespace yasio;
using namespace yasio::inet;
DECLARE_LOG_CATEGORY_EXTERN(yasio_ue4, Log, All);
DEFINE_LOG_CATEGORY(yasio_ue4);

View File

@ -53,9 +53,6 @@ SOFTWARE.
# pragma warning(disable : 4996)
#endif
using namespace yasio;
using namespace yasio::inet;
#if defined(_WIN32) && !defined(_WINSTORE)
static LPFN_ACCEPTEX __accept_ex = nullptr;
static LPFN_GETACCEPTEXSOCKADDRS __get_accept_ex_sockaddrs = nullptr;
@ -65,6 +62,7 @@ static LPFN_CONNECTEX __connect_ex = nullptr;
#if !YASIO__HAS_NTOP
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
YASIO__NS_INLINE
@ -79,6 +77,12 @@ namespace compat
} // namespace yasio
#endif
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
int xxsocket::xpconnect(const char* hostname, u_short port, u_short local_port)
{
auto flags = getipsv();
@ -950,6 +954,8 @@ const char* xxsocket::gai_strerror(int error)
return ::gai_strerror(error);
#endif
}
} // namespace inet
} // namespace yasio
// initialize win32 socket library
#ifdef _WIN32

View File

@ -229,6 +229,7 @@ inline bool IN6_IS_ADDR_GLOBAL(const in6_addr* a)
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
@ -1181,8 +1182,9 @@ private:
}; // namespace inet
} // namespace inet
namespace net = inet;
#if !YASIO__HAS_NS_INLINE
using namespace yasio::inet;
#endif
} // namespace yasio
namespace std

View File

@ -105,6 +105,8 @@ enum
eof = -20, // end of file.
};
}
YASIO__NS_INLINE
namespace inet
{
namespace
@ -410,7 +412,7 @@ bool io_transport::do_write(highp_time_t& wait_duration)
auto& v = *wrap;
if (call_write(v.get(), error) < 0)
{
this->set_last_errno(error, yasio::net::io_base::error_stage::WRITE);
this->set_last_errno(error, yasio::io_base::error_stage::WRITE);
break;
}
}
@ -1855,7 +1857,7 @@ bool io_service::do_read(transport_handle_t transport, fd_set* fds_array)
transport->offset_ += n;
else
{
transport->set_last_errno(yasio::errc::invalid_packet, yasio::net::io_base::error_stage::READ);
transport->set_last_errno(yasio::errc::invalid_packet, yasio::io_base::error_stage::READ);
break;
}
}
@ -1866,7 +1868,7 @@ bool io_service::do_read(transport_handle_t transport, fd_set* fds_array)
}
else
{ // n < 0, regard as connection should close
transport->set_last_errno(error, yasio::net::io_base::error_stage::READ);
transport->set_last_errno(error, yasio::io_base::error_stage::READ);
break;
}
ret = true;

View File

@ -75,6 +75,7 @@ typedef struct ares_addrinfo ares_addrinfo;
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
// options
@ -798,8 +799,8 @@ public:
source_ud_ = source_->ud_.ptr;
#endif
}
io_event(int cidx, int kind, int status, io_transport* source /*not nullable*/, int passive = 0)
: kind_(kind), passive_(passive), writable_(1), status_(status), cindex_(cidx), source_id_(source->id_), source_(source)
io_event(int cidx, int kind, int status, io_transport* source /*not nullable*/)
: kind_(kind), passive_(0), writable_(1), status_(status), cindex_(cidx), source_id_(source->id_), source_(source)
{
#if !defined(YASIO_MINIFY_EVENT)
source_ud_ = source_->ud_.ptr;
@ -867,8 +868,6 @@ private:
#endif
};
static const int io_event_size = sizeof(io_event);
class YASIO_API io_service // lgtm [cpp/class-many-fields]
{
friend class highp_timer;
@ -1183,6 +1182,9 @@ private:
}; // io_service
} // namespace inet
#if !YASIO__HAS_NS_INLINE
using namespace yasio::inet;
#endif
} /* namespace yasio */
#define yasio_shared_service yasio::gc::singleton<yasio::inet::io_service>::instance

45
thirdparty/yasio/yasio_fwd.hpp vendored Normal file
View File

@ -0,0 +1,45 @@
// A multi-platform support c++11 library with focus on asynchronous socket I/O for any
// client application.
//
//////////////////////////////////////////////////////////////////////////////////////////
/*
The MIT License (MIT)
Copyright (c) 2012-2021 HALX99
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef YASIO__FWD_HPP
#define YASIO__FWD_HPP
#include "yasio/compiler/feature_test.hpp"
namespace yasio
{
YASIO__NS_INLINE
namespace inet
{
class io_service;
class io_event;
} // namespace inet
#if !YASIO__HAS_NS_INLINE
using namespace yasio::inet;
#endif
} // namespace yasio
#endif