---
name: "tv"
section: "3"
platform: "macos"
package: "ksh"
version: "42"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/tv/3"
---

# tv(3)

high resolution time support

## NAME

tv - high resolution time support

## SYNOPSIS

$1$2#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>#include \<tv.h\>

## DESCRIPTION

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

### Tv\_t

contains these elements:

- $1$2unsignedunsignedunsignedunsignedunsignedunsignedunsignedunsigned

  $1$2\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t $1$2tv\_sectv\_sectv\_sectv\_sectv\_sectv\_sectv\_sectv\_sec Seconds since the epoch.

- $1$2unsignedunsignedunsignedunsignedunsignedunsignedunsignedunsigned

  $1$2\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t\_ast\_int4\_t $1$2tv\_nsectv\_nsectv\_nsectv\_nsectv\_nsectv\_nsectv\_nsectv\_nsec Nanosecond resolution.

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

### int tvgettime(Tv\_t\* tv)

Sets $1$2tvtvtvtvtvtvtvtv to the current time. $1$200000000 is returned on success, $1$2-1-1-1-1-1-1-1-1 on error.

### int tvsettime(const Tv\_t\* tv)

Sets the system time to $1$2tvtvtvtvtvtvtvtv The caller must have sufficient privilege. $1$200000000 is returned on success, $1$2-1-1-1-1-1-1-1-1 on error.

### int tvcmp(const Tv\_t\* av, const Tv\_t\* bv)

Compares the times $1$2avavavavavavavav and $1$2bvbvbvbvbvbvbvbv and returns $1$2-1-1-1-1-1-1-1-1 if $1$2avavavavavavavav is less than $1$2bvbvbvbvbvbvbvbv $1$200000000 if $1$2avavavavavavavav is equal to $1$2bvbvbvbvbvbvbvbv and $1$211111111 if $1$2avavavavavavavav is greater than $1$2bvbvbvbvbvbvbvbv

### time\_t tvgetatime(Tv\_t\* tv, const struct stat\* st)

### time\_t tvgetmtime(Tv\_t\* tv, const struct stat\* st)

### time\_t tvgetctime(Tv\_t\* tv, const struct stat\* st)

These macros set $1$2tvtvtvtvtvtvtvtv to the $1$2stststststststst the access, modify, or change time, respectively. The seconds portion of $1$2tvtvtvtvtvtvtvtv is returned.

### time\_t tvsetatime(Tv\_t\* tv, struct stat\* st)

### time\_t tvsetmtime(Tv\_t\* tv, struct stat\* st)

### time\_t tvsetctime(Tv\_t\* tv, struct stat\* st)

These macros set the $1$2stststststststst access, modify, or change time, respectively, to $1$2tvtvtvtvtvtvtvtv The seconds portion of $1$2tvtvtvtvtvtvtvtv is returned.

### int tvtouch(const char\* path, const Tv\_t\* av, const Tv\_t\* mv, const Tv\_t\* cv, int copy)

Sets the file $1$2pathpathpathpathpathpathpathpath access time from $1$2avavavavavavavav modify time from $1$2mvmvmvmvmvmvmvmv and change time from $1$2cvcvcvcvcvcvcvcv Any of $1$2avavavavavavavav $1$2mvmvmvmvmvmvmvmv and $1$2cvcvcvcvcvcvcvcv may be 0; the corresponding file time will retain the previous value if $1$2pathpathpathpathpathpathpathpath exists and $1$2copycopycopycopycopycopycopycopy is $1$211111111 otherwise the corresponding file time will be set to the current time. $1$200000000 is returned on success, $1$2-1-1-1-1-1-1-1-1 on error.

### int tvsleep(const Tv\_t\* tv, Tv\_t\* rv)

Pauses execution for $1$2tvtvtvtvtvtvtvtv time. $1$200000000 is returned if the full $1$2tvtvtvtvtvtvtvtv amount has expired. Otherwise $1$2-1-1-1-1-1-1-1-1 is returned and $1$2rvrvrvrvrvrvrvrv if not 0, is set to the sleep time remaining.

## RETURN VALUE

Except for $1$2tvcmp()tvcmp()tvcmp()tvcmp()tvcmp()tvcmp()tvcmp()tvcmp() an error return of $1$2-1-1-1-1-1-1-1-1 also sets $1$2errnoerrnoerrnoerrnoerrnoerrnoerrnoerrno to the corresponding error code.

## SEE ALSO

[tm(3)](/tm/3.md)
