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
47
Issues
47
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
52fda5e9
Commit
52fda5e9
authored
Dec 05, 2014
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrs: consider TAI offset when setting system time
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
19006629
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
wrs-time.c
time-wrs/wrs-time.c
+18
-1
No files found.
time-wrs/wrs-time.c
View file @
52fda5e9
...
...
@@ -11,6 +11,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/timex.h>
#include <ppsi/ppsi.h>
#include <ppsi-wrs.h>
...
...
@@ -186,6 +187,9 @@ static int wrs_time_get(struct pp_instance *ppi, TimeInternal *t)
static
int
wrs_time_set
(
struct
pp_instance
*
ppi
,
TimeInternal
*
t
)
{
TimeInternal
diff
;
struct
timex
tx
;
int
tai_offset
=
0
;
/*
* This is almost unused in ppsi, only proto-standard/servo.c
* calls it, at initialization time, when the offset is bigger
...
...
@@ -216,7 +220,20 @@ static int wrs_time_set(struct pp_instance *ppi, TimeInternal *t)
}
wrs_adjust_counters
(
diff
.
seconds
,
diff
.
nanoseconds
);
/* Finally, set unix time too */
/*
* Finally, set unix time too, but count the UTC/TAI difference
* assuming somebody has set up up for us
*/
memset
(
&
tx
,
0
,
sizeof
(
tx
));
if
(
adjtimex
(
&
tx
)
>=
0
)
{
/*
* Our WRS kernel has tai support, but our compiler does not.
* We are 32-bit only, and we know for sure that tai is
* exactly after stbcnt. It's a bad hack, but it works
*/
tai_offset
=
*
((
int
*
)(
&
tx
.
stbcnt
)
+
1
);
}
t
->
seconds
-=
tai_offset
;
unix_time_ops
.
set
(
ppi
,
t
);
return
0
;
}
...
...
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