xref: /freebsd/lib/libc/gen/timespec_get.3 (revision 9b5d724cad10087e34165199e55f15f2df744ed5)
17e299411SWarner Losh.\"	$NetBSD: timespec_get.3,v 1.2 2016/10/04 10:46:40 wiz Exp $
27e299411SWarner Losh.\"
37e299411SWarner Losh.\" Copyright (c) 2016 The NetBSD Foundation, Inc.
47e299411SWarner Losh.\" All rights reserved.
57e299411SWarner Losh.\"
67e299411SWarner Losh.\" This code is derived from software contributed to The NetBSD Foundation
77e299411SWarner Losh.\" by Kamil Rytarowski.
87e299411SWarner Losh.\"
97e299411SWarner Losh.\" Redistribution and use in source and binary forms, with or without
107e299411SWarner Losh.\" modification, are permitted provided that the following conditions
117e299411SWarner Losh.\" are met:
127e299411SWarner Losh.\" 1. Redistributions of source code must retain the above copyright
137e299411SWarner Losh.\"    notice, this list of conditions and the following disclaimer.
147e299411SWarner Losh.\" 2. Redistributions in binary form must reproduce the above copyright
157e299411SWarner Losh.\"    notice, this list of conditions and the following disclaimer in the
167e299411SWarner Losh.\"    documentation and/or other materials provided with the distribution.
177e299411SWarner Losh.\"
187e299411SWarner Losh.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
197e299411SWarner Losh.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
207e299411SWarner Losh.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
217e299411SWarner Losh.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
227e299411SWarner Losh.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
237e299411SWarner Losh.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
247e299411SWarner Losh.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
257e299411SWarner Losh.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
267e299411SWarner Losh.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
277e299411SWarner Losh.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
287e299411SWarner Losh.\" POSSIBILITY OF SUCH DAMAGE.
297e299411SWarner Losh.\"
30*9b5d724cSDag-Erling Smørgrav.Dd August 21, 2023
317e299411SWarner Losh.Dt TIMESPEC_GET 3
327e299411SWarner Losh.Os
337e299411SWarner Losh.Sh NAME
347e299411SWarner Losh.Nm timespec_get
357e299411SWarner Losh.Nd get current calendar time
367e299411SWarner Losh.Sh LIBRARY
377e299411SWarner Losh.Lb libc
387e299411SWarner Losh.Sh SYNOPSIS
397e299411SWarner Losh.In time.h
407e299411SWarner Losh.Ft int
417e299411SWarner Losh.Fn timespec_get "struct timespec *ts" "int base"
427e299411SWarner Losh.Sh DESCRIPTION
437e299411SWarner LoshThe
447e299411SWarner Losh.Nm
457e299411SWarner Loshfunction sets the interval pointed to by
467e299411SWarner Losh.Fa ts
477e299411SWarner Loshto hold the current calendar time based on the specified time base in
487e299411SWarner Losh.Fa base .
497e299411SWarner Losh.Pp
503d19db5dSWarner LoshThe base
513d19db5dSWarner Losh.Dv TIME_UTC
523d19db5dSWarner Loshreturns the time since the epoch.
533d19db5dSWarner LoshThis time is expressed in seconds and nanoseconds since midnight (0 hour), January 1, 1970.
543d19db5dSWarner LoshIn
553d19db5dSWarner Losh.Fx ,
563d19db5dSWarner Loshthis corresponds to
573d19db5dSWarner Losh.Dv CLOCK_REALTIME .
58*9b5d724cSDag-Erling Smørgrav.Pp
59*9b5d724cSDag-Erling SmørgravThe base
60*9b5d724cSDag-Erling Smørgrav.Dv TIME_MONOTONIC
61*9b5d724cSDag-Erling Smørgravreturns a monotonically-increasing time since an unspecified point in the past.
62*9b5d724cSDag-Erling SmørgravIn
63*9b5d724cSDag-Erling Smørgrav.Fx ,
64*9b5d724cSDag-Erling Smørgravthis corresponds to
65*9b5d724cSDag-Erling Smørgrav.Dv CLOCK_MONOTONIC .
667e299411SWarner Losh.Sh RETURN VALUES
677e299411SWarner LoshThe
687e299411SWarner Losh.Nm
697e299411SWarner Loshfunction returns the passed value of
707e299411SWarner Losh.Fa base
717e299411SWarner Loshif successful, otherwise
727e299411SWarner Losh.Dv 0
737e299411SWarner Loshon failure.
747e299411SWarner Losh.Sh SEE ALSO
753d19db5dSWarner Losh.Xr clock_gettime 2 ,
76d03bd62fSEnji Cooper.Xr gettimeofday 2 ,
77*9b5d724cSDag-Erling Smørgrav.Xr time 3 ,
78*9b5d724cSDag-Erling Smørgrav.Xr timespec_getres 3
797e299411SWarner Losh.Sh STANDARDS
807e299411SWarner LoshThe
817e299411SWarner Losh.Nm
823d19db5dSWarner Loshfunction with a
833d19db5dSWarner Losh.Fa base
843d19db5dSWarner Loshof
853d19db5dSWarner Losh.Dv TIME_UTC
863d19db5dSWarner Loshconforms to
877e299411SWarner Losh.St -isoC-2011 .
88*9b5d724cSDag-Erling Smørgrav.\" The
89*9b5d724cSDag-Erling Smørgrav.\" .Dv TIME_MONOTONIC
90*9b5d724cSDag-Erling Smørgrav.\" base conforms to
91*9b5d724cSDag-Erling Smørgrav.\" -isoC-2023 .
927e299411SWarner Losh.Sh HISTORY
937e299411SWarner LoshThis interface first appeared in
943d19db5dSWarner Losh.Fx 12 .
957e299411SWarner Losh.Sh AUTHORS
967e299411SWarner Losh.An Kamil Rytarowski Aq Mt kamil@NetBSD.org
973d19db5dSWarner Losh.An Warner Losh Aq Mt imp@FreeBSD.org
98