1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
From: Roberto Bagnara <bagnara@cs.unipr.it>
Date: Wed, 17 Feb 2010 11:15:35 +0000 (+0100)
Subject: Cater for systems where setitimer() is not provided (part 2).
X-Git-Url: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl%2Fppl.git;a=commitdiff_plain;h=8ac2c64c2e9fa2da2d02428fe51c34b8dca3d6ff
Cater for systems where setitimer() is not provided (part 2).
---
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:
Watchdog(int units, void (*function)());
~Watchdog();
-#if HAVE_DECL_SETITIMER
+#if PWL_HAVE_DECL_SETITIMER
private:
friend class Init;
@@ -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,7 +29,7 @@ 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(int units, const Flag_Base* volatile& holder, Flag& flag)
@@ -55,32 +56,42 @@ Watchdog::Watchdog(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(int units,
- const Flag_Base* volatile& holder, Flag& flag) {
- used(units);
- used(holder);
- used(flag);
+Watchdog::Watchdog(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(int units, void (*function)()) {
- used(units);
- used(function);
+Watchdog::Watchdog(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() {
|