11581Srgrimes/*
21581Srgrimes * Copyright (c) 1994 Christopher G. Demetriou
31581Srgrimes * All rights reserved.
41581Srgrimes *
51581Srgrimes * Redistribution and use in source and binary forms, with or without
61581Srgrimes * modification, are permitted provided that the following conditions
71581Srgrimes * are met:
81581Srgrimes * 1. Redistributions of source code must retain the above copyright
91581Srgrimes *    notice, this list of conditions and the following disclaimer.
101581Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
111581Srgrimes *    notice, this list of conditions and the following disclaimer in the
121581Srgrimes *    documentation and/or other materials provided with the distribution.
131581Srgrimes * 3. All advertising materials mentioning features or use of this software
141581Srgrimes *    must display the following acknowledgement:
151581Srgrimes *      This product includes software developed by Christopher G. Demetriou.
161581Srgrimes * 4. The name of the author may not be used to endorse or promote products
171581Srgrimes *    derived from this software without specific prior written permission
181581Srgrimes *
191581Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
201581Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
211581Srgrimes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
221581Srgrimes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
231581Srgrimes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
241581Srgrimes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
251581Srgrimes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
261581Srgrimes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
271581Srgrimes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
281581Srgrimes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
291581Srgrimes */
301581Srgrimes
311581Srgrimes#ifndef lint
3250476Speterstatic char rcsid[] = "$FreeBSD: releng/11.0/lib/libcompat/4.1/ftime.c 211061 2010-08-08 08:19:23Z ed $";
331581Srgrimes#endif /* not lint */
341581Srgrimes
351581Srgrimes#include <sys/types.h>
361581Srgrimes#include <sys/time.h>
371581Srgrimes#include <sys/timeb.h>
381581Srgrimes
3917141Sjkhint
40205125Sedftime(struct timeb *tbp)
411581Srgrimes{
42211061Sed	struct timezone tz;
43211061Sed	struct timeval t;
441581Srgrimes
45211061Sed	if (gettimeofday(&t, &tz) < 0)
46211061Sed		return (-1);
47211061Sed	tbp->millitm = t.tv_usec / 1000;
48211061Sed	tbp->time = t.tv_sec;
49211061Sed	tbp->timezone = tz.tz_minuteswest;
50211061Sed	tbp->dstflag = tz.tz_dsttime;
511581Srgrimes
521581Srgrimes	return (0);
531581Srgrimes}
54