Index: distrib/sets/lists/comp/mi =================================================================== RCS file: /public/netbsd-rsync/src/distrib/sets/lists/comp/mi,v retrieving revision 1.2062 diff -u -r1.2062 mi --- distrib/sets/lists/comp/mi 2 Oct 2016 17:19:00 -0000 1.2062 +++ distrib/sets/lists/comp/mi 3 Oct 2016 23:46:24 -0000 @@ -9352,6 +9352,7 @@ ./usr/share/man/cat3/timerclear.0 comp-c-catman .cat ./usr/share/man/cat3/timercmp.0 comp-c-catman .cat ./usr/share/man/cat3/timerisset.0 comp-c-catman .cat +./usr/share/man/cat3/timerspec_get.0 comp-c-catman .cat ./usr/share/man/cat3/timersub.0 comp-c-catman .cat ./usr/share/man/cat3/times.0 comp-c-catman .cat ./usr/share/man/cat3/timespec.0 comp-c-catman .cat @@ -16559,6 +16560,7 @@ ./usr/share/man/html3/timerclear.html comp-c-htmlman html ./usr/share/man/html3/timercmp.html comp-c-htmlman html ./usr/share/man/html3/timerisset.html comp-c-htmlman html +./usr/share/man/html3/timerspec_get.html comp-c-htmlman html ./usr/share/man/html3/timersub.html comp-c-htmlman html ./usr/share/man/html3/times.html comp-c-htmlman html ./usr/share/man/html3/timespec.html comp-c-htmlman html @@ -23829,6 +23831,7 @@ ./usr/share/man/man3/timerclear.3 comp-c-man .man ./usr/share/man/man3/timercmp.3 comp-c-man .man ./usr/share/man/man3/timerisset.3 comp-c-man .man +./usr/share/man/man3/timerspec_get.3 comp-c-man .man ./usr/share/man/man3/timersub.3 comp-c-man .man ./usr/share/man/man3/times.3 comp-c-man .man ./usr/share/man/man3/timespec.3 comp-c-man .man Index: include/time.h =================================================================== RCS file: /public/netbsd-rsync/src/include/time.h,v retrieving revision 1.46 diff -u -r1.46 time.h --- include/time.h 23 Apr 2016 23:10:10 -0000 1.46 +++ include/time.h 3 Oct 2016 23:41:51 -0000 @@ -137,9 +137,10 @@ extern int getdate_err; #endif +#include + #if (_POSIX_C_SOURCE - 0) >= 199309L || (_XOPEN_SOURCE - 0) >= 500 || \ defined(_NETBSD_SOURCE) -#include /* XXX for struct timespec */ struct sigevent; struct itimerspec; int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); @@ -231,6 +232,10 @@ #endif /* _NETBSD_SOURCE */ +/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */ +#define TIME_UTC 1 /* time elapsed since epoch */ +int timerspec_get(struct timespec *ts, int base); + __END_DECLS #endif /* !_TIME_H_ */ Index: lib/libc/gen/Makefile.inc =================================================================== RCS file: /public/netbsd-rsync/src/lib/libc/gen/Makefile.inc,v retrieving revision 1.195 diff -u -r1.195 Makefile.inc --- lib/libc/gen/Makefile.inc 5 Jun 2016 17:16:44 -0000 1.195 +++ lib/libc/gen/Makefile.inc 3 Oct 2016 22:47:46 -0000 @@ -32,7 +32,7 @@ siglist.c signal.c signame.c sigrelse.c \ sigset.c sigsetops.c sleep.c \ stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \ - sysctlnametomib.c syslog.c telldir.c time.c \ + sysctlnametomib.c syslog.c telldir.c time.c timerspec_get.c \ times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \ ulimit.c uname.c unvis.c usleep.c utime.c utimens.c utmp.c \ utmpx.c valloc.c vis.c wait.c wait3.c waitid.c waitpid.c warn.c \ @@ -80,8 +80,9 @@ raise.3 randomid.3 realpath.3 scandir.3 setjmp.3 setmode.3 \ setproctitle.3 shquote.3 sighold.3 sigignore.3 siginterrupt.3 \ signal.3 signbit.3 sigrelse.3 sigset.3 sigsetops.3 sleep.3 \ - stringlist.3 sysconf.3 sysctl.3 syslog.3 time.3 times.3 \ - timezone.3 toascii.3 tolower.3 toupper.3 ttyname.3 \ + stringlist.3 sysconf.3 sysctl.3 syslog.3 \ + time.3 timerspec_get.3 times.3 timezone.3 toascii.3 tolower.3 \ + toupper.3 ttyname.3 \ ualarm.3 ulimit.3 uname.3 unvis.3 usleep.3 utime.3 valloc.3 vis.3 \ wordexp.3 Index: lib/libc/gen/timerspec_get.3 =================================================================== RCS file: lib/libc/gen/timerspec_get.3 diff -N lib/libc/gen/timerspec_get.3 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libc/gen/timerspec_get.3 3 Oct 2016 23:30:42 -0000 @@ -0,0 +1,75 @@ +.\" $NetBSD$ +.\" +.\" Copyright (c) 2016 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Kamil Rytarowski. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd October 4, 2016 +.Dt TIMERSPEC_GET 3 +.Os +.Sh NAME +.Nm timerspec_get +.Nd get current calendar time +.Sh LIBRARY +.Lb libc +.Sh SYNOPSIS +.In time.h +.Vt #define TIME_UTC 1 +.Ft int +.Fn timerspec_get "struct timespec *ts" "int base" +.Sh DESCRIPTION +The +.Nm +function sets the interval pointed to by +.Fa ts +to hold the current callendar time based on the specified time base in +.Fa base . +.Pn +Currently the only supported valid base is +.Va TIME_UTC +value. +It returns time elapsed since epoch. +.Sh RETURN VALUES +The +.Nm +function returns the passed value of +.Fa base +if successful, otherwise +.Dv 0 +on failure. +.\" .Sh ERRORS +.Sh SEE ALSO +.Xr clock_gettime 3 +.Sh STANDARDS +The +.Nm +function conforms to +.St -isoC-2011 . +.Sh HISTORY +This interface first appeared in +.Nx 8 . +.Sh AUTHORS +.An Kamil Rytarowski Aq Mt kamil@NetBSD.org Index: lib/libc/gen/timerspec_get.c =================================================================== RCS file: lib/libc/gen/timerspec_get.c diff -N lib/libc/gen/timerspec_get.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/libc/gen/timerspec_get.c 3 Oct 2016 22:48:15 -0000 @@ -0,0 +1,51 @@ +/* $NetBSD$ */ + +/*- + * Copyright (c) 2016 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Kamil Rytarowski. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#ifndef lint +__RCSID("$NetBSD$"); +#endif /* !defined lint */ + +#include + +/* ISO/IEC 9899:201x 7.27.2.5 The timespec_get function */ + +int +timerspec_get(struct timespec *ts, int base) +{ + + if (base == TIME_UTC) { + if (clock_gettime(CLOCK_REALTIME, ts) != 0) + return TIME_UTC; + } + + return 0; +}