ftime.c revision 302408
1249259Sdim/*
2249259Sdim * Copyright (c) 1994 Christopher G. Demetriou
3249259Sdim * All rights reserved.
4249259Sdim *
5249259Sdim * Redistribution and use in source and binary forms, with or without
6249259Sdim * modification, are permitted provided that the following conditions
7249259Sdim * are met:
8249259Sdim * 1. Redistributions of source code must retain the above copyright
9249259Sdim *    notice, this list of conditions and the following disclaimer.
10249259Sdim * 2. Redistributions in binary form must reproduce the above copyright
11249259Sdim *    notice, this list of conditions and the following disclaimer in the
12249259Sdim *    documentation and/or other materials provided with the distribution.
13249259Sdim * 3. All advertising materials mentioning features or use of this software
14249259Sdim *    must display the following acknowledgement:
15249259Sdim *      This product includes software developed by Christopher G. Demetriou.
16249259Sdim * 4. The name of the author may not be used to endorse or promote products
17249259Sdim *    derived from this software without specific prior written permission
18249259Sdim *
19249259Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20249259Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21249259Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22249259Sdim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23249259Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24249259Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25249259Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26249259Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27249259Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28249259Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29249259Sdim */
30249259Sdim
31249259Sdim#ifndef lint
32249259Sdimstatic char rcsid[] = "$FreeBSD: stable/11/lib/libcompat/4.1/ftime.c 211061 2010-08-08 08:19:23Z ed $";
33249259Sdim#endif /* not lint */
34249259Sdim
35249259Sdim#include <sys/types.h>
36249259Sdim#include <sys/time.h>
37249259Sdim#include <sys/timeb.h>
38249259Sdim
39249259Sdimint
40249259Sdimftime(struct timeb *tbp)
41249259Sdim{
42249259Sdim	struct timezone tz;
43249259Sdim	struct timeval t;
44249259Sdim
45249259Sdim	if (gettimeofday(&t, &tz) < 0)
46249259Sdim		return (-1);
47249259Sdim	tbp->millitm = t.tv_usec / 1000;
48249259Sdim	tbp->time = t.tv_sec;
49249259Sdim	tbp->timezone = tz.tz_minuteswest;
50249259Sdim	tbp->dstflag = tz.tz_dsttime;
51249259Sdim
52249259Sdim	return (0);
53249259Sdim}
54249259Sdim