xref: /freebsd-src/stand/libofw/ofw_time.c (revision 4cddd20e1ea8b9c622c72edfad3e64f70e9d56a9)
1475008d6SBrandon Bergren /*-
2475008d6SBrandon Bergren  * Copyright (c) 2000 Benno Rice
3475008d6SBrandon Bergren  * All rights reserved.
4475008d6SBrandon Bergren  *
5475008d6SBrandon Bergren  * Redistribution and use in source and binary forms, with or without
6475008d6SBrandon Bergren  * modification, are permitted provided that the following conditions
7475008d6SBrandon Bergren  * are met:
8475008d6SBrandon Bergren  * 1. Redistributions of source code must retain the above copyright
9475008d6SBrandon Bergren  *    notice, this list of conditions and the following disclaimer.
10475008d6SBrandon Bergren  * 2. Redistributions in binary form must reproduce the above copyright
11475008d6SBrandon Bergren  *    notice, this list of conditions and the following disclaimer in the
12475008d6SBrandon Bergren  *    documentation and/or other materials provided with the distribution.
13475008d6SBrandon Bergren  *
14475008d6SBrandon Bergren  * THIS SOFTWARE IS PROVIDED BY Benno Rice ``AS IS'' AND
15475008d6SBrandon Bergren  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16475008d6SBrandon Bergren  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17475008d6SBrandon Bergren  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18475008d6SBrandon Bergren  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19475008d6SBrandon Bergren  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20475008d6SBrandon Bergren  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21475008d6SBrandon Bergren  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22475008d6SBrandon Bergren  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23475008d6SBrandon Bergren  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24475008d6SBrandon Bergren  * SUCH DAMAGE.
25475008d6SBrandon Bergren  */
26475008d6SBrandon Bergren 
27475008d6SBrandon Bergren #include <stand.h>
28475008d6SBrandon Bergren #include "openfirm.h"
29475008d6SBrandon Bergren 
30475008d6SBrandon Bergren time_t
time(time_t * tloc)31475008d6SBrandon Bergren time(time_t *tloc)
32475008d6SBrandon Bergren {
33475008d6SBrandon Bergren 	int secs;
34475008d6SBrandon Bergren 
35475008d6SBrandon Bergren 	secs = OF_milliseconds() / 1000;
36475008d6SBrandon Bergren 	if (tloc)
37475008d6SBrandon Bergren 		*tloc = secs;
38*4cddd20eSWarner Losh 	return (secs);
39475008d6SBrandon Bergren }
40475008d6SBrandon Bergren 
41475008d6SBrandon Bergren time_t
getsecs(void)42475008d6SBrandon Bergren getsecs(void)
43475008d6SBrandon Bergren {
44475008d6SBrandon Bergren 	time_t	n = 0;
45475008d6SBrandon Bergren 	time(&n);
46*4cddd20eSWarner Losh 	return (n);
47475008d6SBrandon Bergren }
48475008d6SBrandon Bergren 
49475008d6SBrandon Bergren void
delay(int usecs)50475008d6SBrandon Bergren delay(int usecs)
51475008d6SBrandon Bergren {
52475008d6SBrandon Bergren 	int	msecs, start;
53475008d6SBrandon Bergren 
54475008d6SBrandon Bergren 	msecs = usecs / 1000;
55475008d6SBrandon Bergren 	start = OF_milliseconds();
56475008d6SBrandon Bergren 
57475008d6SBrandon Bergren 	while (OF_milliseconds() - start < msecs);
58475008d6SBrandon Bergren }
59