Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit Switch - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
86
Issues
86
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
White Rabbit Switch - Software
Commits
5935647c
Commit
5935647c
authored
May 02, 2019
by
baujc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue printing negative values for RelativeDifference type
parent
343901c6
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
2 deletions
+10
-2
time_lib.c
userspace/tools/time_lib.c
+10
-2
No files found.
userspace/tools/time_lib.c
View file @
5935647c
...
...
@@ -55,19 +55,27 @@ char * timestampToString(struct Timestamp *time,char *buf){
}
char
*
relativeDifferenceToString
(
RelativeDifference
time
,
char
*
buf
)
{
int32_t
nsecs
=
time
>>
REL_DIFF_FRACBITS
;
char
sign
;
int32_t
nsecs
;
uint64_t
sub_yocto
=
0
;
int64_t
fraction
;
uint64_t
bitWeight
=
500000000000000000
;
uint64_t
mask
;
if
(
time
<
0
)
{
time
=-
time
;
sign
=
'-'
;
}
else
{
sign
=
'+'
;
}
nsecs
=
time
>>
REL_DIFF_FRACBITS
;
fraction
=
time
&
REL_DIFF_FRACMASK
;
for
(
mask
=
(
uint64_t
)
1
<<
(
REL_DIFF_FRACBITS
-
1
);
mask
!=
0
;
mask
>>=
1
)
{
if
(
mask
&
fraction
)
sub_yocto
+=
bitWeight
;
bitWeight
/=
2
;
}
sprintf
(
buf
,
"%
"
PRId32
".%018"
PRIu64
,
nsecs
,
sub_yocto
);
sprintf
(
buf
,
"%
c%"
PRId32
".%018"
PRIu64
,
sign
,
nsecs
,
sub_yocto
);
return
buf
;
}
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