Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
folly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
folly
Commits
9284f39b
Commit
9284f39b
authored
Dec 13, 2012
by
Tudor Bosman
Committed by
Jordan DeLong
Dec 16, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Silence -Wuninitialized in some cases
Test Plan: compiles Reviewed By: philipp@fb.com FB internal diff: D657623
parent
af8b3ec1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
folly/Bits.h
folly/Bits.h
+1
-1
folly/experimental/Bits.h
folly/experimental/Bits.h
+18
-3
No files found.
folly/Bits.h
View file @
9284f39b
...
...
@@ -498,7 +498,7 @@ template <class T>
struct
Unaligned
<
T
,
typename
std
::
enable_if
<
std
::
is_pod
<
T
>::
value
>::
type
>
{
Unaligned
()
{
}
// uninitialized
Unaligned
()
=
default
;
// uninitialized
/* implicit */
Unaligned
(
T
v
)
:
value
(
v
)
{
}
T
value
;
}
__attribute__
((
packed
));
...
...
folly/experimental/Bits.h
View file @
9284f39b
...
...
@@ -40,12 +40,21 @@ namespace detail {
template
<
class
T
,
class
Enable
=
void
>
struct
BitsTraits
;
// Partial specialization for Unaligned<T>, where T is unsigned integral
// loadRMW is the same as load, but it indicates that it loads for a
// read-modify-write operation (we write back the bits we won't change);
// silence the GCC warning in that case.
template
<
class
T
>
struct
BitsTraits
<
Unaligned
<
T
>
,
typename
std
::
enable_if
<
(
std
::
is_integral
<
T
>::
value
&&
std
::
is_unsigned
<
T
>::
value
)
>::
type
>
{
typedef
T
UnderlyingType
;
static
T
load
(
const
Unaligned
<
T
>&
x
)
{
return
x
.
value
;
}
static
void
store
(
Unaligned
<
T
>&
x
,
T
v
)
{
x
.
value
=
v
;
}
static
T
loadRMW
(
const
Unaligned
<
T
>&
x
)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
return
x
.
value
;
#pragma GCC diagnostic pop
}
};
// Partial specialization for T, where T is unsigned integral
...
...
@@ -55,6 +64,12 @@ struct BitsTraits<T, typename std::enable_if<
typedef
T
UnderlyingType
;
static
T
load
(
const
T
&
x
)
{
return
x
;
}
static
void
store
(
T
&
x
,
T
v
)
{
x
=
v
;
}
static
T
loadRMW
(
const
T
&
x
)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
return
x
;
#pragma GCC diagnostic pop
}
};
}
// namespace detail
...
...
@@ -147,13 +162,13 @@ struct Bits {
template
<
class
T
,
class
Traits
>
inline
void
Bits
<
T
,
Traits
>::
set
(
T
*
p
,
size_t
bit
)
{
T
&
block
=
p
[
blockIndex
(
bit
)];
Traits
::
store
(
block
,
Traits
::
load
(
block
)
|
(
one
<<
bitOffset
(
bit
)));
Traits
::
store
(
block
,
Traits
::
load
RMW
(
block
)
|
(
one
<<
bitOffset
(
bit
)));
}
template
<
class
T
,
class
Traits
>
inline
void
Bits
<
T
,
Traits
>::
clear
(
T
*
p
,
size_t
bit
)
{
T
&
block
=
p
[
blockIndex
(
bit
)];
Traits
::
store
(
block
,
Traits
::
load
(
block
)
&
~
(
one
<<
bitOffset
(
bit
)));
Traits
::
store
(
block
,
Traits
::
load
RMW
(
block
)
&
~
(
one
<<
bitOffset
(
bit
)));
}
template
<
class
T
,
class
Traits
>
...
...
@@ -201,7 +216,7 @@ template <class T, class Traits>
inline
void
Bits
<
T
,
Traits
>::
innerSet
(
T
*
p
,
size_t
offset
,
size_t
count
,
UnderlyingType
value
)
{
// Mask out bits and set new value
UnderlyingType
v
=
Traits
::
load
(
*
p
);
UnderlyingType
v
=
Traits
::
load
RMW
(
*
p
);
v
&=
~
(((
one
<<
count
)
-
1
)
<<
offset
);
v
|=
(
value
<<
offset
);
Traits
::
store
(
*
p
,
v
);
...
...
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