From owner-freebsd-standards@FreeBSD.ORG Wed Jun 2 00:33:08 2004 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F48816A4CE for ; Wed, 2 Jun 2004 00:33:08 -0700 (PDT) Received: from VARK.homeunix.com (ar59.lsanca2-4.27.98.47.lsanca2.dsl-verizon.net [4.27.98.47]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9C8C943D31 for ; Wed, 2 Jun 2004 00:33:07 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: from VARK.homeunix.com (localhost [127.0.0.1]) by VARK.homeunix.com (8.12.10/8.12.10) with ESMTP id i527WZkj006473 for ; Wed, 2 Jun 2004 00:32:35 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Received: (from das@localhost) by VARK.homeunix.com (8.12.11/8.12.10/Submit) id i527WZMg006472 for standards@FreeBSD.ORG; Wed, 2 Jun 2004 00:32:35 -0700 (PDT) (envelope-from das@FreeBSD.ORG) Date: Wed, 2 Jun 2004 00:32:35 -0700 From: David Schultz To: standards@FreeBSD.ORG Message-ID: <20040602073235.GA6457@VARK.homeunix.com> Mail-Followup-To: standards@FreeBSD.ORG Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: RFC: fenv.h X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Jun 2004 07:33:08 -0000 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@. - 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.