net/brynet: New port: Header-only cross-platform C++ TCP network library

This commit is contained in:
Yuri Victorovich 2022-11-06 22:52:27 -08:00
parent ed183a1fc7
commit 9b44be3b71
8 changed files with 138 additions and 0 deletions

View File

@ -63,6 +63,7 @@
SUBDIR += bosh-cli
SUBDIR += bounce
SUBDIR += bredbandskollen
SUBDIR += brynet
SUBDIR += bsdec2-image-upload
SUBDIR += bsdrcmds
SUBDIR += bwi-firmware-kmod

28
net/brynet/Makefile Normal file
View File

@ -0,0 +1,28 @@
PORTNAME= brynet
DISTVERSIONPREFIX= v
DISTVERSION= 1.12.1-4
DISTVERSIONSUFFIX= -g2e7d54d
CATEGORIES= net devel
MAINTAINER= yuri@FreeBSD.org
COMMENT= Header-only cross-platform C++ TCP network library
WWW= https://github.com/IronsDu/brynet
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE
USES= cmake:testing compiler:c++17-lang
USE_GITHUB= yes
GH_ACCOUNT= IronsDu
CMAKE_OFF= brynet_BUILD_EXAMPLES brynet_BUILD_TESTS
CMAKE_TESTING_ON= brynet_BUILD_TESTS # tests are built but not run, see https://github.com/IronsDu/brynet/issues/130
NO_BUILD= yes
NO_ARCH= yes
pre-patch:
@${FIND} ${WRKSRC} -name "*.hpp" | ${XARGS} ${REINPLACE_CMD} -i '' -e 's/defined BRYNET_PLATFORM_DARWIN/& || defined BRYNET_PLATFORM_FREEBSD/'
.include <bsd.port.mk>

3
net/brynet/distinfo Normal file
View File

@ -0,0 +1,3 @@
TIMESTAMP = 1667801389
SHA256 (IronsDu-brynet-v1.12.1-4-g2e7d54d_GH0.tar.gz) = cde787bf10b9496b2af04d89d10d79a466d9bd14cde5cf495e6f70c1d4cf9210
SIZE (IronsDu-brynet-v1.12.1-4-g2e7d54d_GH0.tar.gz) = 232439

View File

@ -0,0 +1,11 @@
--- include/brynet/base/Platform.hpp.orig 2022-11-07 05:36:34 UTC
+++ include/brynet/base/Platform.hpp
@@ -5,6 +5,8 @@
#pragma comment(lib, "ws2_32")
#elif defined __APPLE_CC__ || defined __APPLE__
#define BRYNET_PLATFORM_DARWIN
+#elif defined __FreeBSD__
+#define BRYNET_PLATFORM_FREEBSD
#else
#define BRYNET_PLATFORM_LINUX
#endif

View File

@ -0,0 +1,31 @@
--- include/brynet/net/CurrentThread.hpp.orig 2022-11-07 05:56:13 UTC
+++ include/brynet/net/CurrentThread.hpp
@@ -23,7 +23,11 @@ namespace brynet { namespace net { namespace current_t
#ifdef BRYNET_PLATFORM_WINDOWS
using THREAD_ID_TYPE = DWORD;
#elif defined BRYNET_PLATFORM_LINUX || defined BRYNET_PLATFORM_DARWIN || defined BRYNET_PLATFORM_FREEBSD
+# if defined BRYNET_PLATFORM_FREEBSD
+using THREAD_ID_TYPE = pthread_t;
+# else
using THREAD_ID_TYPE = int;
+# endif
#endif
static THREAD_ID_TYPE& tid()
@@ -41,12 +45,16 @@ static THREAD_ID_TYPE& tid()
#elif defined BRYNET_PLATFORM_LINUX
cachedTid = static_cast<pid_t>(::syscall(SYS_gettid));
#elif defined BRYNET_PLATFORM_DARWIN || defined BRYNET_PLATFORM_FREEBSD
+# if defined BRYNET_PLATFORM_FREEBSD
+ cachedTid = pthread_self();
+# else
// warning: 'syscall' is deprecated:
// first deprecated in macOS 10.12 - syscall(2) is unsupported;
// please switch to a supported interface.
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
cachedTid = (pid_t) tid64;
+# endif
#endif
}

View File

@ -0,0 +1,14 @@
--- include/brynet/net/EventLoop.hpp.orig 2022-11-07 05:58:53 UTC
+++ include/brynet/net/EventLoop.hpp
@@ -72,7 +72,11 @@ class EventLoop : public brynet::base::NonCopyable (pu
mIsInBlock = true;
reAllocEventSize(1024);
+#if defined BRYNET_PLATFORM_FREEBSD
+ mSelfThreadID = nullptr;
+#else
mSelfThreadID = -1;
+#endif
mTimer = std::make_shared<brynet::base::TimerMgr>();
mSelfThreadIDIsInitialized.store(false);
}

2
net/brynet/pkg-descr Normal file
View File

@ -0,0 +1,2 @@
Brynet is a header-only cross platform high performance TCP network library
using C++11.

48
net/brynet/pkg-plist Normal file
View File

@ -0,0 +1,48 @@
include/brynet/Version.hpp
include/brynet/base/Any.hpp
include/brynet/base/AppStatus.hpp
include/brynet/base/Array.hpp
include/brynet/base/Buffer.hpp
include/brynet/base/CPP_VERSION.hpp
include/brynet/base/Noexcept.hpp
include/brynet/base/NonCopyable.hpp
include/brynet/base/Packet.hpp
include/brynet/base/Platform.hpp
include/brynet/base/Stack.hpp
include/brynet/base/Timer.hpp
include/brynet/base/WaitGroup.hpp
include/brynet/base/crypto/Base64.hpp
include/brynet/base/crypto/SHA1.hpp
include/brynet/base/endian/Endian.hpp
include/brynet/net/AsyncConnector.hpp
include/brynet/net/Channel.hpp
include/brynet/net/CurrentThread.hpp
include/brynet/net/EventLoop.hpp
include/brynet/net/Exception.hpp
include/brynet/net/ListenThread.hpp
include/brynet/net/Poller.hpp
include/brynet/net/PromiseReceive.hpp
include/brynet/net/SSLHelper.hpp
include/brynet/net/SendableMsg.hpp
include/brynet/net/Socket.hpp
include/brynet/net/SocketLibFunction.hpp
include/brynet/net/SocketLibTypes.hpp
include/brynet/net/TcpConnection.hpp
include/brynet/net/TcpService.hpp
include/brynet/net/detail/ConnectionOption.hpp
include/brynet/net/detail/ConnectorDetail.hpp
include/brynet/net/detail/ConnectorWorkInfo.hpp
include/brynet/net/detail/IOLoopData.hpp
include/brynet/net/detail/ListenThreadDetail.hpp
include/brynet/net/detail/TCPServiceDetail.hpp
include/brynet/net/detail/WakeupChannel.hpp
include/brynet/net/http/HttpFormat.hpp
include/brynet/net/http/HttpParser.hpp
include/brynet/net/http/HttpService.hpp
include/brynet/net/http/WebSocketFormat.hpp
include/brynet/net/http/http_parser.h
include/brynet/net/port/Win.hpp
include/brynet/net/wrapper/ConnectionBuilder.hpp
include/brynet/net/wrapper/HttpConnectionBuilder.hpp
include/brynet/net/wrapper/HttpServiceBuilder.hpp
include/brynet/net/wrapper/ServiceBuilder.hpp