xref: /haiku/src/system/libroot/posix/unistd/usleep.c (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2 ** Copyright 2001, Manuel J. Petit. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
5 
6 #include <unistd.h>
7 #include <syscalls.h>
8 #include <errno.h>
9 
10 int
11 usleep(unsigned useconds)
12 {
13 	int err;
14 	err = snooze_until(system_time() + (bigtime_t)(useconds), B_SYSTEM_TIMEBASE);
15 	if (err < 0) {
16 		errno = err;
17 		return -1;
18 	}
19 	return 0;
20 }
21