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
2d4bf146
Commit
2d4bf146
authored
Mar 25, 2016
by
Matthew Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added units compliance
parent
5db2c8f8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
layout.c++
c++/src/capnp/layout.c++
+32
-32
No files found.
c++/src/capnp/layout.c++
View file @
2d4bf146
...
@@ -1559,14 +1559,14 @@ struct WireHelpers {
...
@@ -1559,14 +1559,14 @@ struct WireHelpers {
if
(
canonical
)
{
if
(
canonical
)
{
// Truncate the data section
// Truncate the data section
while
((
dataSize
!=
0
)
&&
while
((
dataSize
!=
0
*
WORDS
)
&&
(
value
.
getDataField
<
uint64_t
>
(
dataSize
-
1
)
==
0
))
{
(
value
.
getDataField
<
uint64_t
>
(
dataSize
*
(
ELEMENTS
/
WORDS
)
-
1
*
ELEMENTS
)
==
0
))
{
dataSize
--
;
dataSize
-=
1
*
WORDS
;
}
}
// Truncate pointer section
// Truncate pointer section
while
((
ptrCount
!=
0
)
&&
while
((
ptrCount
!=
0
*
POINTERS
)
&&
value
.
getPointerField
(
ptrCount
-
1
).
isNull
())
{
value
.
getPointerField
(
ptrCount
-
1
*
POINTERS
).
isNull
())
{
ptrCount
--
;
ptrCount
-=
1
*
POINTERS
;
}
}
}
}
...
@@ -1577,15 +1577,15 @@ struct WireHelpers {
...
@@ -1577,15 +1577,15 @@ struct WireHelpers {
if
(
value
.
dataSize
==
1
*
BITS
)
{
if
(
value
.
dataSize
==
1
*
BITS
)
{
// Data size could be made 0 by truncation
// Data size could be made 0 by truncation
if
(
dataSize
!=
0
)
{
if
(
dataSize
!=
0
*
WORDS
)
{
*
reinterpret_cast
<
char
*>
(
ptr
)
=
value
.
getDataField
<
bool
>
(
0
*
ELEMENTS
);
*
reinterpret_cast
<
char
*>
(
ptr
)
=
value
.
getDataField
<
bool
>
(
0
*
ELEMENTS
);
}
}
}
else
{
}
else
{
memcpy
(
ptr
,
value
.
data
,
dataSize
*
BYTES_PER_WORD
);
memcpy
(
ptr
,
value
.
data
,
dataSize
*
BYTES_PER_WORD
/
BYTES
);
}
}
WirePointer
*
pointerSection
=
reinterpret_cast
<
WirePointer
*>
(
ptr
+
dataSize
);
WirePointer
*
pointerSection
=
reinterpret_cast
<
WirePointer
*>
(
ptr
+
dataSize
);
for
(
uint
i
=
0
;
i
<
ptrCount
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
ptrCount
/
POINTERS
;
i
++
)
{
copyPointer
(
segment
,
capTable
,
pointerSection
+
i
,
copyPointer
(
segment
,
capTable
,
pointerSection
+
i
,
value
.
segment
,
value
.
capTable
,
value
.
pointers
+
i
,
value
.
segment
,
value
.
capTable
,
value
.
pointers
+
i
,
value
.
nestingLimit
,
nullptr
,
canonical
);
value
.
nestingLimit
,
nullptr
,
canonical
);
...
@@ -1643,26 +1643,26 @@ struct WireHelpers {
...
@@ -1643,26 +1643,26 @@ struct WireHelpers {
WirePointerCount
ptrCount
=
0
*
POINTERS
;
WirePointerCount
ptrCount
=
0
*
POINTERS
;
if
(
canonical
)
{
if
(
canonical
)
{
for
(
auto
ec
=
ElementCount
(
0
);
ec
<
value
.
elementCount
;
ec
++
)
{
for
(
auto
ec
=
ElementCount
(
0
);
ec
<
value
.
elementCount
;
ec
+=
1
*
ELEMENTS
)
{
auto
se
=
value
.
getStructElement
(
ec
);
auto
se
=
value
.
getStructElement
(
ec
);
WordCount
localDataSize
=
declDataSize
;
WordCount
localDataSize
=
declDataSize
;
while
((
localDataSize
!=
0
*
WORDS
)
&&
while
((
localDataSize
!=
0
*
WORDS
)
&&
(
se
.
getDataField
<
uint64_t
>
(
localDataSize
-
1
)
==
0
))
{
(
se
.
getDataField
<
uint64_t
>
(
(
localDataSize
-
1
*
WORDS
)
/
WORDS
*
ELEMENTS
)
==
0
))
{
localDataSize
--
;
localDataSize
-=
WORDS
;
}
}
if
(
localDataSize
>
dataSize
)
{
if
(
localDataSize
>
dataSize
)
{
dataSize
=
localDataSize
;
dataSize
=
localDataSize
;
}
}
WirePointerCount
localPtrCount
=
declPointerCount
;
WirePointerCount
localPtrCount
=
declPointerCount
;
while
((
localPtrCount
!=
0
*
POINTERS
)
&&
while
((
localPtrCount
!=
0
*
POINTERS
)
&&
se
.
getPointerField
(
localPtrCount
-
1
).
isNull
())
{
se
.
getPointerField
(
localPtrCount
-
1
*
POINTERS
).
isNull
())
{
localPtrCount
--
;
localPtrCount
-=
1
*
POINTERS
;
}
}
if
(
localPtrCount
>
ptrCount
)
{
if
(
localPtrCount
>
ptrCount
)
{
ptrCount
=
localPtrCount
;
ptrCount
=
localPtrCount
;
}
}
}
}
totalSize
=
(
dataSize
+
ptrCount
*
WORDS_PER_POINTER
)
*
value
.
elementCount
;
totalSize
=
(
dataSize
+
ptrCount
*
WORDS_PER_POINTER
)
/
ELEMENTS
*
value
.
elementCount
;
}
else
{
}
else
{
dataSize
=
declDataSize
;
dataSize
=
declDataSize
;
ptrCount
=
declPointerCount
;
ptrCount
=
declPointerCount
;
...
@@ -1679,7 +1679,7 @@ struct WireHelpers {
...
@@ -1679,7 +1679,7 @@ struct WireHelpers {
const
word
*
src
=
reinterpret_cast
<
const
word
*>
(
value
.
ptr
);
const
word
*
src
=
reinterpret_cast
<
const
word
*>
(
value
.
ptr
);
for
(
uint
i
=
0
;
i
<
value
.
elementCount
/
ELEMENTS
;
i
++
)
{
for
(
uint
i
=
0
;
i
<
value
.
elementCount
/
ELEMENTS
;
i
++
)
{
memcpy
(
dst
,
src
,
dataSize
*
BYTES_PER_WORD
);
memcpy
(
dst
,
src
,
dataSize
*
BYTES_PER_WORD
/
BYTES
);
dst
+=
dataSize
;
dst
+=
dataSize
;
src
+=
declDataSize
;
src
+=
declDataSize
;
...
@@ -1690,7 +1690,7 @@ struct WireHelpers {
...
@@ -1690,7 +1690,7 @@ struct WireHelpers {
dst
+=
POINTER_SIZE_IN_WORDS
;
dst
+=
POINTER_SIZE_IN_WORDS
;
src
+=
POINTER_SIZE_IN_WORDS
;
src
+=
POINTER_SIZE_IN_WORDS
;
}
}
src
+=
(
declPointerCount
-
ptrCount
)
*
POINTER_SIZE_IN_
WORDS
;
src
+=
(
(
declPointerCount
-
ptrCount
)
*
WORDS_PER_POINTER
)
/
WORDS
;
}
}
return
{
segment
,
ptr
};
return
{
segment
,
ptr
};
...
@@ -2714,32 +2714,32 @@ bool StructReader::isCanonical(const word **readHead,
...
@@ -2714,32 +2714,32 @@ bool StructReader::isCanonical(const word **readHead,
return
false
;
return
false
;
}
}
if
(
this
->
getDataSectionSize
()
%
BITS_PER_WORD
!=
0
)
{
if
(
this
->
getDataSectionSize
()
%
BITS_PER_WORD
!=
0
*
BITS
)
{
// Using legacy non-word-size structs, reject
// Using legacy non-word-size structs, reject
return
false
;
return
false
;
}
}
WordCount32
dataSize
=
this
->
getDataSectionSize
()
/
BITS_PER_WORD
;
WordCount32
dataSize
=
this
->
getDataSectionSize
()
/
BITS_PER_WORD
;
// Mark whether the struct is properly truncated
// Mark whether the struct is properly truncated
if
(
dataSize
!=
0
)
{
if
(
dataSize
!=
0
*
WORDS
)
{
*
dataTrunc
=
this
->
getDataField
<
uint64_t
>
(
dataSize
-
1
)
!=
0
;
*
dataTrunc
=
this
->
getDataField
<
uint64_t
>
(
(
dataSize
-
1
*
WORDS
)
/
WORDS
*
ELEMENTS
)
!=
0
;
}
else
{
}
else
{
*
dataTrunc
=
true
;
*
dataTrunc
=
true
;
}
}
if
(
this
->
pointerCount
!=
0
)
{
if
(
this
->
pointerCount
!=
0
*
POINTERS
)
{
*
ptrTrunc
=
!
this
->
getPointerField
(
this
->
pointerCount
-
1
).
isNull
();
*
ptrTrunc
=
!
this
->
getPointerField
(
this
->
pointerCount
-
1
*
POINTERS
).
isNull
();
}
else
{
}
else
{
*
ptrTrunc
=
true
;
*
ptrTrunc
=
true
;
}
}
// Advance the read head
// Advance the read head
*
readHead
+=
dataSize
+
this
->
pointerCount
;
*
readHead
+=
(
dataSize
+
(
this
->
pointerCount
*
WORDS_PER_POINTER
))
/
WORDS
;
// Check each pointer field for canonicity
// Check each pointer field for canonicity
for
(
WirePointerCount16
ptrIndex
=
0
;
for
(
WirePointerCount16
ptrIndex
=
0
*
POINTERS
;
ptrIndex
<
this
->
pointerCount
;
ptrIndex
<
this
->
pointerCount
;
ptrIndex
++
)
{
ptrIndex
+=
POINTERS
)
{
if
(
!
this
->
getPointerField
(
ptrIndex
).
isCanonical
(
ptrHead
))
{
if
(
!
this
->
getPointerField
(
ptrIndex
).
isCanonical
(
ptrHead
))
{
return
false
;
return
false
;
}
}
...
@@ -2896,18 +2896,18 @@ bool ListReader::isCanonical(const word **readHead) {
...
@@ -2896,18 +2896,18 @@ bool ListReader::isCanonical(const word **readHead) {
// front of it, so our check is slightly different
// front of it, so our check is slightly different
return
false
;
return
false
;
}
}
if
(
this
->
structDataSize
%
BITS_PER_WORD
!=
0
)
{
if
(
this
->
structDataSize
%
BITS_PER_WORD
!=
0
*
BITS
)
{
return
false
;
return
false
;
}
}
auto
structSize
=
(
this
->
structDataSize
/
BITS_PER_WORD
)
+
auto
structSize
=
(
this
->
structDataSize
/
BITS_PER_WORD
)
+
(
this
->
structPointerCount
*
WORDS_PER_POINTER
);
(
this
->
structPointerCount
*
WORDS_PER_POINTER
);
auto
listEnd
=
*
readHead
+
this
->
elementCount
*
structSize
;
auto
listEnd
=
*
readHead
+
(
this
->
elementCount
/
ELEMENTS
*
structSize
)
/
WORDS
;
auto
pointerHead
=
listEnd
;
auto
pointerHead
=
listEnd
;
bool
listDataTrunc
=
false
;
bool
listDataTrunc
=
false
;
bool
listPtrTrunc
=
false
;
bool
listPtrTrunc
=
false
;
for
(
ElementCount
ec
=
ElementCount
(
0
);
for
(
ElementCount
ec
=
ElementCount
(
0
);
ec
<
this
->
elementCount
;
ec
<
this
->
elementCount
;
ec
++
)
{
ec
+=
1
*
ELEMENTS
)
{
bool
dataTrunc
,
ptrTrunc
;
bool
dataTrunc
,
ptrTrunc
;
if
(
!
this
->
getStructElement
(
ec
).
isCanonical
(
readHead
,
if
(
!
this
->
getStructElement
(
ec
).
isCanonical
(
readHead
,
&
pointerHead
,
&
pointerHead
,
...
@@ -2926,10 +2926,10 @@ bool ListReader::isCanonical(const word **readHead) {
...
@@ -2926,10 +2926,10 @@ bool ListReader::isCanonical(const word **readHead) {
if
(
reinterpret_cast
<
const
word
*>
(
this
->
ptr
)
!=
*
readHead
)
{
if
(
reinterpret_cast
<
const
word
*>
(
this
->
ptr
)
!=
*
readHead
)
{
return
false
;
return
false
;
}
}
*
readHead
+=
this
->
elementCount
;
*
readHead
+=
this
->
elementCount
*
(
POINTERS
/
ELEMENTS
)
*
WORDS_PER_POINTER
/
WORDS
;
for
(
ElementCount
ec
=
ElementCount
(
0
);
for
(
ElementCount
ec
=
ElementCount
(
0
);
ec
<
this
->
elementCount
;
ec
<
this
->
elementCount
;
ec
++
)
{
ec
+=
1
*
ELEMENTS
)
{
if
(
!
this
->
getPointerElement
(
ec
).
isCanonical
(
readHead
))
{
if
(
!
this
->
getPointerElement
(
ec
).
isCanonical
(
readHead
))
{
return
false
;
return
false
;
}
}
...
@@ -2944,8 +2944,8 @@ bool ListReader::isCanonical(const word **readHead) {
...
@@ -2944,8 +2944,8 @@ bool ListReader::isCanonical(const word **readHead) {
auto
bitSize
=
this
->
elementCount
*
auto
bitSize
=
this
->
elementCount
*
dataBitsPerElement
(
this
->
elementSize
);
dataBitsPerElement
(
this
->
elementSize
);
auto
wordSize
=
bitSize
/
BITS_PER_WORD
;
auto
wordSize
=
bitSize
/
BITS_PER_WORD
;
if
(
bitSize
%
BITS_PER_WORD
!=
0
)
{
if
(
bitSize
%
BITS_PER_WORD
!=
0
*
BITS
)
{
wordSize
++
;
wordSize
=
wordSize
+
1
*
WORDS
;
}
}
*
readHead
+=
wordSize
;
*
readHead
+=
wordSize
;
...
...
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