int __fesetexceptflag (const fexcept_t *flagp, int excepts) { unsigned long old_spefscr, spefscr; fexcept_t flag; int excepts_spe = __fexcepts_to_spe (excepts); /* Get the current state. */ old_spefscr = fegetenv_register (); /* Ignore exceptions not listed in 'excepts'. */ flag = *flagp & excepts_spe; /* Replace the exception status */ spefscr = (old_spefscr & ~excepts_spe) | flag; /* Store the new status word (along with the rest of the environment). */ fesetenv_register (spefscr); /* If the state of the "invalid" or "underflow" flag has changed, inform the kernel. */ if (((spefscr ^ old_spefscr) & (SPEFSCR_FINVS | SPEFSCR_FUNFS)) != 0) __fe_note_change (); /* Success. */ return 0; }
int __feclearexcept (int excepts) { unsigned int fpescr; int excepts_spe = __fexcepts_to_spe (excepts); /* Get the current state. */ fpescr = fegetenv_register (); /* Clear the relevant bits. */ fpescr &= ~excepts_spe; /* Put the new state in effect. */ fesetenv_register (fpescr); /* Let the kernel know if the "invalid" or "underflow" bit was cleared. */ if (excepts & (FE_INVALID | FE_UNDERFLOW)) __fe_note_change (); /* Success. */ return 0; }