aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/netliba
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2024-08-19 16:16:30 +0200
committerGitHub <noreply@github.com>2024-08-19 17:16:30 +0300
commit9b567afd3339f4525feab53873592cb025b14251 (patch)
tree5c8489f98dc5a9a10f66065055e5a401bbd14767 /library/cpp/netliba
parent47bd121575c210d4bbb2dddcc2131759a694df05 (diff)
downloadydb-9b567afd3339f4525feab53873592cb025b14251.tar.gz
Library import 240819-0942 (#7994)
Co-authored-by: robot-piglet <robot-piglet@yandex-team.com> Co-authored-by: hiddenpath <hiddenpath@yandex-team.com> Co-authored-by: bulatman <bulatman@yandex-team.com> Co-authored-by: robot-contrib <robot-contrib@yandex-team.com> Co-authored-by: osidorkin <osidorkin@yandex-team.com> Co-authored-by: akhropov <akhropov@yandex-team.com> Co-authored-by: akozhikhov <akozhikhov@yandex-team.com> Co-authored-by: orlovorlov <orlovorlov@yandex-team.com> Co-authored-by: babenko <babenko@yandex-team.com> Co-authored-by: shadchin <shadchin@yandex-team.com> Co-authored-by: dmasloff <dmasloff@yandex-team.com> Co-authored-by: aleksei-le <aleksei-le@yandex-team.com> Co-authored-by: coteeq <coteeq@yandex-team.com> Co-authored-by: dimdim11 <dimdim11@yandex-team.com> Co-authored-by: robot-ya-builder <robot-ya-builder@yandex-team.com> Co-authored-by: iaz1607 <iaz1607@yandex-team.com>
Diffstat (limited to 'library/cpp/netliba')
-rw-r--r--library/cpp/netliba/socket/packet_queue.h6
-rw-r--r--library/cpp/netliba/socket/socket.h4
-rw-r--r--library/cpp/netliba/socket/udp_recv_packet.h2
-rw-r--r--library/cpp/netliba/v6/block_chain.h5
-rw-r--r--library/cpp/netliba/v6/cpu_affinity.cpp2
-rw-r--r--library/cpp/netliba/v6/ib_buffers.h9
-rw-r--r--library/cpp/netliba/v6/ib_collective.cpp4
-rw-r--r--library/cpp/netliba/v6/ib_low.h6
-rw-r--r--library/cpp/netliba/v6/ib_test.cpp5
-rw-r--r--library/cpp/netliba/v6/udp_client_server.cpp10
-rw-r--r--library/cpp/netliba/v6/udp_socket.h4
11 files changed, 24 insertions, 33 deletions
diff --git a/library/cpp/netliba/socket/packet_queue.h b/library/cpp/netliba/socket/packet_queue.h
index 58a84709c2..a81e956862 100644
--- a/library/cpp/netliba/socket/packet_queue.h
+++ b/library/cpp/netliba/socket/packet_queue.h
@@ -20,9 +20,9 @@ namespace NNetlibaSocket {
template <size_t TTNumWriterThreads>
class TLockFreePacketQueue {
private:
- enum { MAX_PACKETS_IN_QUEUE = INT_MAX,
- CMD_QUEUE_RESERVE = 1 << 20,
- MAX_DATA_IN_QUEUE = 32 << 20 };
+ static constexpr int MAX_PACKETS_IN_QUEUE = INT_MAX;
+ static constexpr int CMD_QUEUE_RESERVE = 1 << 20;
+ static constexpr int MAX_DATA_IN_QUEUE = 32 << 20;
typedef std::pair<TUdpRecvPacket*, TPacketMeta> TPacket;
typedef std::conditional_t<TTNumWriterThreads == 1, NThreading::TOneOneQueue<TPacket>, NThreading::TManyOneQueue<TPacket, TTNumWriterThreads>> TImpl;
diff --git a/library/cpp/netliba/socket/socket.h b/library/cpp/netliba/socket/socket.h
index c1da3c145f..0b30bd2ccf 100644
--- a/library/cpp/netliba/socket/socket.h
+++ b/library/cpp/netliba/socket/socket.h
@@ -74,8 +74,8 @@ namespace NNetlibaSocket {
///////////////////////////////////////////////////////////////////////////////
// currently netliba v6 version id is any number which's not equal to NETLIBA_V12_VERSION
- enum { NETLIBA_ANY_VERSION = -1,
- NETLIBA_V12_VERSION = 112 };
+ constexpr int NETLIBA_ANY_VERSION = -1;
+ constexpr int NETLIBA_V12_VERSION = 112;
enum EFragFlag {
FF_ALLOW_FRAG,
diff --git a/library/cpp/netliba/socket/udp_recv_packet.h b/library/cpp/netliba/socket/udp_recv_packet.h
index a2777fbcbf..a02e4c9b50 100644
--- a/library/cpp/netliba/socket/udp_recv_packet.h
+++ b/library/cpp/netliba/socket/udp_recv_packet.h
@@ -7,7 +7,7 @@
#include "allocator.h"
namespace NNetlibaSocket {
- enum { UDP_MAX_PACKET_SIZE = 8900 };
+ constexpr int UDP_MAX_PACKET_SIZE = 8900;
class TUdpHostRecvBufAlloc;
struct TUdpRecvPacket: public TWithCustomAllocator {
diff --git a/library/cpp/netliba/v6/block_chain.h b/library/cpp/netliba/v6/block_chain.h
index 25247ec05f..e214d5f603 100644
--- a/library/cpp/netliba/v6/block_chain.h
+++ b/library/cpp/netliba/v6/block_chain.h
@@ -140,9 +140,8 @@ namespace NNetliba {
TIntrusivePtr<TSharedMemory> SharedData;
TVector<TIntrusivePtr<TThrRefBase>> AttachedStorage;
char DefaultBuf[128]; // prevent allocs in most cases
- enum {
- N_DEFAULT_BLOCK_SIZE = 1024
- };
+
+ static constexpr int N_DEFAULT_BLOCK_SIZE = 1024;
char* Alloc(int sz) {
char* res = nullptr;
diff --git a/library/cpp/netliba/v6/cpu_affinity.cpp b/library/cpp/netliba/v6/cpu_affinity.cpp
index 7808092a72..55b4c98b71 100644
--- a/library/cpp/netliba/v6/cpu_affinity.cpp
+++ b/library/cpp/netliba/v6/cpu_affinity.cpp
@@ -13,7 +13,7 @@
namespace NNetliba {
class TCPUSet {
public:
- enum { MAX_SIZE = 128 };
+ static constexpr int MAX_SIZE = 128;
private:
#if defined(__FreeBSD__) && (__FreeBSD__ >= 7)
diff --git a/library/cpp/netliba/v6/ib_buffers.h b/library/cpp/netliba/v6/ib_buffers.h
index 8847250137..ae1857cdcb 100644
--- a/library/cpp/netliba/v6/ib_buffers.h
+++ b/library/cpp/netliba/v6/ib_buffers.h
@@ -11,11 +11,10 @@ namespace NNetliba {
// single thread version
class TIBBufferPool: public TThrRefBase, TNonCopyable {
- enum {
- BLOCK_SIZE_LN = 11,
- BLOCK_SIZE = 1 << BLOCK_SIZE_LN,
- BLOCK_COUNT = 1024
- };
+ static constexpr int BLOCK_SIZE_LN = 11;
+ static constexpr int BLOCK_SIZE = 1 << BLOCK_SIZE_LN;
+ static constexpr int BLOCK_COUNT = 1024;
+
struct TSingleBlock {
TIntrusivePtr<TMemoryRegion> Mem;
TVector<ui8> BlkRefCounts;
diff --git a/library/cpp/netliba/v6/ib_collective.cpp b/library/cpp/netliba/v6/ib_collective.cpp
index af5dd6d284..5251ad2eb1 100644
--- a/library/cpp/netliba/v6/ib_collective.cpp
+++ b/library/cpp/netliba/v6/ib_collective.cpp
@@ -343,9 +343,7 @@ namespace NNetliba {
//////////////////////////////////////////////////////////////////////////
struct TAllDataSync {
- enum {
- WR_COUNT = 64 * 2
- };
+ static constexpr int WR_COUNT = 64 * 2;
int CurrentBuffer;
TIntrusivePtr<TIBMemBlock> MemBlock[2];
diff --git a/library/cpp/netliba/v6/ib_low.h b/library/cpp/netliba/v6/ib_low.h
index 42e11ed941..f75f1e5379 100644
--- a/library/cpp/netliba/v6/ib_low.h
+++ b/library/cpp/netliba/v6/ib_low.h
@@ -69,9 +69,9 @@ namespace NNetliba {
int Port;
int LID;
TIntrusivePtr<TIBContext> IBCtx;
- enum {
- MAX_GID = 16
- };
+
+ static constexpr int MAX_GID = 16;
+
ibv_gid MyGidArr[MAX_GID];
public:
diff --git a/library/cpp/netliba/v6/ib_test.cpp b/library/cpp/netliba/v6/ib_test.cpp
index 178691e837..8d1c825a24 100644
--- a/library/cpp/netliba/v6/ib_test.cpp
+++ b/library/cpp/netliba/v6/ib_test.cpp
@@ -17,9 +17,8 @@ namespace NNetliba {
class TIPSocket {
TNetSocket s;
- enum {
- HDR_SIZE = UDP_LOW_LEVEL_HEADER_SIZE
- };
+
+ static constexpr int HDR_SIZE = UDP_LOW_LEVEL_HEADER_SIZE;
public:
void Init(int port) {
diff --git a/library/cpp/netliba/v6/udp_client_server.cpp b/library/cpp/netliba/v6/udp_client_server.cpp
index 14f60625f2..200daa387d 100644
--- a/library/cpp/netliba/v6/udp_client_server.cpp
+++ b/library/cpp/netliba/v6/udp_client_server.cpp
@@ -31,12 +31,10 @@ namespace NNetliba {
// тогда на приемнике повиснет пакет. Этот пакет мы зашибем по этому таймауту
const float UDP_MAX_INPUT_DATA_WAIT = UDP_TRANSFER_TIMEOUT * 2;
- enum {
- UDP_PACKET_SIZE_FULL = 8900, // used for ping to detect jumbo-frame support
- UDP_PACKET_SIZE = 8800, // max data in packet
- UDP_PACKET_SIZE_SMALL = 1350, // 1180 would be better taking into account that 1280 is guaranteed ipv6 minimum MTU
- UDP_PACKET_BUF_SIZE = UDP_PACKET_SIZE + 100,
- };
+ constexpr int UDP_PACKET_SIZE_FULL = 8900; // used for ping to detect jumbo-frame support
+ constexpr int UDP_PACKET_SIZE = 8800; // max data in packet
+ constexpr int UDP_PACKET_SIZE_SMALL = 1350; // 1180 would be better taking into account that 1280 is guaranteed ipv6 minimum MTU
+ constexpr int UDP_PACKET_BUF_SIZE = UDP_PACKET_SIZE + 100;
//////////////////////////////////////////////////////////////////////////
struct TUdpCompleteInTransfer {
diff --git a/library/cpp/netliba/v6/udp_socket.h b/library/cpp/netliba/v6/udp_socket.h
index bd95b8bcd0..5ba047ea2f 100644
--- a/library/cpp/netliba/v6/udp_socket.h
+++ b/library/cpp/netliba/v6/udp_socket.h
@@ -9,9 +9,7 @@ namespace NNetliba {
bool IsLocalIPv6(ui64 network, ui64 iface);
bool InitLocalIPList();
- enum {
- UDP_LOW_LEVEL_HEADER_SIZE = 4,
- };
+ constexpr int UDP_LOW_LEVEL_HEADER_SIZE = 4;
using NNetlibaSocket::EFragFlag;
using NNetlibaSocket::FF_ALLOW_FRAG;