Package: ppl / 0.10.2-8

7ba6445b1c5adb835e27d2f005779d4343721d21 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
From 7ba6445b1c5adb835e27d2f005779d4343721d21 Mon Sep 17 00:00:00 2001
From: Roberto Bagnara <bagnara@cs.unipr.it>
Date: Mon, 15 Feb 2010 14:50:19 +0100
Subject: [PATCH] Improve portability to systems that do not (fully) support Posix signal handling.

---
 Watchdog/configure.ac      |    1 +
 Watchdog/pwl-config.sed    |    4 ++-
 Watchdog/tests/pwl_test.cc |   62 +++++++++++++++++++++++++++++++++++++++----
 configure.ac               |    1 +
 ppl-config.sed             |    4 +++
 tests/ppl_test.cc          |   62 +++++++++++++++++++++++++++++++++++++++----
 6 files changed, 121 insertions(+), 13 deletions(-)

diff --git a/Watchdog/configure.ac b/Watchdog/configure.ac
index b831583..4e7b1a8 100644
--- a/Watchdog/configure.ac
+++ b/Watchdog/configure.ac
@@ -371,6 +371,7 @@ then
 
   # Checks for the availability of C library functions in C++.
   AC_CHECK_DECLS([getenv], , , [#include <cstdlib>])
+  AC_CHECK_DECLS([sigaction], , , [#include <csignal>])
 
   # Checks for typedefs, structures, and compiler characteristics.
   AC_CHECK_TYPES([siginfo_t], [], [], [[
diff --git a/Watchdog/pwl-config.sed b/Watchdog/pwl-config.sed
index 960a73e..15a0d31 100644
--- a/Watchdog/pwl-config.sed
+++ b/Watchdog/pwl-config.sed
@@ -1,9 +1,11 @@
 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_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
 s/\([^A-Z_]\)HAVE_MEMORY_H/\1PWL_HAVE_MEMORY_H/g
-s/\([^A-Z_]\)HAVE_SETITIMER_H/\1PWL_HAVE_SETITIMER_H/g
+s/\([^A-Z_]\)HAVE_SETITIMER/\1PWL_HAVE_SETITIMER/g
+s/\([^A-Z_]\)HAVE_SIGINFO_T/\1PWL_HAVE_SIGINFO_T/g
 s/\([^A-Z_]\)HAVE_STDINT_H/\1PWL_HAVE_STDINT_H/g
 s/\([^A-Z_]\)HAVE_STDLIB_H/\1PWL_HAVE_STDLIB_H/g
 s/\([^A-Z_]\)HAVE_STRINGS_H/\1PWL_HAVE_STRINGS_H/g
diff --git a/Watchdog/tests/pwl_test.cc b/Watchdog/tests/pwl_test.cc
index 41ab632..f4b828c 100644
--- a/Watchdog/tests/pwl_test.cc
+++ b/Watchdog/tests/pwl_test.cc
@@ -43,9 +43,12 @@ uncaught_exception_handler() {
   exit(1);
 }
 
-#ifdef HAVE_SIGINFO_T
+#ifdef PWL_HAVE_DECL_SIGACTION
+
+#if defined(PWL_HAVE_SIGINFO_T) && defined(SA_SIGINFO)
+
 void
-fpe_handler(int sig, siginfo_t* sip, void*) {
+fpe_sigaction(int sig, siginfo_t* sip, void*) {
   if (sig != SIGFPE) {
     std::cerr << "fpe_handler called on signal different from SIGFPE"
 	      << std::endl;
@@ -113,7 +116,49 @@ fpe_handler(int sig, siginfo_t* sip, void*) {
   }
   exit(1);
 }
-#endif // defined(HAVE_SIGINFO_T)
+
+#else // !defined(PWL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+
+void
+fpe_handler(int sig) {
+  if (sig != SIGFPE) {
+    std::cerr << "fpe_handler called on signal different from SIGFPE"
+	      << std::endl;
+    exit(1);
+  }
+  std::cerr << "SIGFPE caught"
+            << std::endl;
+#if defined(PWL_HAVE_FENV_H)
+    std::cerr << "Inquire with fetestexcept(): ";
+#ifdef FE_INEXACT
+    if (fetestexcept(FE_INEXACT))
+      std::cerr << "FE_INEXACT ";
+#endif
+#ifdef FE_DIVBYZERO
+    if (fetestexcept(FE_DIVBYZERO))
+      std::cerr << "FE_DIVBYZERO ";
+#endif
+#ifdef FE_UNDERFLOW
+    if (fetestexcept(FE_UNDERFLOW))
+      std::cerr << "FE_UNDERFLOW ";
+#endif
+#ifdef FE_OVERFLOW
+    if (fetestexcept(FE_OVERFLOW))
+      std::cerr << "FE_OVERFLOW ";
+#endif
+#if FE_INVALID
+    if (fetestexcept(FE_INVALID))
+      std::cerr << "FE_INVALID ";
+#endif
+    std::cerr << std::endl;
+#endif
+  }
+  exit(1);
+}
+
+#endif // !defined(PWL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+
+#endif // defined(PWL_HAVE_DECL_SIGACTION)
 
 } // namespace
 
@@ -121,19 +166,24 @@ namespace Parma_Watchdog_Library {
 
 namespace Test {
 
-#ifdef HAVE_SIGINFO_T
 void
 set_handlers() {
+#ifdef PWL_HAVE_DECL_SIGACTION
   struct sigaction action;
-  action.sa_sigaction = fpe_handler;
   sigemptyset(&action.sa_mask);
+#if defined(PWL_HAVE_SIGINFO_T) && defined(SA_SIGINFO)
+  action.sa_sigaction = fpe_sigaction;
   action.sa_flags = SA_SIGINFO;
+#else // !defined(PWL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+  action.sa_handler = fpe_handler;
+  action.sa_flags = 0;
+#endif // !defined(PWL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
   if (sigaction(SIGFPE, &action, NULL) != 0) {
     std::cerr << "sigaction() failed"
 	      << std::endl;
     abort();
   }
-#endif // defined(HAVE_SIGINFO_T)
+#endif // defined(PWL_HAVE_DECL_SIGACTION)
 
   std::set_unexpected(unexpected_exception_handler);
   std::set_terminate(uncaught_exception_handler);
diff --git a/configure.ac b/configure.ac
index 465f530..d67f0ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1472,6 +1472,7 @@ AC_CHECK_DECLS([getrusage],
 # include <sys/resource.h>
 #endif
 ])
+AC_CHECK_DECLS([sigaction], , , [#include <csignal>])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_CHECK_TYPES([timeval])
diff --git a/ppl-config.sed b/ppl-config.sed
index 2d74bb6..95f8ae1 100644
--- a/ppl-config.sed
+++ b/ppl-config.sed
@@ -10,6 +10,7 @@ s/\([^A-Z_]\)HAVE_DECL_RLIMIT_AS/\1PPL_HAVE_DECL_RLIMIT_AS/g
 s/\([^A-Z_]\)HAVE_DECL_RLIMIT_DATA/\1PPL_HAVE_DECL_RLIMIT_DATA/g
 s/\([^A-Z_]\)HAVE_DECL_RLIMIT_RSS/\1PPL_HAVE_DECL_RLIMIT_RSS/g
 s/\([^A-Z_]\)HAVE_DECL_RLIMIT_VMEM/\1PPL_HAVE_DECL_RLIMIT_VMEM/g
+s/\([^A-Z_]\)HAVE_DECL_SIGACTION/\1PPL_HAVE_DECL_SIGACTION/g
 s/\([^A-Z_]\)HAVE_DECL_STRTOD/\1PPL_HAVE_DECL_STRTOD/g
 s/\([^A-Z_]\)HAVE_DECL_STRT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cc
index 3c5caef..c0ac87f 100644
--- a/tests/ppl_test.cc
+++ b/tests/ppl_test.cc
@@ -43,9 +43,12 @@ uncaught_exception_handler() {
   exit(1);
 }
 
-#ifdef HAVE_SIGINFO_T
+#ifdef PPL_HAVE_DECL_SIGACTION
+
+#if defined(PPL_HAVE_SIGINFO_T) && defined(SA_SIGINFO)
+
 void
-fpe_handler(int sig, siginfo_t* sip, void*) {
+fpe_sigaction(int sig, siginfo_t* sip, void*) {
   if (sig != SIGFPE) {
     std::cerr << "fpe_handler called on signal different from SIGFPE"
 	      << std::endl;
@@ -113,7 +116,49 @@ fpe_handler(int sig, siginfo_t* sip, void*) {
   }
   exit(1);
 }
-#endif // defined(HAVE_SIGINFO_T)
+
+#else // !defined(PPL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+
+void
+fpe_handler(int sig) {
+  if (sig != SIGFPE) {
+    std::cerr << "fpe_handler called on signal different from SIGFPE"
+	      << std::endl;
+    exit(1);
+  }
+  std::cerr << "SIGFPE caught"
+            << std::endl;
+#if defined(PWL_HAVE_FENV_H)
+    std::cerr << "Inquire with fetestexcept(): ";
+#ifdef FE_INEXACT
+    if (fetestexcept(FE_INEXACT))
+      std::cerr << "FE_INEXACT ";
+#endif
+#ifdef FE_DIVBYZERO
+    if (fetestexcept(FE_DIVBYZERO))
+      std::cerr << "FE_DIVBYZERO ";
+#endif
+#ifdef FE_UNDERFLOW
+    if (fetestexcept(FE_UNDERFLOW))
+      std::cerr << "FE_UNDERFLOW ";
+#endif
+#ifdef FE_OVERFLOW
+    if (fetestexcept(FE_OVERFLOW))
+      std::cerr << "FE_OVERFLOW ";
+#endif
+#if FE_INVALID
+    if (fetestexcept(FE_INVALID))
+      std::cerr << "FE_INVALID ";
+#endif
+    std::cerr << std::endl;
+#endif
+  }
+  exit(1);
+}
+
+#endif // !defined(PPL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+
+#endif // defined(PPL_HAVE_DECL_SIGACTION)
 
 } // namespace
 
@@ -123,17 +168,22 @@ namespace Test {
 
 void
 set_handlers() {
-#ifdef HAVE_SIGINFO_T
+#ifdef PPL_HAVE_DECL_SIGACTION
   struct sigaction action;
-  action.sa_sigaction = fpe_handler;
   sigemptyset(&action.sa_mask);
+#if defined(PPL_HAVE_SIGINFO_T) && defined(SA_SIGINFO)
+  action.sa_sigaction = fpe_sigaction;
   action.sa_flags = SA_SIGINFO;
+#else // !defined(PPL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
+  action.sa_handler = fpe_handler;
+  action.sa_flags = 0;
+#endif // !defined(PPL_HAVE_SIGINFO_T) || !defined(SA_SIGINFO)
   if (sigaction(SIGFPE, &action, NULL) != 0) {
     std::cerr << "sigaction() failed"
 	      << std::endl;
     abort();
   }
-#endif // defined(HAVE_SIGINFO_T)
+#endif // defined(PPL_HAVE_DECL_SIGACTION)
 
   std::set_unexpected(unexpected_exception_handler);
   std::set_terminate(uncaught_exception_handler);
-- 
1.6.0.6