Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/atf/dist/atf-run Put back setitimer based code ...
details: https://anonhg.NetBSD.org/src/rev/ba7f045d37c2
branches: trunk
changeset: 772134:ba7f045d37c2
user: christos <christos%NetBSD.org@localhost>
date: Mon Dec 19 21:59:46 2011 +0000
description:
Put back setitimer based code for the have-nots: (OS/X Lion)
diffstat:
external/bsd/atf/dist/atf-run/timer.cpp | 41 ++++++++++++++++++++++++++++++--
1 files changed, 38 insertions(+), 3 deletions(-)
diffs (73 lines):
diff -r 52f63331d12c -r ba7f045d37c2 external/bsd/atf/dist/atf-run/timer.cpp
--- a/external/bsd/atf/dist/atf-run/timer.cpp Mon Dec 19 21:56:18 2011 +0000
+++ b/external/bsd/atf/dist/atf-run/timer.cpp Mon Dec 19 21:59:46 2011 +0000
@@ -44,11 +44,25 @@
// Auxiliary functions.
// ------------------------------------------------------------------------
+#ifdef SIGEV_NONE
+#define HAVE_POSIX_TIMER
+#endif
+
+#ifndef HAVE_POSIX_TIMER
+static void *handle;
+#endif
+
static
void
handler(int signo, siginfo_t *si, void *uc)
{
- impl::timer *timer = static_cast<impl::timer *>(si->si_value.sival_ptr);
+ impl::timer *timer = static_cast<impl::timer *>(
+#ifndef HAVE_POSIX_TIMER
+ handle
+#else
+ si->si_value.sival_ptr
+#endif
+ );
timer->setfired();
timer->timeout_callback();
@@ -68,7 +82,7 @@
throw system_error(IMPL_NAME "::timer::timer",
"Failed to set signal handler", errno);
-
+#ifndef HAVE_POSIX_TIMER
::sigevent se;
se.sigev_notify = SIGEV_SIGNAL;
se.sigev_signo = SIGALRM;
@@ -92,11 +106,32 @@
throw system_error(IMPL_NAME "::timer::timer",
"Failed to program timer", errno);
}
+#else
+ ::itimerval it, oit;
+ it.it_interval.tv_sec = 0;
+ it.it_interval.tv_usec = 0;
+ it.it_value.tv_sec = seconds;
+ it.it_value.tv_usec = 0;
+ if (::setitimer(ITIMER_REAL, &it, &oit) == -1)
+ ::sigaction(SIGALRM, &m_old_sa, NULL);
+ throw system_error(IMPL_NAME "::timer::timer",
+ "Failed to program timer", errno);
+ }
+ TIMEVAL_TO_TIMESPEC(&m_old_it, &oit);
+ handle = static_cast<void *>(this);
+#endif
}
impl::timer::~timer(void)
{
- int ret = ::timer_delete(m_timer);
+ int ret;
+#ifdef HAVE_POSIX_TIMER
+ ::itimerval oit;
+ TIMESPEC_TO_TIMEVAL(&oit, &m_old_it);
+ ret = ::setitimer(ITIMER_REAL, &oit, NULL);
+#else
+ ret = ::timer_delete(m_timer);
+#endif
INV(ret != -1);
ret = ::sigaction(SIGALRM, &m_old_sa, NULL);
INV(ret != -1);
Home |
Main Index |
Thread Index |
Old Index