Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
50fe1805
Commit
50fe1805
authored
Apr 11, 2017
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix canMemcpy assertions that are now broken on GCC 4.
parent
ffd8ede2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
16 deletions
+17
-16
dynamic.c++
c++/src/capnp/dynamic.c++
+12
-14
async-io-unix.c++
c++/src/kj/async-io-unix.c++
+1
-1
async-io-win32.c++
c++/src/kj/async-io-win32.c++
+1
-1
common.h
c++/src/kj/common.h
+3
-0
No files found.
c++/src/capnp/dynamic.c++
View file @
50fe1805
...
...
@@ -1453,13 +1453,12 @@ DynamicValue::Reader::Reader(const Reader& other) {
case
ENUM
:
case
STRUCT
:
case
ANY_POINTER
:
static_assert
(
kj
::
canMemcpy
<
Text
::
Reader
>
()
&&
kj
::
canMemcpy
<
Data
::
Reader
>
()
&&
kj
::
canMemcpy
<
DynamicList
::
Reader
>
()
&&
kj
::
canMemcpy
<
DynamicEnum
>
()
&&
kj
::
canMemcpy
<
DynamicStruct
::
Reader
>
()
&&
kj
::
canMemcpy
<
AnyPointer
::
Reader
>
(),
"Assumptions here don't hold."
);
KJ_ASSERT_CAN_MEMCPY
(
Text
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
Data
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicList
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicEnum
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicStruct
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
AnyPointer
::
Reader
);
break
;
case
CAPABILITY
:
...
...
@@ -1484,13 +1483,12 @@ DynamicValue::Reader::Reader(Reader&& other) noexcept {
case
ENUM
:
case
STRUCT
:
case
ANY_POINTER
:
static_assert
(
kj
::
canMemcpy
<
Text
::
Reader
>
()
&&
kj
::
canMemcpy
<
Data
::
Reader
>
()
&&
kj
::
canMemcpy
<
DynamicList
::
Reader
>
()
&&
kj
::
canMemcpy
<
DynamicEnum
>
()
&&
kj
::
canMemcpy
<
DynamicStruct
::
Reader
>
()
&&
kj
::
canMemcpy
<
AnyPointer
::
Reader
>
(),
"Assumptions here don't hold."
);
KJ_ASSERT_CAN_MEMCPY
(
Text
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
Data
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicList
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicEnum
);
KJ_ASSERT_CAN_MEMCPY
(
DynamicStruct
::
Reader
);
KJ_ASSERT_CAN_MEMCPY
(
AnyPointer
::
Reader
);
break
;
case
CAPABILITY
:
...
...
c++/src/kj/async-io-unix.c++
View file @
50fe1805
...
...
@@ -735,7 +735,7 @@ Promise<Array<SocketAddress>> SocketAddress::lookupHost(
addr
.
addrlen
=
cur
->
ai_addrlen
;
memcpy
(
&
addr
.
addr
.
generic
,
cur
->
ai_addr
,
cur
->
ai_addrlen
);
}
static_assert
(
canMemcpy
<
SocketAddress
>
(),
"Can't write() SocketAddress..."
);
KJ_ASSERT_CAN_MEMCPY
(
SocketAddress
);
output
.
write
(
&
addr
,
sizeof
(
addr
));
cur
=
cur
->
ai_next
;
}
...
...
c++/src/kj/async-io-win32.c++
View file @
50fe1805
...
...
@@ -782,7 +782,7 @@ Promise<Array<SocketAddress>> SocketAddress::lookupHost(
addr
.
addrlen
=
cur
->
ai_addrlen
;
memcpy
(
&
addr
.
addr
.
generic
,
cur
->
ai_addr
,
cur
->
ai_addrlen
);
}
static_assert
(
canMemcpy
<
SocketAddress
>
(),
"Can't write() SocketAddress..."
);
KJ_ASSERT_CAN_MEMCPY
(
SocketAddress
);
const
char
*
data
=
reinterpret_cast
<
const
char
*>
(
&
addr
);
size_t
size
=
sizeof
(
addr
);
...
...
c++/src/kj/common.h
View file @
50fe1805
...
...
@@ -468,6 +468,7 @@ constexpr bool canMemcpy() {
// and assume we can't memcpy() at all, and must explicitly copy-construct everything.
return
false
;
}
#define KJ_ASSERT_CAN_MEMCPY(T)
#else
template
<
typename
T
>
constexpr
bool
canMemcpy
()
{
...
...
@@ -476,6 +477,8 @@ constexpr bool canMemcpy() {
return
__is_trivially_constructible
(
T
,
const
T
&
)
&&
__is_trivially_assignable
(
T
,
const
T
&
);
}
#define KJ_ASSERT_CAN_MEMCPY(T) \
static_assert(kj::canMemcpy<T>(), "this code expects this type to be memcpy()-able");
#endif
// =======================================================================================
...
...
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