why don't setjmp save MXCSR register and x87 control word?

Joseph Myers joseph@codesourcery.com
Wed Mar 17 21:08:32 GMT 2021


On Wed, 17 Mar 2021, Adhemerval Zanella via Libc-alpha wrote:

> Because afaik the C standard specify that any state of floating-point status 
> flag should *not* be saved:
> 
>   7.13 Nonlocal jumps <setjmp.h>
>   [...]
>   It does not include the state of the floating-point status flags, of open files, 
>   or of any other component of the abstract machine.

Indeed, the floating-point exception flags, rounding mode and any other 
such state are essentially thread-local variables, and should be handled 
just like such variables.  setjmp and longjmp don't save and restore 
thread-local or global variables, so they shouldn't save and restore 
floating-point flags or control modes either.

(In psABI terms, we invented the term "limited-access bits" to describe 
this state in the 32-bit Power Architecture ABI.)

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Libc-alpha mailing list