Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
multipass
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
derf
multipass
Commits
9df610bb
Commit
9df610bb
authored
6 years ago
by
Birte Kristina Friesel
Browse files
Options
Downloads
Patches
Plain Diff
XDR: Use unions instead of casts for float/double<->int conversion
parent
bb1c3523
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/os/object/xdrinput.cc
+12
-4
12 additions, 4 deletions
src/os/object/xdrinput.cc
src/os/object/xdrstream.cc
+12
-2
12 additions, 2 deletions
src/os/object/xdrstream.cc
with
24 additions
and
6 deletions
src/os/object/xdrinput.cc
+
12
−
4
View file @
9df610bb
...
...
@@ -37,14 +37,22 @@ int64_t XDRInput::get_int64()
float
XDRInput
::
get_float
()
{
uint32_t
val
=
get_uint32
();
return
*
(
float
*
)
&
val
;
union
{
uint32_t
i
;
float
f
;
}
v
;
v
.
i
=
get_uint32
();
return
v
.
f
;
}
double
XDRInput
::
get_double
()
{
uint64_t
val
=
get_uint64
();
return
*
(
double
*
)
&
val
;
union
{
uint64_t
i
;
double
d
;
}
v
;
v
.
i
=
get_uint64
();
return
v
.
d
;
}
uint32_t
XDRInput
::
get_opaque_length
()
...
...
This diff is collapsed.
Click to expand it.
src/os/object/xdrstream.cc
+
12
−
2
View file @
9df610bb
...
...
@@ -70,13 +70,23 @@ XDRStream & XDRStream::operator<<(int64_t number)
XDRStream
&
XDRStream
::
operator
<<
(
float
number
)
{
*
this
<<
*
(
uint32_t
*
)
&
number
;
union
{
uint32_t
i
;
float
f
;
}
v
;
v
.
f
=
number
;
*
this
<<
v
.
i
;
return
*
this
;
}
XDRStream
&
XDRStream
::
operator
<<
(
double
number
)
{
*
this
<<
*
(
uint64_t
*
)
&
number
;
union
{
uint64_t
i
;
double
d
;
}
v
;
v
.
d
=
number
;
*
this
<<
v
.
i
;
return
*
this
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment