Skip to content

Commit f32719e

Browse files
committed
net/BareInetAddress: use s6_addr only on Linux
Looks like `s6_addr` is Linux-only and not even macOS supports it.
1 parent 7554c07 commit f32719e

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/net/BareInetAddress.cxx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@
1111
#endif
1212

1313
#ifdef _WIN32
14-
#include <string.h> // for memcpy()
1514
#include <winsock2.h>
1615
#include <ws2tcpip.h>
1716
#else
1817
#include <arpa/inet.h>
1918
#include <netinet/in.h>
2019
#endif
2120

21+
#ifndef __linux__
22+
#include <string.h> // for memcpy()
23+
#endif
24+
2225
BareInetAddress::BareInetAddress(const IPv4Address &src) noexcept
2326
{
2427
array[0] = 0;
@@ -33,16 +36,15 @@ BareInetAddress::BareInetAddress(const IPv6Address &_src) noexcept
3336
{
3437
const auto &src = _src.GetAddress();
3538
static_assert(sizeof(array) == sizeof(src));
36-
static_assert(sizeof(array) == sizeof(src.s6_addr));
3739

38-
#ifdef _WIN32
39-
/* Windows doesn't have s6_addr32 */
40-
memcpy(array, &src, sizeof(array));
41-
#else
40+
#ifdef __linux__
4241
array[0] = src.s6_addr32[0];
4342
array[1] = src.s6_addr32[1];
4443
array[2] = src.s6_addr32[2];
4544
array[3] = src.s6_addr32[3];
45+
#else
46+
/* s6_addr32 is Linux-only */
47+
memcpy(array, &src, sizeof(array));
4648
#endif
4749
}
4850

0 commit comments

Comments
 (0)