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
9e155ca1
Commit
9e155ca1
authored
Feb 27, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wr-servo.c: simplified some conversions
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
8b1eac65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
35 deletions
+20
-35
wr-servo.c
proto-ext-whiterabbit/wr-servo.c
+20
-35
No files found.
proto-ext-whiterabbit/wr-servo.c
View file @
9e155ca1
...
...
@@ -43,24 +43,22 @@ static void dump_timestamp(char *what, TimeInternal ts)
static
int64_t
ts_to_picos
(
TimeInternal
ts
)
{
return
(
int64_t
)
ts
.
seconds
*
(
int64_t
)
1000000000000LL
+
(
int64_t
)
ts
.
nanoseconds
*
(
int64_t
)
1000LL
+
(
int64_t
)
ts
.
phase
;
return
ts
.
seconds
*
1000000000000LL
+
ts
.
nanoseconds
*
1000LL
+
ts
.
phase
;
}
static
TimeInternal
picos_to_ts
(
int64_t
picos
)
{
int64_t
phase
=
picos
%
1000LL
;
picos
=
(
picos
-
phase
)
/
1000LL
;
int64_t
nsec
=
picos
%
1000000000LL
;
picos
=
(
picos
-
nsec
)
/
1000000000LL
;
int64_t
nsec
,
phase
;
TimeInternal
ts
;
ts
.
seconds
=
(
int64_t
)
picos
;
ts
.
nanoseconds
=
(
int32_t
)
nsec
;
ts
.
phase
=
(
int32_t
)
phase
;
phase
=
picos
%
1000
;
nsec
=
picos
/
1000
;
ts
.
seconds
=
nsec
/
PP_NSEC_PER_SEC
;
ts
.
nanoseconds
=
nsec
%
PP_NSEC_PER_SEC
;
ts
.
phase
=
phase
;
return
ts
;
}
...
...
@@ -68,25 +66,18 @@ static TimeInternal ts_add(TimeInternal a, TimeInternal b)
{
TimeInternal
c
;
c
.
seconds
=
0
;
c
.
nanoseconds
=
0
;
c
.
phase
=
a
.
phase
+
b
.
phase
;
c
.
nanoseconds
=
a
.
nanoseconds
+
b
.
nanoseconds
;
c
.
seconds
=
a
.
seconds
+
b
.
seconds
;
while
(
c
.
phase
>=
1000
)
{
while
(
c
.
phase
>=
1000
)
{
c
.
phase
-=
1000
;
c
.
nanoseconds
++
;
}
c
.
nanoseconds
+=
(
a
.
nanoseconds
+
b
.
nanoseconds
);
while
(
c
.
nanoseconds
>=
1000000000L
)
{
c
.
nanoseconds
-=
1000000000L
;
while
(
c
.
nanoseconds
>=
PP_NSEC_PER_SEC
)
{
c
.
nanoseconds
-=
PP_NSEC_PER_SEC
;
c
.
seconds
++
;
}
c
.
seconds
+=
(
a
.
seconds
+
b
.
seconds
);
return
c
;
}
...
...
@@ -94,24 +85,18 @@ static TimeInternal ts_sub(TimeInternal a, TimeInternal b)
{
TimeInternal
c
;
c
.
seconds
=
0
;
c
.
nanoseconds
=
0
;
c
.
phase
=
a
.
phase
-
b
.
phase
;
c
.
nanoseconds
=
a
.
nanoseconds
-
b
.
nanoseconds
;
c
.
seconds
=
a
.
seconds
-
b
.
seconds
;
while
(
c
.
phase
<
0
)
{
c
.
phase
+=
1000
;
c
.
nanoseconds
--
;
}
c
.
nanoseconds
+=
a
.
nanoseconds
-
b
.
nanoseconds
;
while
(
c
.
nanoseconds
<
0
)
{
c
.
nanoseconds
+=
1000000000L
;
c
.
nanoseconds
+=
PP_NSEC_PER_SEC
;
c
.
seconds
--
;
}
c
.
seconds
+=
a
.
seconds
-
b
.
seconds
;
return
c
;
}
...
...
@@ -133,13 +118,13 @@ static TimeInternal ts_hardwarize(TimeInternal ts, int clock_period_ps)
}
if
(
ts
.
nanoseconds
<
0
)
{
ts
.
nanoseconds
+=
1000000000LL
;
ts
.
nanoseconds
+=
PP_NSEC_PER_SEC
;
ts
.
seconds
--
;
}
if
(
ts
.
seconds
==
-
1
&&
ts
.
nanoseconds
>
0
)
{
ts
.
seconds
++
;
ts
.
nanoseconds
-=
1000000000LL
;
ts
.
nanoseconds
-=
PP_NSEC_PER_SEC
;
}
if
(
ts
.
nanoseconds
<
0
&&
ts
.
nanoseconds
>=
(
-
q_threshold
)
...
...
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