Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Jun 2008 15:13:08 -0400
From:      David Schultz <das@FreeBSD.ORG>
To:        standards@FreeBSD.ORG, amd64@FreeBSD.ORG
Subject:   saving FPU state in setjmp/longjmp
Message-ID:  <20080616191308.GA25248@zim.MIT.EDU>

next in thread | raw e-mail | index | archive | help
Are setjmp/longjmp supposed to save and restore the FPU control
word (rounding mode, exception masks, etc.)? They're specifically
not supposed to touch the status word, and one would think that
they shouldn't touch the control word either. From a pragmatic
point of view, most apps don't touch the FP control word anyway,
and the few that do are better off with fegetenv/fesetenv and friends.

A brief survey of setjmp/longjmp implementations indicates:
- freebsd/arm saves and restores the FPU status word, which is wrong.
- freebsd/i386 and freebsd/amd64 save and restore the x87 control word
  but not the SSE control word, which is half wrong in one direction or
  the other.
- freebsd/everything-else don't touch the FPU.
- linux doesn't touch the FPU.
- solaris doesn't touch the FPU.

So the real question is whether to remove the part of setjmp and
longjmp that fiddle with the x87 control word, or whether to
extend these functions to also save and restore the SSE control
word. The fact that SSE has been around for a while and nobody has
noticed the breakage suggests that either change should have
minimal impact on compatibility.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080616191308.GA25248>