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
a3a3661f
Commit
a3a3661f
authored
May 25, 2006
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix overflows
parent
bf85a920
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
23 deletions
+8
-23
src/misc/mtime.c
src/misc/mtime.c
+8
-23
No files found.
src/misc/mtime.c
View file @
a3a3661f
...
...
@@ -28,7 +28,7 @@
*****************************************************************************/
#include <stdio.h>
/* sprintf() */
#include <time.h>
/* clock_gettime(), clock_nanosleep() */
#include <stdlib.h>
/*
ldiv() */
#include <stdlib.h>
/* l
ldiv() */
#include <vlc/vlc.h>
...
...
@@ -197,8 +197,8 @@ mtime_t mdate( void )
/* Run-time fallback to real-time clock (always available) */
(
void
)
clock_gettime
(
CLOCK_REALTIME
,
&
ts
);
fprintf
(
stderr
,
"%ld
\n
"
,
(
mtime_t
)((
ts
.
tv_sec
*
1000000
)
+
(
ts
.
tv_nsec
/
1000
)));
return
(
ts
.
tv_sec
*
1000000
)
+
(
ts
.
tv_nsec
/
1000
);
return
((
mtime_t
)
ts
.
tv_sec
*
(
mtime_t
)
1000000
)
+
(
mtime_t
)
(
ts
.
tv_nsec
/
1000
);
#else
struct
timeval
tv_date
;
...
...
@@ -240,28 +240,13 @@ void mwait( mtime_t date )
msleep
(
delay
);
#elif defined (HAVE_CLOCK_GETTIME)
struct
timespec
ts
;
ldiv_t
d
;
# if 1
/*
* Ideally, we'd use absolute time (TIMER_ABSTIME), instead of
* computing the time difference... but VLC mtime_t type seems to
* overflow way too quickly for this to work properly, or maybe it's a
* signedness problem (??).
*/
date
-=
mdate
();
if
(
date
<=
0
)
return
;
# endif
d
=
ldiv
(
date
,
1000000
);
ts
.
tv_sec
=
d
.
quot
;
ts
.
tv_nsec
=
d
.
rem
*
1000
;
lldiv_t
d
=
lldiv
(
date
,
1000000
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
};
# if (_POSIX_MONOTONIC_CLOCK - 0 >= 0)
if
(
clock_nanosleep
(
CLOCK_MONOTONIC
,
0
,
&
ts
,
NULL
)
)
if
(
clock_nanosleep
(
CLOCK_MONOTONIC
,
TIMER_ABSTIME
,
&
ts
,
NULL
)
)
# endif
clock_nanosleep
(
CLOCK_REALTIME
,
0
,
&
ts
,
NULL
);
clock_nanosleep
(
CLOCK_REALTIME
,
TIMER_ABSTIME
,
&
ts
,
NULL
);
#else
struct
timeval
tv_date
;
...
...
@@ -332,7 +317,7 @@ void msleep( mtime_t delay )
Sleep
(
(
int
)
(
delay
/
1000
)
);
#elif defined( HAVE_CLOCK_GETTIME )
l
div_t
d
=
ldiv
(
delay
,
1000000
);
l
ldiv_t
d
=
l
ldiv
(
delay
,
1000000
);
struct
timespec
ts
=
{
d
.
quot
,
d
.
rem
*
1000
};
# if (_POSIX_CLOCK_MONOTONIC - 0 >= 0)
if
(
clock_nanosleep
(
CLOCK_MONOTONIC
,
0
,
&
ts
,
NULL
)
)
...
...
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