From cb7e8c5ef3f5f60a848e469ed40610c8946fe7ac Mon Sep 17 00:00:00 2001 From: David 'Digit' Turner Date: Thu, 8 Jul 2010 17:19:07 -0700 Subject: [PATCH] libc: update alarm() implementation to return 0 on error. This matches the GLibc behaviour, and allows alarm(0xFFFFFFFF) to return 0. Change-Id: I419aa71b27d6bb2015d15ba6b6112bf62eadcbb8 --- libc/docs/CHANGES.TXT | 5 +++++ libc/unistd/alarm.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/libc/docs/CHANGES.TXT b/libc/docs/CHANGES.TXT index cbca6cb16..96f25d34c 100644 --- a/libc/docs/CHANGES.TXT +++ b/libc/docs/CHANGES.TXT @@ -27,6 +27,10 @@ Differences between current and Android 2.2: - : add missing declaration for truncate(). The implementation was already here since Android 1.5. + modify implementation of alarm() to return 0 in case of error (i.e. + if a value larger than 0x7fffffff seconds is passed to it). This + makes the implementation compliant with the GLibc behaviour. + - : small fixes to really support wchar_t in Bionic (not there yet). the size of wchar_t is still 32-bit (decided by the compiler) @@ -66,6 +70,7 @@ Differences between current and Android 2.2: - : fixed implementation of fstatfs() (also fixes fpathconf() which uses it). + ------------------------------------------------------------------------------- Differences between Android 2.2. and Android 2.1: diff --git a/libc/unistd/alarm.c b/libc/unistd/alarm.c index 01863a43f..53edea949 100644 --- a/libc/unistd/alarm.c +++ b/libc/unistd/alarm.c @@ -51,7 +51,11 @@ alarm(secs) 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 if (oitv.it_value.tv_usec) oitv.it_value.tv_sec++; return (oitv.it_value.tv_sec); -- 2.11.0