• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2017 Cyril Hrubis <chrubis@suse.cz>
4  */
5 
6 #include <time.h>
7 
8 #define TST_NO_DEFAULT_MAIN
9 #include "tst_test.h"
10 #include "tst_clocks.h"
11 #include "lapi/syscalls.h"
12 #include "lapi/posix_clocks.h"
13 
tst_clock_getres(clockid_t clk_id,struct timespec * res)14 int tst_clock_getres(clockid_t clk_id, struct timespec *res)
15 {
16 	return tst_syscall(__NR_clock_getres, clk_id, res);
17 }
18 
tst_clock_gettime(clockid_t clk_id,struct timespec * ts)19 int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
20 {
21 	return tst_syscall(__NR_clock_gettime, clk_id, ts);
22 }
23 
tst_clock_settime(clockid_t clk_id,struct timespec * ts)24 int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
25 {
26 	return tst_syscall(__NR_clock_settime, clk_id, ts);
27 }
28 
tst_clock_name(clockid_t clk_id)29 const char *tst_clock_name(clockid_t clk_id)
30 {
31 	switch (clk_id) {
32 	case CLOCK_REALTIME:
33 		return "CLOCK_REALTIME";
34 	case CLOCK_MONOTONIC:
35 		return "CLOCK_MONOTONIC";
36 	case CLOCK_PROCESS_CPUTIME_ID:
37 		return "CLOCK_PROCESS_CPUTIME_ID";
38 	case CLOCK_THREAD_CPUTIME_ID:
39 		return "CLOCK_THREAD_CPUTIME_ID";
40 	case CLOCK_MONOTONIC_RAW:
41 		return "CLOCK_MONOTONIC_RAW";
42 	case CLOCK_REALTIME_COARSE:
43 		return "CLOCK_REALTIME_COARSE";
44 	case CLOCK_MONOTONIC_COARSE:
45 		return "CLOCK_MONOTONIC_COARSE";
46 	case CLOCK_BOOTTIME:
47 		return "CLOCK_BOOTTIME";
48 	case CLOCK_REALTIME_ALARM:
49 		return "CLOCK_REALTIME_ALARM";
50 	case CLOCK_BOOTTIME_ALARM:
51 		return "CLOCK_BOOTTIME_ALARM";
52 	case CLOCK_TAI:
53 		return "CLOCK_TAI";
54 	default:
55 		return "INVALID/UNKNOWN CLOCK";
56 	}
57 }
58