@@ -251,41 +251,29 @@ static inline int raiseExcept(int excepts) {
251
251
// ensure that the writes by the exception handler are maintained
252
252
// when raising the next exception.
253
253
254
- if (statusValue & internal::ExceptionFlags::Invalid ) {
254
+ auto raiseHelper = []( uint16_t singleExceptFlag ) {
255
255
internal::X87StateDescriptor state;
256
256
internal::getX87StateDescriptor (state);
257
- state.StatusWord |= internal::ExceptionFlags::Invalid;
258
- internal::writeX87StateDescriptor (state);
259
- internal::fwait ();
260
- }
261
- if (statusValue & internal::ExceptionFlags::DivByZero) {
262
- internal::X87StateDescriptor state;
263
- internal::getX87StateDescriptor (state);
264
- state.StatusWord |= internal::ExceptionFlags::DivByZero;
265
- internal::writeX87StateDescriptor (state);
266
- internal::fwait ();
267
- }
268
- if (statusValue & internal::ExceptionFlags::Overflow) {
269
- internal::X87StateDescriptor state;
270
- internal::getX87StateDescriptor (state);
271
- state.StatusWord |= internal::ExceptionFlags::Overflow;
272
- internal::writeX87StateDescriptor (state);
273
- internal::fwait ();
274
- }
275
- if (statusValue & internal::ExceptionFlags::Underflow) {
276
- internal::X87StateDescriptor state;
277
- internal::getX87StateDescriptor (state);
278
- state.StatusWord |= internal::ExceptionFlags::Underflow;
279
- internal::writeX87StateDescriptor (state);
280
- internal::fwait ();
281
- }
282
- if (statusValue & internal::ExceptionFlags::Inexact) {
283
- internal::X87StateDescriptor state;
284
- internal::getX87StateDescriptor (state);
285
- state.StatusWord |= internal::ExceptionFlags::Inexact;
257
+ state.StatusWord |= singleExceptFlag;
286
258
internal::writeX87StateDescriptor (state);
287
259
internal::fwait ();
260
+ };
261
+
262
+ if (statusValue & internal::ExceptionFlags::Invalid)
263
+ raiseHelper (internal::ExceptionFlags::Invalid);
264
+ if (statusValue & internal::ExceptionFlags::DivByZero)
265
+ raiseHelper (internal::ExceptionFlags::DivByZero);
266
+ if (statusValue & internal::ExceptionFlags::Overflow)
267
+ raiseHelper (internal::ExceptionFlags::Overflow);
268
+ if (statusValue & internal::ExceptionFlags::Underflow)
269
+ raiseHelper (internal::ExceptionFlags::Underflow);
270
+ if (statusValue & internal::ExceptionFlags::Inexact)
271
+ raiseHelper (internal::ExceptionFlags::Inexact);
272
+ #ifdef __FE_DENORM
273
+ if (statusValue & internal::ExceptionFlags::Denormal) {
274
+ raiseHelper (internal::ExceptionFlags::Denormal);
288
275
}
276
+ #endif // __FE_DENORM
289
277
290
278
// There is no special synchronization scheme available to
291
279
// raise SEE exceptions. So, we will ignore that for now.
0 commit comments