1 /* @(#)sleep.c	1.6 14/03/03 Copyright 2007-2014 J. Schilling */
2 #include <schily/mconfig.h>
3 #ifndef lint
4 static	UConst char sccsid[] =
5 	"@(#)sleep.c	1.6 14/03/03 Copyright 2007-2014 J. Schilling";
6 #endif
7 /*
8  *	Emulate sleep where it does not exist
9  *
10  *	Copyright (c) 2007-2014 J. Schilling
11  */
12 /*
13  * The contents of this file are subject to the terms of the
14  * Common Development and Distribution License, Version 1.0 only
15  * (the "License").  You may not use this file except in compliance
16  * with the License.
17  *
18  * See the file CDDL.Schily.txt in this distribution for details.
19  * A copy of the CDDL is also available via the Internet at
20  * http://www.opensource.org/licenses/cddl1.txt
21  *
22  * When distributing Covered Code, include this CDDL HEADER in each
23  * file and include the License file CDDL.Schily.txt from this distribution.
24  */
25 
26 #if	!defined(HAVE_SLEEP) && (defined(_MSC_VER) || defined(__MINGW32__))
27 #include <schily/windows.h>
28 #include <schily/standard.h>
29 
30 EXPORT unsigned int
sleep(secs)31 sleep(secs)
32 	unsigned int	secs;
33 {
34 	DWORD		ms;
35 
36 	if (secs == 0)
37 		return (0);
38 
39 	ms = secs * 1000;
40 	Sleep(ms);
41 	return (0);
42 }
43 
44 EXPORT int
usleep(usecs)45 usleep(usecs)
46 	unsigned int	usecs;
47 {
48 	DWORD		ms;
49 
50 	if (usecs == 0)
51 		return (0);
52 
53 	ms = usecs / 1000;
54 	Sleep(ms);
55 	return (0);
56 }
57 #endif
58