[PPL-devel] [GIT] ppl/ppl(master): Cater for systems where setitimer() is not provided (part 2).

Roberto Bagnara bagnara at cs.unipr.it
Wed Feb 17 12:15:51 CET 2010


Module: ppl/ppl
Branch: master
Commit: 8ac2c64c2e9fa2da2d02428fe51c34b8dca3d6ff
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=8ac2c64c2e9fa2da2d02428fe51c34b8dca3d6ff

Author: Roberto Bagnara <bagnara at cs.unipr.it>
Date:   Wed Feb 17 12:15:35 2010 +0100

Cater for systems where setitimer() is not provided (part 2).

---

 TODO                             |    4 ----
 Watchdog/pwl-config.sed          |    1 +
 Watchdog/src/Watchdog.cc         |   17 +++++++----------
 Watchdog/src/Watchdog.defs.hh    |    4 ++--
 Watchdog/src/Watchdog.inlines.hh |   35 +++++++++++++++++++++++------------
 5 files changed, 33 insertions(+), 28 deletions(-)

diff --git a/TODO b/TODO
index 8c3cf6d..835ea2c 100644
--- a/TODO
+++ b/TODO
@@ -2,10 +2,6 @@
 Enhancements for PPL 0.11
 =========================
 
-- Deterministic timeouts are disabled whenever the PWL is disabled.
-  However, the PWL is disabled when OS support for dealing with
-  real and CPU time are unavailable, which is not relevant for
-  people that want to use deterministic timeouts.
 - Make all the *affine*image() methods uniform as far as the
   specification is concerned.
 - Look carefully at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42115
diff --git a/Watchdog/pwl-config.sed b/Watchdog/pwl-config.sed
index 15a0d31..7972470 100644
--- a/Watchdog/pwl-config.sed
+++ b/Watchdog/pwl-config.sed
@@ -1,5 +1,6 @@
 s/\([^A-Z_]\)HAVE_DECL_GETENV/\1PWL_HAVE_DECL_GETENV/g
 s/\([^A-Z_]\)HAVE_DECL_SIGACTION/\1PWL_HAVE_DECL_SIGACTION/g
+s/\([^A-Z_]\)HAVE_DECL_SETITIMER/\1PWL_HAVE_DECL_SETITIMER/g
 s/\([^A-Z_]\)HAVE_DLFCN_H/\1PWL_HAVE_DLFCN_H/g
 s/\([^A-Z_]\)HAVE_FENV_H/\1PWL_HAVE_FENV_H/g
 s/\([^A-Z_]\)HAVE_INTTYPES_H/\1PWL_HAVE_INTTYPES_H/g
diff --git a/Watchdog/src/Watchdog.cc b/Watchdog/src/Watchdog.cc
index 03e259e..1b2fcb2 100644
--- a/Watchdog/src/Watchdog.cc
+++ b/Watchdog/src/Watchdog.cc
@@ -24,6 +24,8 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 #include "Watchdog.defs.hh"
 
+#if PWL_HAVE_DECL_SETITIMER
+
 #include <csignal>
 #include <iostream>
 #include <stdexcept>
@@ -218,17 +220,13 @@ PWL::Watchdog::remove_watchdog_event(WD_Pending_List::Iterator position) {
   pending.erase(position);
 }
 
-PWL::Watchdog::~Watchdog() {
-  if (!expired) {
-    in_critical_section = true;
-    remove_watchdog_event(pending_position);
-    in_critical_section = false;
-  }
-  delete &handler;
-}
+PWL::Time PWL::Watchdog::reschedule_time(1);
+
+#endif // PWL_HAVE_DECL_SETITIMER
 
 void
 PWL::Watchdog::initialize() {
+#if PWL_HAVE_DECL_SETITIMER
   signal_once.it_interval.tv_sec = 0;
   signal_once.it_interval.tv_usec = 0;
 
@@ -241,12 +239,11 @@ PWL::Watchdog::initialize() {
   s.sa_flags = 0;  // Was SA_ONESHOT: why?
 
   my_sigaction(THE_SIGNAL, &s, 0);
+#endif // PWL_HAVE_DECL_SETITIMER
 }
 
 void
 PWL::Watchdog::finalize() {
 }
 
-PWL::Time PWL::Watchdog::reschedule_time(1);
-
 unsigned int PWL::Init::count = 0;
diff --git a/Watchdog/src/Watchdog.defs.hh b/Watchdog/src/Watchdog.defs.hh
index 3b1b3ba..a6ec958 100644
--- a/Watchdog/src/Watchdog.defs.hh
+++ b/Watchdog/src/Watchdog.defs.hh
@@ -61,7 +61,7 @@ public:
   //! Destructor.
   ~Watchdog();
 
-#if HAVE_DECL_SETITIMER
+#if PWL_HAVE_DECL_SETITIMER
 
 private:
   typedef Pending_List<Watchdog_Traits> WD_Pending_List;
@@ -133,7 +133,7 @@ private:
 
   friend void PWL_handle_timeout(int signum);
 
-#endif // HAVE_DECL_SETITIMER
+#endif // PWL_HAVE_DECL_SETITIMER
 };
 
 class Init {
diff --git a/Watchdog/src/Watchdog.inlines.hh b/Watchdog/src/Watchdog.inlines.hh
index a24dd35..016926d 100644
--- a/Watchdog/src/Watchdog.inlines.hh
+++ b/Watchdog/src/Watchdog.inlines.hh
@@ -29,11 +29,12 @@ site: http://www.cs.unipr.it/ppl/ . */
 
 namespace Parma_Watchdog_Library {
 
-#if HAVE_DECL_SETITIMER
+#if PWL_HAVE_DECL_SETITIMER
 
 template <typename Flag_Base, typename Flag>
 Watchdog::Watchdog(unsigned int units,
-		   const Flag_Base* volatile& holder, Flag& flag)
+		   const Flag_Base* volatile& holder,
+                   Flag& flag)
   : expired(false),
     handler(*new Handler_Flag<Flag_Base, Flag>(holder, flag)) {
   if (units == 0)
@@ -55,32 +56,42 @@ Watchdog::Watchdog(unsigned int units, void (*function)())
   in_critical_section = false;
 }
 
+inline
+Watchdog::~Watchdog() {
+  if (!expired) {
+    in_critical_section = true;
+    remove_watchdog_event(pending_position);
+    in_critical_section = false;
+  }
+  delete &handler;
+}
+
 inline void
 Watchdog::reschedule() {
   set_timer(reschedule_time);
 }
 
-#else // !HAVE_DECL_SETITIMER
+#else // !PWL_HAVE_DECL_SETITIMER
 
 template <typename Flag_Base, typename Flag>
-Watchdog::Watchdog(unsigned int units,
-		   const Flag_Base* volatile& holder, Flag& flag) {
-  used(units);
-  used(holder);
-  used(flag);
+Watchdog::Watchdog(unsigned int /* units */,
+		   const Flag_Base* volatile& /* holder */,
+                   Flag& /* flag */) {
   throw std::runtime_error("PWL::Watchdog objects not supported:"
                            " system does not provide setitimer()");
 }
 
 inline
-Watchdog::Watchdog(unsigned int units, void (*function)()) {
-  used(units);
-  used(function);
+Watchdog::Watchdog(unsigned int /* units */, void (* /* function */)()) {
   throw std::runtime_error("PWL::Watchdog objects not supported:"
                            " system does not provide setitimer()");
 }
 
-#endif // HAVE_DECL_SETITIMER
+inline
+Watchdog::~Watchdog() {
+}
+
+#endif // !PWL_HAVE_DECL_SETITIMER
 
 inline
 Init::Init() {




More information about the PPL-devel mailing list