File: timespec_get.3

package info (click to toggle)
manpages 6.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,184 kB
  • sloc: sh: 575; python: 222; perl: 190; makefile: 29; lisp: 22
file content (99 lines) | stat: -rw-r--r-- 2,057 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
'\" t
.\" SPDX-License-Identifier: 0BSD
.\"
.TH timespec_get 3 2025-02-10 "Linux man-pages (unreleased)"
.SH NAME
timespec_get,
timespec_getres
\-
ISO C interface to clock and time functions
.SH LIBRARY
Standard C library
.RI ( libc ,\~ \-lc ),
.SH SYNOPSIS
.nf
.B #include <time.h>
.P
.BI "int timespec_get(struct timespec *" res ", int " base );
.BI "int timespec_getres(struct timespec *" tp ", int " base );
.fi
.SH DESCRIPTION
The
.BR timespec_get ()
function stores the current time, based on the specified time base, in the
.BR timespec (3type)
structure pointed to by
.IR res .
.P
The
.BR timespec_getres ()
function stores the resolution of times retrieved by
.BR timespec_get ()
with the specified time base in the
.BR timespec (3type)
structure pointed to by
.IR tp ,
if
.I tp
is non-NULL.
For a particular time base,
the resolution is constant for the lifetime of the calling process.
.P
.B TIME_UTC
is always a supported time base,
and is the only time base supported on Linux.
The time and resolution in this time base
are the same as those retrieved by
.I clock_gettime(CLOCK_REALTIME,\~res)
and
.IR clock_getres(CLOCK_REALTIME,\~tp) ,
respectively.
Other systems may support additional time bases.
.SH RETURN VALUE
.BR timespec_get ()
returns the nonzero
.I base
if it is a supported time base
and the current time was successfully retrieved, or 0 otherwise.
.P
.BR timespec_getres ()
returns the nonzero
.I base
if it is a supported time base, or 0 otherwise.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
.TS
allbox;
lbx lb lb
l l l.
Interface	Attribute	Value
T{
.na
.nh
.BR timespec_get (),
.BR timespec_getres ()
T}	Thread safety	MT-Safe
.TE
.SH STANDARDS
.TP
.BR timespec_get ()
.TQ
.B TIME_UTC
C23 (though ISO C doesn't specify the time epoch),
POSIX.1-2024.
.TP
.BR timespec_getres ()
C23.
.SH HISTORY
.TP
.BR timespec_get ()
.TQ
.B TIME_UTC
C11, POSIX.1-2024, glibc 2.16, musl 1.1.10.
.TP
.BR timespec_getres ()
C23, glibc 2.34.
.SH SEE ALSO
.BR clock_gettime (2),
.BR clock_getres (2)