]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/libc_backends/lib/l4re/lib/nanosleep.c
Inital import
[l4.git] / l4 / pkg / libc_backends / lib / l4re / lib / nanosleep.c
1 /**
2  * \file   dietlibc/lib/backends/simple_sleep/sleep.c
3  * \brief  
4  *
5  * \date   08/10/2004
6  * \author Martin Pohlack  <mp26@os.inf.tu-dresden.de>
7  */
8 /*
9  * (c) 2004-2009 Technische Universität Dresden
10  * This file is part of TUD:OS and distributed under the terms of the
11  * GNU Lesser General Public License 2.1.
12  * Please see the COPYING-LGPL-2.1 file for details.
13  */
14 #include <errno.h>
15 #include <sys/time.h>
16 #include <time.h>
17
18 #include <l4/util/util.h>
19
20 int nanosleep(const struct timespec *req, struct timespec *rem)
21 {
22     int milis;
23
24     (void)rem;
25     if (req == NULL)
26     {
27         errno = EFAULT; // or maybe EINVAL ???
28         return -1;
29     }
30
31     if (req->tv_nsec < 0 || req->tv_nsec > 999999999 || req->tv_sec < 0)
32     {
33         errno = EINVAL;
34         return -1;
35     }
36
37     milis = (req->tv_sec * 1000) + (req->tv_nsec / 1000000);
38     l4_sleep(milis);
39
40     return 0;
41 }