am 2c7c79e6
: Merge "Switch to upstream alarm(3)."
* commit '2c7c79e6e5e730553281b6d42e734ee2c532a660': Switch to upstream alarm(3).
This commit is contained in:
commit
fea778b308
@ -104,7 +104,6 @@ libc_common_src_files := \
|
||||
stdlib/putenv.c \
|
||||
stdlib/setenv.c \
|
||||
stdlib/strtod.c \
|
||||
unistd/alarm.c \
|
||||
unistd/syslog.c \
|
||||
unistd/time.c \
|
||||
|
||||
@ -316,6 +315,7 @@ libc_upstream_netbsd_src_files := \
|
||||
upstream-netbsd/lib/libc/unistd/killpg.c \
|
||||
|
||||
libc_upstream_openbsd_src_files := \
|
||||
upstream-openbsd/lib/libc/gen/alarm.c \
|
||||
upstream-openbsd/lib/libc/gen/exec.c \
|
||||
upstream-openbsd/lib/libc/gen/fnmatch.c \
|
||||
upstream-openbsd/lib/libc/gen/ftok.c \
|
||||
|
@ -1,3 +1,4 @@
|
||||
/* $OpenBSD: alarm.c,v 1.7 2005/08/08 08:05:33 espie Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -10,7 +11,7 @@
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
@ -27,12 +28,6 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#include <sys/cdefs.h>
|
||||
//__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/alarm.c,v 1.3 2007/01/09 00:27:53 imp Exp $");
|
||||
|
||||
/*
|
||||
* Backwards compatible alarm.
|
||||
*/
|
||||
@ -40,22 +35,16 @@ static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93";
|
||||
#include <unistd.h>
|
||||
|
||||
unsigned int
|
||||
alarm(secs)
|
||||
unsigned int secs;
|
||||
alarm(unsigned int secs)
|
||||
{
|
||||
struct itimerval it, oitv;
|
||||
struct itimerval *itp = ⁢
|
||||
|
||||
itp->it_interval.tv_usec = 0;
|
||||
itp->it_interval.tv_sec = 0;
|
||||
timerclear(&itp->it_interval);
|
||||
itp->it_value.tv_sec = secs;
|
||||
itp->it_value.tv_usec = 0;
|
||||
if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
|
||||
#if 1 /* BIONIC: Same behaviour than GLibc for errors */
|
||||
return 0;
|
||||
#else
|
||||
return (-1);
|
||||
#endif
|
||||
return ((unsigned int) -1);
|
||||
if (oitv.it_value.tv_usec)
|
||||
oitv.it_value.tv_sec++;
|
||||
return (oitv.it_value.tv_sec);
|
@ -112,3 +112,7 @@ TEST(unistd, read_EBADF) {
|
||||
ASSERT_EQ(-1, read(-1, buf, sizeof(buf)));
|
||||
ASSERT_EQ(EBADF, errno);
|
||||
}
|
||||
|
||||
TEST(unistd, alarm) {
|
||||
ASSERT_EQ(0U, alarm(0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user