git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22484 a95241bf-73f2-0310-859d-f6bbb57e9c96
36 lines
632 B
C
36 lines
632 B
C
/*
|
|
** Copyright 2004, Axel Dörfler, [email protected]. All rights reserved.
|
|
** Distributed under the terms of the Haiku License.
|
|
*/
|
|
|
|
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
#include <sys/time.h>
|
|
|
|
#include <syscalls.h>
|
|
|
|
|
|
uint
|
|
alarm(unsigned int sec)
|
|
{
|
|
struct itimerval value, oldValue;
|
|
int result;
|
|
|
|
value.it_interval.tv_sec = value.it_interval.tv_usec = 0;
|
|
value.it_value.tv_sec = sec;
|
|
value.it_value.tv_usec = 0;
|
|
|
|
result = setitimer(ITIMER_REAL, &value, &oldValue);
|
|
if (result < 0) {
|
|
errno = result;
|
|
return -1;
|
|
}
|
|
|
|
if (oldValue.it_value.tv_usec)
|
|
oldValue.it_value.tv_sec++;
|
|
|
|
return oldValue.it_value.tv_sec;
|
|
}
|
|
|