Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 17:29:04 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Kris Kennaway <kris@obsecurity.org>
Cc:        sparc@FreeBSD.ORG, <current@FreeBSD.ORG>
Subject:   Re: fpsetmask on sparc64
Message-ID:  <20030112165423.K5527-100000@gamplex.bde.org>
In-Reply-To: <20030112031626.GA15783@rot13.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 11 Jan 2003, Kris Kennaway wrote:

> fpsetmask is not defined in <floatingpoint.h> or
> <machine/floatingpoint.h> on sparc64 (it is on i386):
>
> /usr/include/machine/floatingpoint.h:#define    fpsetmask(m)    ((fp_except_t)      \
> /usr/include/ieeefp.h:extern fp_except_t fpsetmask(fp_except_t);
> /usr/include/floatingpoint.h:#define    fpsetmask(m)    ((fp_except_t)
>
> This appears to cause the following port failures/warnings:
>
> amphetamine-0.8.10.log:src/Main.cpp:79: `fpsetmask' undeclared (first use this function)
> ...
> Is this an omission, or are the ports wrong?

First answer:
This is a bug in the ports.  The non-i386 arches are apparently including
<machine/floatingpoint.h> instead of the documented interface <ieeefp.h>.
I think the ports are only meddling the FP mask to hide their FP errors
when running under FreeBSD-3.x and earlier anyway.  They would have
to use <machine/floatingpoint.h> to suppport FreeBSD-2.x since <ieeefp.h>
didn't exist until FreeBSD-3.1.  FreeBSD-4.0 and later hide FP errors
by default.

Second answer:
Ports should use the C99 interfaces fe{get,set}*() from <fenv.h>, and then
only if C99 is supported.  There might be problems with this too:
- C99 isn't supported yet.
- C99 doesn't have fesetmask().  This is partly because it would be
  very unportable.  It is not an IEEE FP feature.  C99 only has
  fesetenv(FE_DFL_ENV) to recover from any meddling with the FP
  environment.
- Non-default FP environments should only be used in small sections
  of code, since large parts of libraries, etc. are entitled to assume
  that the environment is the default.  So changing the FP mask to a
  non-default value at program startup time would give undefined
  behaviour if it were possible.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




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