|
26 | 26 | static const char *version; |
27 | 27 | static const char **name; |
28 | 28 |
|
| 29 | +/* The same as struct __kernel_timespec */ |
| 30 | +struct vdso_timespec64 { |
| 31 | + uint64_t tv_sec; |
| 32 | + uint64_t tv_nsec; |
| 33 | +}; |
| 34 | + |
29 | 35 | typedef long (*vdso_gettimeofday_t)(struct timeval *tv, struct timezone *tz); |
30 | 36 | typedef long (*vdso_clock_gettime_t)(clockid_t clk_id, struct timespec *ts); |
| 37 | +typedef long (*vdso_clock_gettime64_t)(clockid_t clk_id, struct vdso_timespec64 *ts); |
31 | 38 | typedef long (*vdso_clock_getres_t)(clockid_t clk_id, struct timespec *ts); |
32 | 39 | typedef time_t (*vdso_time_t)(time_t *t); |
33 | 40 |
|
@@ -70,6 +77,33 @@ static void vdso_test_gettimeofday(void) |
70 | 77 | } |
71 | 78 | } |
72 | 79 |
|
| 80 | +static void vdso_test_clock_gettime64(clockid_t clk_id) |
| 81 | +{ |
| 82 | + /* Find clock_gettime64. */ |
| 83 | + vdso_clock_gettime64_t vdso_clock_gettime64 = |
| 84 | + (vdso_clock_gettime64_t)vdso_sym(version, name[5]); |
| 85 | + |
| 86 | + if (!vdso_clock_gettime64) { |
| 87 | + ksft_print_msg("Couldn't find %s\n", name[5]); |
| 88 | + ksft_test_result_skip("%s %s\n", name[5], |
| 89 | + vdso_clock_name[clk_id]); |
| 90 | + return; |
| 91 | + } |
| 92 | + |
| 93 | + struct vdso_timespec64 ts; |
| 94 | + long ret = VDSO_CALL(vdso_clock_gettime64, 2, clk_id, &ts); |
| 95 | + |
| 96 | + if (ret == 0) { |
| 97 | + ksft_print_msg("The time is %lld.%06lld\n", |
| 98 | + (long long)ts.tv_sec, (long long)ts.tv_nsec); |
| 99 | + ksft_test_result_pass("%s %s\n", name[5], |
| 100 | + vdso_clock_name[clk_id]); |
| 101 | + } else { |
| 102 | + ksft_test_result_fail("%s %s\n", name[5], |
| 103 | + vdso_clock_name[clk_id]); |
| 104 | + } |
| 105 | +} |
| 106 | + |
73 | 107 | static void vdso_test_clock_gettime(clockid_t clk_id) |
74 | 108 | { |
75 | 109 | /* Find clock_gettime. */ |
@@ -171,11 +205,12 @@ static inline void vdso_test_clock(clockid_t clock_id) |
171 | 205 | ksft_print_msg("clock_id: %s\n", vdso_clock_name[clock_id]); |
172 | 206 |
|
173 | 207 | vdso_test_clock_gettime(clock_id); |
| 208 | + vdso_test_clock_gettime64(clock_id); |
174 | 209 |
|
175 | 210 | vdso_test_clock_getres(clock_id); |
176 | 211 | } |
177 | 212 |
|
178 | | -#define VDSO_TEST_PLAN 20 |
| 213 | +#define VDSO_TEST_PLAN 29 |
179 | 214 |
|
180 | 215 | int main(int argc, char **argv) |
181 | 216 | { |
|
0 commit comments