TM(3ast) TM(3ast)

# [NAME](#NAME)

tv - high resolution time support

# [SYNOPSIS](#SYNOPSIS)

#include &lt;tv.h&gt;

# [DESCRIPTION](#DESCRIPTION)

The *tv* library supports high resolution **Tv\_t** time specifications.

## [Tv\_t](#Tv_t)

contains these elements:

unsigned

\_ast\_int4\_t tv\_sec Seconds since the epoch.

unsigned

\_ast\_int4\_t tv\_nsec Nanosecond resolution.

In practice resolution is much coarser than 1 nanosecond. Systems that only support 1 second resolution always set tv\_nsec to 0.

## [int tvgettime(Tv\_t* tv)](#int_tvgettime%28Tv_t*_tv%29)

Sets tv to the current time. 0 is returned on success, -1 on error.

## [int tvsettime(const Tv\_t* tv)](#int_tvsettime%28const_Tv_t*_tv%29)

Sets the system time to tv. The caller must have sufficient privilege. 0 is returned on success, -1 on error.

## [int tvcmp(const Tv\_t* av, const Tv\_t* bv)](#int_tvcmp%28const_Tv_t*_av,_const_Tv_t*_bv%29)

Compares the times av and bv and returns -1 if av is less than bv, 0 if av is equal to bv, and 1 if av is greater than bv.

## [time\_t tvgetatime(Tv\_t* tv, const struct stat* st)](#time_t_tvgetatime%28Tv_t*_tv,_const_struct_stat*_st%29)

## [time\_t tvgetmtime(Tv\_t* tv, const struct stat* st)](#time_t_tvgetmtime%28Tv_t*_tv,_const_struct_stat*_st%29)

## [time\_t tvgetctime(Tv\_t* tv, const struct stat* st)](#time_t_tvgetctime%28Tv_t*_tv,_const_struct_stat*_st%29)

These macros set tv to the st the access, modify, or change time, respectively. The seconds portion of tv is returned.

## [time\_t tvsetatime(Tv\_t* tv, struct stat* st)](#time_t_tvsetatime%28Tv_t*_tv,_struct_stat*_st%29)

## [time\_t tvsetmtime(Tv\_t* tv, struct stat* st)](#time_t_tvsetmtime%28Tv_t*_tv,_struct_stat*_st%29)

## [time\_t tvsetctime(Tv\_t* tv, struct stat* st)](#time_t_tvsetctime%28Tv_t*_tv,_struct_stat*_st%29)

These macros set the st access, modify, or change time, respectively, to tv. The seconds portion of tv is returned.

## [int tvtouch(const char* path, const Tv\_t* av, const Tv\_t* mv, const Tv\_t* cv, int copy)](#int_tvtouch%28const_char*_path,_const_Tv_t*_av,_const_Tv_t*_mv,_const_Tv_t*_cv,_int_copy%29)

Sets the file path access time from av, modify time from mv, and change time from cv. Any of av, mv, and cv may be 0; the corresponding file time will retain the previous value if path exists and copy is 1; otherwise the corresponding file time will be set to the current time. 0 is returned on success, -1 on error.

## [int tvsleep(const Tv\_t* tv, Tv\_t* rv)](#int_tvsleep%28const_Tv_t*_tv,_Tv_t*_rv%29)

Pauses execution for tv time. 0 is returned if the full tv amount has expired. Otherwise -1 is returned and rv, if not 0, is set to the sleep time remaining.

# [RETURN VALUE](#RETURN_VALUE)

Except for tvcmp(), an error return of -1 also sets errno to the corresponding error code.

# [SEE ALSO](#SEE_ALSO)

[tm(3)](/man/os/ksh/tm.3)

---

Document: tv(3ast) from ksh 1.0.10-r36 (Chainguard OS)
Source: https://github.com/ksh93/ksh
