1ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes/*
2ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * Copyright (c) 1989, 1993
3ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *	The Regents of the University of California.  All rights reserved.
4ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *
5ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * Redistribution and use in source and binary forms, with or without
6ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * modification, are permitted provided that the following conditions
7ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * are met:
8ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * 1. Redistributions of source code must retain the above copyright
9ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *    notice, this list of conditions and the following disclaimer.
10ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * 2. Redistributions in binary form must reproduce the above copyright
11ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *    notice, this list of conditions and the following disclaimer in the
12ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *    documentation and/or other materials provided with the distribution.
13ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * 4. Neither the name of the University nor the names of its contributors
14ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *    may be used to endorse or promote products derived from this software
15ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *    without specific prior written permission.
16ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes *
17ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes * SUCH DAMAGE.
28ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes */
29ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes
30ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#if defined(LIBC_SCCS) && !defined(lint)
31ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughesstatic char sccsid[] = "@(#)usleep.c	8.1 (Berkeley) 6/4/93";
32ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#endif /* LIBC_SCCS and not lint */
33ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#include <sys/cdefs.h>
34ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes__FBSDID("$FreeBSD$");
35ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes
36ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#include "namespace.h"
37ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#include <time.h>
38ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#include <unistd.h>
39ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes#include "un-namespace.h"
40ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes
41ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughesint
42ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes__usleep(useconds_t useconds)
43ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes{
44ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes	struct timespec time_to_sleep;
45ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes
46ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes	time_to_sleep.tv_nsec = (useconds % 1000000) * 1000;
47ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes	time_to_sleep.tv_sec = useconds / 1000000;
48ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes	return (_nanosleep(&time_to_sleep, NULL));
49ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes}
50ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes
51ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes__weak_reference(__usleep, usleep);
52ab61eb366ac48addf2bca6093a34455193f5c8dfElliott Hughes__weak_reference(__usleep, _usleep);
53