Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
064fffbc
Commit
064fffbc
authored
Dec 09, 2015
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mtime: use timespec_get() in NTPtime64()
parent
a392c101
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
20 deletions
+4
-20
src/misc/mtime.c
src/misc/mtime.c
+4
-20
No files found.
src/misc/mtime.c
View file @
064fffbc
...
...
@@ -230,35 +230,19 @@ mtime_t date_Decrement( date_t *p_date, uint32_t i_nb_samples )
/**
* @return NTP 64-bits timestamp in host byte order.
*/
uint64_t
NTPtime64
(
void
)
uint64_t
NTPtime64
(
void
)
{
#if (_POSIX_TIMERS > 0)
struct
timespec
ts
;
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
#else
struct
timeval
tv
;
struct
{
uint32_t
tv_sec
;
uint32_t
tv_nsec
;
}
ts
;
gettimeofday
(
&
tv
,
NULL
);
ts
.
tv_sec
=
tv
.
tv_sec
;
ts
.
tv_nsec
=
tv
.
tv_usec
*
1000
;
#endif
timespec_get
(
&
ts
,
TIME_UTC
);
/* Convert nanoseconds to 32-bits fraction (232 picosecond units) */
uint64_t
t
=
(
uint64_t
)(
ts
.
tv_nsec
)
<<
32
;
t
/=
1000000000
;
/* There is 70 years (incl. 17 leap ones) offset to the Unix Epoch.
* No leap seconds during that period since they were not invented yet.
/* The offset to Unix epoch is 70 years (incl. 17 leap ones). There were
* no leap seconds during that period since they had not been invented yet.
*/
assert
(
t
<
0x100000000
);
t
|=
((
UINT64_C
(
70
)
*
365
+
17
)
*
24
*
60
*
60
+
ts
.
tv_sec
)
<<
32
;
return
t
;
}
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