vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / unistd / ualarm.c
blob36acd6e467bae5802217ab6d6a606e11d714f72a
1 /*
2 * Copyright 2004-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include <errno.h>
8 #include <unistd.h>
9 #include <sys/time.h>
11 #include <errno_private.h>
12 #include <syscalls.h>
15 useconds_t
16 ualarm(useconds_t usec, useconds_t interval)
18 struct itimerval value, oldValue;
20 value.it_value.tv_sec = usec / 1000000;
21 value.it_value.tv_usec = usec % 1000000;
22 value.it_interval.tv_sec = interval / 1000000;
23 value.it_interval.tv_usec = interval % 1000000;
25 if (setitimer(ITIMER_REAL, &value, &oldValue) < 0)
26 return -1;
28 return (oldValue.it_value.tv_sec * 1000000) + oldValue.it_value.tv_usec;