OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / alarm.c
1 /* vi: set sw=4 ts=4: */
2 /*
3  * alarm() for uClibc
4  *
5  * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
6  *
7  * GNU Library General Public License (LGPL) version 2 or later.
8  */
9
10 #include "syscalls.h"
11 #include <unistd.h>
12 #ifdef __NR_alarm
13 #define __NR___alarm __NR_alarm
14 _syscall1(unsigned int, alarm, unsigned int, seconds);
15 #else
16 #include <sys/time.h>
17
18 libc_hidden_proto(setitimer)
19
20 unsigned int alarm(unsigned int seconds)
21 {
22         struct itimerval old, new;
23         unsigned int retval;
24
25         new.it_value.tv_usec = 0;
26         new.it_interval.tv_sec = 0;
27         new.it_interval.tv_usec = 0;
28         new.it_value.tv_sec = (long int) seconds;
29         if (setitimer(ITIMER_REAL, &new, &old) < 0) {
30                 return 0;
31         }
32         retval = old.it_value.tv_sec;
33         if (old.it_value.tv_usec) {
34                 ++retval;
35         }
36         return retval;
37 }
38 #endif
39 libc_hidden_proto(alarm)
40 libc_hidden_def(alarm)