RFC: fenv.h

David Schultz das at FreeBSD.ORG
Wed Jun 2 07:33:08 GMT 2004


The following patch adds the fenv.h header to FreeBSD.  I would
appreciate any reviews of these changes.  Descriptions of the various
functions are included in the patch in the form of some manpages.
Barring any problems that arise, I would like to commit this over
the weekend.

	  http://www.freebsd.org/~das/patches/fenv.diff

Implementations are provided for all supported architectures, with
caveats noted below.  Perhaps the biggest caveat is that the
programmer cannot count on the contents of the floating-point
environment without compiler support, which gcc currently lacks.
However, program behavior is reasonable with `gcc -O0', and often even
with `gcc -O1'.  At least we'll be ready when gcc evolves.
The only other significant problem is that unmasked exceptions
(which aren't standard anyway) are handled inconsistently among
architectures.

alpha:
- All the standard features (i.e. not unmasked exceptions) appear to work.
- Much of the floating-point support on the Alpha platform is emulated
  by the kernel.  I found and fixed some kernel bugs during
  development, but the kernel still doesn't deliver SIGFPEs for
  unmasked exceptions generated by SUI-format instructions.
  The lack of response from alpha@ was disappointing, but I'd like to
  thank marcel@ for testing some changes on his hardware.

amd64:
- Everything appears to work, except as noted.
- The kernel does not set the default FP environment appropriately for
  new processes.  Proposed solution to amd64 at .
- When a signal handler is invoked for an SSE trap (but not an x87
  trap ???), it is not possible to safely return from the handler.
  (Strictly speaking this is allowed in POSIX, but it makes it
  impossible to write a portable and useful SIGFPE handler.)

arm:
- I made an effort to get this right.  However, there will certainly
  be bugs.  I have poor documentation and no access to ARM hardware,
  and I couldn't even get a cross-toolchain to build.

ia64:
- Everything appears to work.
- The same caveat about signal handlers for amd64 applies for all FP
  traps on ia64.

i386:
- Everything appears to work.

powerpc:
- All the standard features appear to work.
- There is no powerpc machine in the main FreeBSD cluster available
  for testing.  I did the best I could on a machine running Darwin

sparc64:
- Everything appears to work.


More information about the freebsd-standards mailing list