Source: check
Version: 0.9.10-3
Severity: important
Tags: patch
User: [email protected]
Usertags: hurd
Control: forwarded -1 https://sourceforge.net/p/check/patches/49/
Hi,
check 0.9.10-3 does not build on hurd-i386 [1].
The problem is due to the second-only precision which is available with
alarm in the replacement for the timer_* functions (not implemented yet
on Hurd), which causes few check failures in two tests.
I just reported the issue upstream [2] with a clean patch for the issue;
since that requires autoreconf, I'm providing a simplier patch which
just unconditionally switches the timer_settimer replacement to
setitimer; should cause no issues on Linux and kFreeBSD, since both
implement the timer_* functions.
Both patches (the one sent upstream and the one attached here) fix the
issue on Hurd.
[1]
https://buildd.debian.org/status/fetch.php?pkg=check&arch=hurd-i386&ver=0.9.10-3&stamp=1373106835
[2] https://sourceforge.net/p/check/patches/49/
Thanks,
--
Pino
--- a/lib/timer_settime.c
+++ b/lib/timer_settime.c
@@ -1,22 +1,18 @@
#include "libcompat.h"
+#include <sys/time.h>
+
int timer_settime(timer_t timerid CK_ATTRIBUTE_UNUSED,
int flags CK_ATTRIBUTE_UNUSED,
const struct itimerspec *new_value,
struct itimerspec * old_value CK_ATTRIBUTE_UNUSED)
{
- int seconds = new_value->it_value.tv_sec;
-
- /*
- * As the alarm() call has only second precision, if the caller
- * specifies partial seconds, we round up to the nearest second.
- */
- if(new_value->it_value.tv_nsec > 0)
- {
- seconds += 1;
- }
-
- alarm(seconds);
-
- return 0;
+ struct itimerval new;
+
+ new.it_value.tv_sec = new_value->it_value.tv_sec;
+ new.it_value.tv_usec = new_value->it_value.tv_nsec / 1000;
+ new.it_interval.tv_sec = new_value->it_interval.tv_sec;
+ new.it_interval.tv_usec = new_value->it_interval.tv_nsec / 1000;
+
+ return setitimer(ITIMER_REAL, &new, NULL);
}