Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
PPSi
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
PPSi
Commits
34ca7d7b
Commit
34ca7d7b
authored
Oct 24, 2016
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
time: proto-standard/arith.c: make it shorter by 192 bytes
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
17df60f4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
31 deletions
+13
-31
arith.c
proto-standard/arith.c
+13
-31
No files found.
proto-standard/arith.c
View file @
34ca7d7b
...
@@ -14,20 +14,13 @@ static void normalize_pp_time(struct pp_time *t)
...
@@ -14,20 +14,13 @@ static void normalize_pp_time(struct pp_time *t)
/* no 64b division please, we'll rather loop a few times */
/* no 64b division please, we'll rather loop a few times */
#define SNS_PER_S ((1000LL * 1000 * 1000) << 16)
#define SNS_PER_S ((1000LL * 1000 * 1000) << 16)
/* 0 is special: it can have both negative and positive fractions */
int
sign
=
(
t
->
secs
<
0
||
(
t
->
secs
==
0
&&
t
->
scaled_nsecs
<
0
))
if
(
t
->
secs
==
0LL
)
{
?
-
1
:
1
;
while
(
t
->
scaled_nsecs
>
SNS_PER_S
)
{
t
->
secs
++
;
/* turn into positive, to make code shorter (don't replicate loops) */
t
->
scaled_nsecs
-=
SNS_PER_S
;
t
->
secs
*=
sign
;
}
t
->
scaled_nsecs
*=
sign
;
while
(
t
->
scaled_nsecs
<
-
SNS_PER_S
)
{
t
->
secs
--
;
t
->
scaled_nsecs
+=
SNS_PER_S
;
}
return
;
}
if
(
t
->
secs
>
0LL
)
{
while
(
t
->
scaled_nsecs
<
0
)
{
while
(
t
->
scaled_nsecs
<
0
)
{
t
->
secs
--
;
t
->
secs
--
;
t
->
scaled_nsecs
+=
SNS_PER_S
;
t
->
scaled_nsecs
+=
SNS_PER_S
;
...
@@ -36,19 +29,8 @@ static void normalize_pp_time(struct pp_time *t)
...
@@ -36,19 +29,8 @@ static void normalize_pp_time(struct pp_time *t)
t
->
secs
++
;
t
->
secs
++
;
t
->
scaled_nsecs
-=
SNS_PER_S
;
t
->
scaled_nsecs
-=
SNS_PER_S
;
}
}
return
;
t
->
secs
*=
sign
;
}
t
->
scaled_nsecs
*=
sign
;
/* A negative pp_time has both secs and scaled_nsecs <= 0 */
while
(
t
->
scaled_nsecs
<
-
SNS_PER_S
)
{
t
->
secs
--
;
t
->
scaled_nsecs
+=
SNS_PER_S
;
}
while
(
t
->
scaled_nsecs
>
0
)
{
t
->
secs
++
;
t
->
scaled_nsecs
-=
SNS_PER_S
;
}
}
}
void
pp_time_add
(
struct
pp_time
*
t1
,
struct
pp_time
*
t2
)
void
pp_time_add
(
struct
pp_time
*
t1
,
struct
pp_time
*
t2
)
...
...
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