Package: ppl / 0.10.2-8

eab6ab2fd4e44c8e7348c26112e4c9e4190e88ee Patch series | download
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
From: Roberto Bagnara <bagnara@cs.unipr.it>
Date: Wed, 17 Feb 2010 11:22:12 +0000 (+0100)
Subject: Cater for systems where setitimer() is not provided (part 3).
X-Git-Url: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl%2Fppl.git;a=commitdiff_plain;h=eab6ab2fd4e44c8e7348c26112e4c9e4190e88ee

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

diff --git a/Watchdog/src/Watchdog.cc b/Watchdog/src/Watchdog.cc
index 1b2fcb2..68ed01f 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"
 
+namespace PWL = Parma_Watchdog_Library;
+
 #if PWL_HAVE_DECL_SETITIMER
 
 #include <csignal>
@@ -54,8 +56,6 @@ site: http://www.cs.unipr.it/ppl/ . */
 #define THE_SIGNAL SIGPROF
 #endif
 
-namespace PWL = Parma_Watchdog_Library;
-
 using std::cerr;
 using std::endl;
 
@@ -222,11 +222,8 @@ PWL::Watchdog::remove_watchdog_event(WD_Pending_List::Iterator position) {
 
 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;
 
@@ -239,11 +236,12 @@ 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() {
 }
 
+#endif // PWL_HAVE_DECL_SETITIMER
+
 unsigned int PWL::Init::count = 0;
diff --git a/Watchdog/src/Watchdog.inlines.hh b/Watchdog/src/Watchdog.inlines.hh
index 016926d..80258dd 100644
--- a/Watchdog/src/Watchdog.inlines.hh
+++ b/Watchdog/src/Watchdog.inlines.hh
@@ -71,6 +71,24 @@ Watchdog::reschedule() {
   set_timer(reschedule_time);
 }
 
+inline
+Init::Init() {
+  // Only when the first Init object is constructed...
+  if (count++ == 0) {
+    // ... the library is initialized.
+    Watchdog::initialize();
+  }
+}
+
+inline
+Init::~Init() {
+  // Only when the last Init object is destroyed...
+  if (--count == 0) {
+    // ... the library is finalized.
+    Watchdog::finalize();
+  }
+}
+
 #else // !PWL_HAVE_DECL_SETITIMER
 
 template <typename Flag_Base, typename Flag>
@@ -91,14 +109,11 @@ inline
 Watchdog::~Watchdog() {
 }
 
-#endif // !PWL_HAVE_DECL_SETITIMER
-
 inline
 Init::Init() {
   // Only when the first Init object is constructed...
   if (count++ == 0) {
     // ... the library is initialized.
-    Watchdog::initialize();
   }
 }
 
@@ -107,10 +122,11 @@ Init::~Init() {
   // Only when the last Init object is destroyed...
   if (--count == 0) {
     // ... the library is finalized.
-    Watchdog::finalize();
   }
 }
 
+#endif // !PWL_HAVE_DECL_SETITIMER
+
 } // namespace Parma_Watchdog_Library
 
 #endif // !defined(PWL_Watchdog_inlines_hh)