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
11bd0278
Commit
11bd0278
authored
Aug 29, 2017
by
Sven Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unix_time: adjtimex store flags
parent
319c9147
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
31 deletions
+30
-31
unix-time.c
time-unix/unix-time.c
+30
-31
No files found.
time-unix/unix-time.c
View file @
11bd0278
...
...
@@ -61,10 +61,10 @@ static int unix_time_get_utc_offset(struct pp_instance *ppi, int *offset, int *l
memset
(
&
t
,
0
,
sizeof
(
t
));
ret
=
adjtimex
(
&
t
);
if
(
ret
>=
0
)
{
if
(
ret
==
TIME
_INS
)
{
if
(
t
.
status
==
STA
_INS
)
{
*
leap59
=
0
;
*
leap61
=
1
;
}
else
if
(
ret
==
TIME
_DEL
)
{
}
else
if
(
t
.
status
==
STA
_DEL
)
{
*
leap59
=
1
;
*
leap61
=
0
;
}
else
{
...
...
@@ -90,38 +90,31 @@ static int unix_time_set_utc_offset(struct pp_instance *ppi, int offset, int lea
{
struct
timex
t
;
if
(
leap59
)
{
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
modes
=
MOD_STATUS
;
t
.
status
=
STA_DEL
;
if
(
adjtimex
(
&
t
)
<
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"set leap second failed"
);
return
-
1
;
}
}
else
if
(
leap61
)
{
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
modes
=
MOD_STATUS
;
t
.
status
=
STA_INS
;
if
(
adjtimex
(
&
t
)
<
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"set leap second failed"
);
return
-
1
;
}
}
else
{
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
modes
=
MOD_STATUS
;
t
.
status
=
0
;
if
(
adjtimex
(
&
t
)
<
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"clear leap second failed"
);
return
-
1
;
/* get the current flags first */
memset
(
&
t
,
0
,
sizeof
(
t
));
ret
=
adjtimex
(
&
t
);
if
(
ret
>=
0
)
{
if
(
leap59
)
{
t
.
modes
=
MOD_STATUS
;
t
.
status
|=
STA_DEL
;
t
.
status
&=
~
STA_INS
;
}
else
if
(
leap61
)
{
t
.
modes
=
MOD_STATUS
;
t
.
status
|=
STA_INS
;
t
.
status
&=
~
STA_DEL
;
}
else
{
t
.
modes
=
MOD_STATUS
;
t
.
status
&=
~
STA_INS
;
t
.
status
&=
~
STA_DEL
;
}
}
else
pp_diag
(
ppi
,
time
,
1
,
"get UTC offset and flags failed"
);
memset
(
&
t
,
0
,
sizeof
(
t
));
t
.
modes
=
MOD_TAI
;
t
.
modes
|=
MOD_TAI
;
t
.
constant
=
offset
;
if
(
adjtimex
(
&
t
)
<
0
)
{
pp_diag
(
ppi
,
time
,
1
,
"set UTC offset failed"
);
pp_diag
(
ppi
,
time
,
1
,
"set UTC offset
and flags
failed"
);
return
-
1
;
}
...
...
@@ -177,10 +170,15 @@ static int unix_time_set(struct pp_instance *ppi, const struct pp_time *t)
static
int
unix_time_init_servo
(
struct
pp_instance
*
ppi
)
{
struct
timex
t
;
int
ret
;
/* get the current flags first */
memset
(
&
t
,
0
,
sizeof
(
t
));
ret
=
adjtimex
(
&
t
);
/* We must set MOD_PLL and recover the current frequency value */
t
.
modes
=
MOD_STATUS
;
t
.
status
=
STA_PLL
;
t
.
status
|
=
STA_PLL
;
if
(
adjtimex
(
&
t
)
<
0
)
return
-
1
;
return
(
t
.
freq
>>
16
)
*
1000
;
/* positive or negative, not -1 */
...
...
@@ -247,3 +245,4 @@ struct pp_time_operations unix_time_ops = {
.
init_servo
=
unix_time_init_servo
,
.
calc_timeout
=
unix_calc_timeout
,
};
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