MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / set

Function set

src/OSspecific/POSIX/signals/sigFpe.C:152–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

150// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
151
152void Foam::sigFpe::set(const bool verbose)
153{
154 if (oldAction_.sa_handler)
155 {
156 FatalErrorInFunction
157 << "Cannot call sigFpe::set() more than once"
158 << abort(FatalError);
159 }
160
161 if (env("FOAM_SIGFPE"))
162 {
163 bool supported = false;
164
165 #ifdef LINUX_GNUC
166 supported = true;
167
168 feenableexcept
169 (
170 FE_DIVBYZERO
171 | FE_INVALID
172 | FE_OVERFLOW
173 );
174
175 struct sigaction newAction;
176 newAction.sa_handler = sigHandler;
177 newAction.sa_flags = SA_NODEFER;
178 sigemptyset(&newAction.sa_mask);
179 if (sigaction(SIGFPE, &newAction, &oldAction_) < 0)
180 {
181 FatalErrorInFunction
182 << "Cannot set SIGFPE trapping"
183 << abort(FatalError);
184 }
185
186
187 #elif defined(sgiN32) || defined(sgiN32Gcc)
188 supported = true;
189
190 sigfpe_[_DIVZERO].abort=1;
191 sigfpe_[_OVERFL].abort=1;
192 sigfpe_[_INVALID].abort=1;
193
194 sigfpe_[_DIVZERO].trace=1;
195 sigfpe_[_OVERFL].trace=1;
196 sigfpe_[_INVALID].trace=1;
197
198 handle_sigfpes
199 (
200 _ON,
201 _EN_DIVZERO
202 | _EN_INVALID
203 | _EN_OVERFL,
204 0,
205 _ABORT_ON_ERROR,
206 nullptr
207 );
208 #endif
209

Callers

nothing calls this directly

Calls 3

envFunction · 0.85
sigactionClass · 0.70
abortFunction · 0.50

Tested by

no test coverage detected