Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1fa99da3
Commit
1fa99da3
authored
Jan 14, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/IPv[46]Address: make the initializers even more portable
Similar to
5a5229b4
: use more C++14 constexpr.
parent
22d669da
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
18 deletions
+25
-18
IPv4Address.hxx
src/net/IPv4Address.hxx
+7
-2
IPv6Address.hxx
src/net/IPv6Address.hxx
+18
-16
No files found.
src/net/IPv4Address.hxx
View file @
1fa99da3
...
...
@@ -51,7 +51,12 @@ class IPv4Address {
#ifdef _WIN32
static
constexpr
struct
in_addr
ConstructInAddr
(
uint8_t
a
,
uint8_t
b
,
uint8_t
c
,
uint8_t
d
)
noexcept
{
return
{{{
a
,
b
,
c
,
d
}}};
struct
in_addr
result
{};
result
.
s_net
=
a
;
result
.
s_host
=
b
;
result
.
s_lh
=
c
;
result
.
s_impno
=
d
;
return
result
;
}
#else
...
...
@@ -66,7 +71,7 @@ class IPv4Address {
static
constexpr
struct
in_addr
ConstructInAddr
(
uint8_t
a
,
uint8_t
b
,
uint8_t
c
,
uint8_t
d
)
noexcept
{
return
{
ConstructInAddrT
(
a
,
b
,
c
,
d
)
}
;
return
ConstructInAddrBE
(
ConstructInAddrT
(
a
,
b
,
c
,
d
))
;
}
#endif
...
...
src/net/IPv6Address.hxx
View file @
1fa99da3
...
...
@@ -53,22 +53,24 @@ class IPv6Address {
uint16_t
c
,
uint16_t
d
,
uint16_t
e
,
uint16_t
f
,
uint16_t
g
,
uint16_t
h
)
noexcept
{
return
{{
#ifndef __HAIKU__
{
#endif
uint8_t
(
a
>>
8
),
uint8_t
(
a
),
uint8_t
(
b
>>
8
),
uint8_t
(
b
),
uint8_t
(
c
>>
8
),
uint8_t
(
c
),
uint8_t
(
d
>>
8
),
uint8_t
(
d
),
uint8_t
(
e
>>
8
),
uint8_t
(
e
),
uint8_t
(
f
>>
8
),
uint8_t
(
f
),
uint8_t
(
g
>>
8
),
uint8_t
(
g
),
uint8_t
(
h
>>
8
),
uint8_t
(
h
),
#ifndef __HAIKU__
}
#endif
}};
struct
in6_addr
result
{};
result
.
s6_addr
[
0
]
=
a
>>
8
;
result
.
s6_addr
[
1
]
=
a
;
result
.
s6_addr
[
2
]
=
b
>>
8
;
result
.
s6_addr
[
3
]
=
b
;
result
.
s6_addr
[
4
]
=
c
>>
8
;
result
.
s6_addr
[
5
]
=
c
;
result
.
s6_addr
[
6
]
=
d
>>
8
;
result
.
s6_addr
[
7
]
=
d
;
result
.
s6_addr
[
8
]
=
e
>>
8
;
result
.
s6_addr
[
9
]
=
e
;
result
.
s6_addr
[
10
]
=
f
>>
8
;
result
.
s6_addr
[
11
]
=
f
;
result
.
s6_addr
[
12
]
=
g
>>
8
;
result
.
s6_addr
[
13
]
=
g
;
result
.
s6_addr
[
14
]
=
h
>>
8
;
result
.
s6_addr
[
15
]
=
h
;
return
result
;
}
static
constexpr
struct
sockaddr_in6
Construct
(
struct
in6_addr
address
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment