1*49cdfc7eSAndroid Build Coastguard Worker /* SPDX-License-Identifier: GPL-2.0-or-later 2*49cdfc7eSAndroid Build Coastguard Worker * Copyright (c) 2017 Cyril Hrubis <[email protected]> 3*49cdfc7eSAndroid Build Coastguard Worker */ 4*49cdfc7eSAndroid Build Coastguard Worker 5*49cdfc7eSAndroid Build Coastguard Worker /* 6*49cdfc7eSAndroid Build Coastguard Worker * clock_gettime() and clock_getres() functions 7*49cdfc7eSAndroid Build Coastguard Worker */ 8*49cdfc7eSAndroid Build Coastguard Worker 9*49cdfc7eSAndroid Build Coastguard Worker #ifndef TST_CLOCKS__ 10*49cdfc7eSAndroid Build Coastguard Worker #define TST_CLOCKS__ 11*49cdfc7eSAndroid Build Coastguard Worker 12*49cdfc7eSAndroid Build Coastguard Worker int tst_clock_getres(clockid_t clk_id, struct timespec *res); 13*49cdfc7eSAndroid Build Coastguard Worker 14*49cdfc7eSAndroid Build Coastguard Worker int tst_clock_gettime(clockid_t clk_id, struct timespec *ts); 15*49cdfc7eSAndroid Build Coastguard Worker 16*49cdfc7eSAndroid Build Coastguard Worker int tst_clock_settime(clockid_t clk_id, struct timespec *ts); 17*49cdfc7eSAndroid Build Coastguard Worker 18*49cdfc7eSAndroid Build Coastguard Worker /* 19*49cdfc7eSAndroid Build Coastguard Worker * Converts clock id to a readable name. 20*49cdfc7eSAndroid Build Coastguard Worker */ 21*49cdfc7eSAndroid Build Coastguard Worker const char *tst_clock_name(clockid_t clk_id); 22*49cdfc7eSAndroid Build Coastguard Worker 23*49cdfc7eSAndroid Build Coastguard Worker /* 24*49cdfc7eSAndroid Build Coastguard Worker * Returns current system time for file/IPC operations, which may slightly lag 25*49cdfc7eSAndroid Build Coastguard Worker * behind time() return values. 26*49cdfc7eSAndroid Build Coastguard Worker * 27*49cdfc7eSAndroid Build Coastguard Worker * The reason for this is that the time() syscall reads the nanosecond timer at 28*49cdfc7eSAndroid Build Coastguard Worker * the time of the call and adds it to the kernel current time, because of that 29*49cdfc7eSAndroid Build Coastguard Worker * accumulation may cause it jump one second ahead compared to the kernel time 30*49cdfc7eSAndroid Build Coastguard Worker * stamp that is used for IPC and filesystems. 31*49cdfc7eSAndroid Build Coastguard Worker */ 32*49cdfc7eSAndroid Build Coastguard Worker time_t tst_get_fs_timestamp(void); 33*49cdfc7eSAndroid Build Coastguard Worker 34*49cdfc7eSAndroid Build Coastguard Worker #endif /* TST_CLOCKS__ */ 35