1235537Sgber/*
2235537Sgber * Copyright (c) 1983, 1993
3235537Sgber *	The Regents of the University of California.  All rights reserved.
4235537Sgber *
5235537Sgber * Redistribution and use in source and binary forms, with or without
6235537Sgber * modification, are permitted provided that the following conditions
7235537Sgber * are met:
8235537Sgber * 1. Redistributions of source code must retain the above copyright
9235537Sgber *    notice, this list of conditions and the following disclaimer.
10235537Sgber * 2. Redistributions in binary form must reproduce the above copyright
11235537Sgber *    notice, this list of conditions and the following disclaimer in the
12235537Sgber *    documentation and/or other materials provided with the distribution.
13235537Sgber * 4. Neither the name of the University nor the names of its contributors
14235537Sgber *    may be used to endorse or promote products derived from this software
15235537Sgber *    without specific prior written permission.
16235537Sgber *
17235537Sgber * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18235537Sgber * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19235537Sgber * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20235537Sgber * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21235537Sgber * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22235537Sgber * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23235537Sgber * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24235537Sgber * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25235537Sgber * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26235537Sgber * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27235537Sgber * SUCH DAMAGE.
28235537Sgber */
29235537Sgber
30235537Sgber#if defined(LIBC_SCCS) && !defined(lint)
31235537Sgberstatic char sccsid[] = "@(#)time.c	8.1 (Berkeley) 6/4/93";
32235537Sgber#endif /* LIBC_SCCS and not lint */
33235537Sgber#include <sys/cdefs.h>
34235537Sgber__FBSDID("$FreeBSD$");
35235537Sgber
36235537Sgber#include <sys/types.h>
37235537Sgber#include <sys/time.h>
38235537Sgber
39235537Sgbertime_t
40235537Sgbertime(time_t *t)
41235537Sgber{
42235537Sgber	struct timespec tt;
43235537Sgber	time_t retval;
44235537Sgber
45235537Sgber	if (clock_gettime(CLOCK_SECOND, &tt) < 0)
46235537Sgber		retval = -1;
47235537Sgber	else
48235537Sgber		retval = tt.tv_sec;
49235537Sgber	if (t != NULL)
50235537Sgber		*t = retval;
51235537Sgber	return (retval);
52235537Sgber}
53235537Sgber