History

timer: remove unused code

Kacper Michajłow committed 3 years ago

Commit 71e888c1 parent 751790c3 files · +0 −53Browse files

Unified · Split

3 files
  1. osdep/timer.c +0 −30
  2. osdep/timer.h +0 −7
  3. test/timer.c +0 −16
osdep/timer.c+0−30
@@ -16,7 +16,6 @@ · 15 unmodified lines
1616 */
1717
1818 #include <stdlib.h>
19−#include <pthread.h>
2019 #include <time.h>
2120 #include <unistd.h>
2221 #include <sys/time.h>
@@ -66,32 +65,3 @@ int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec) · 43 unmodified lines
6665 return 1;
6766 return time_ns + ti;
6867 }
69−
70−#if !HAVE_WIN32_THREADS
71−
72−struct timespec mp_time_ns_to_realtime(int64_t time_ns)
73−{
74− struct timespec ts = {0};
75− if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
76− return ts;
77− int64_t time_rel = time_ns - mp_time_ns();
78−
79− // clamp to 1000 days in the future
80− time_rel = MPMIN(time_rel, 1000 * 24 * 60 * 60 * INT64_C(1000000000));
81− ts.tv_sec += time_rel / INT64_C(1000000000);
82− ts.tv_nsec += time_rel % INT64_C(1000000000);
83−
84− if (ts.tv_nsec >= INT64_C(1000000000)) {
85− ts.tv_sec++;
86− ts.tv_nsec -= INT64_C(1000000000);
87− }
88−
89− return ts;
90−}
91−
92−struct timespec mp_rel_time_to_timespec(double timeout_sec)
93−{
94− return mp_time_ns_to_realtime(mp_time_ns_add(mp_time_ns(), timeout_sec));
95−}
96−
97−#endif
osdep/timer.h+0−7
@@ -60,11 +60,4 @@ void mp_end_hires_timers(int resolution_ms); · 59 unmodified lines
6060 // Takes care of possible overflows. Never returns a negative or 0 time.
6161 int64_t mp_time_ns_add(int64_t time_ns, double timeout_sec);
6262
63−// Convert the mp time in nanoseconds to a timespec using CLOCK_REALTIME.
64−struct timespec mp_time_ns_to_realtime(int64_t time_ns);
65−
66−// Convert the relative timeout in seconds to a timespec.
67−// The timespec is absolute, using CLOCK_REALTIME.
68−struct timespec mp_rel_time_to_timespec(double timeout_sec);
69−
7063 #endif /* MPLAYER_TIMER_H */
test/timer.c+0−16
@@ -1,7 +1,6 @@
11 #include "common/common.h"
22 #include "osdep/timer.h"
33 #include "test_utils.h"
4−#include "config.h"
54
65 #include <time.h>
76 #include <sys/time.h>
@@ -38,20 +37,5 @@ int main(void) · 30 unmodified lines
3837 assert_int_equal(mp_time_ns_add(test2, 20.44), INT64_MAX);
3938 }
4039
41−#if !HAVE_WIN32_THREADS
42− /* conversion */
43− {
44− struct timeval tv;
45− struct timespec ts;
46− gettimeofday(&tv, NULL);
47− ts = mp_time_ns_to_realtime(mp_time_ns());
48− assert_true(llabs(tv.tv_sec - ts.tv_sec) <= 1);
49−
50− gettimeofday(&tv, NULL);
51− ts = mp_rel_time_to_timespec(0.0);
52− assert_true(llabs(tv.tv_sec - ts.tv_sec) <= 1);
53− }
54−#endif
55−
5640 return 0;
5741 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t