standards/56906: Several math(3) functions fail to set errno on a domain error

Stefan Farfeleder stefan at
Tue Sep 16 06:08:12 PDT 2003

On Tue, Sep 16, 2003 at 11:42:44AM +1000, Bruce Evans wrote:
> On Tue, 16 Sep 2003, Stefan Farfeleder wrote:
> > >Synopsis:       Several math(3) functions fail to set errno on a domain error
> This is intentional.
> > >Description:
> > ISO C90 says that errno must be set to EDOM if a domain error occurs.
> As you probably know, C99 doesn't require this.  FreeBSD, or at least I,
> decided not to support C90's relatively feeble and broken specification
> of floating point and wait for C99 to get it right.  The wait is long
> over and the nonstandardness is now a little different.

Hm, having a conforming C90 environment would be nice despite C99's
existence as older compliant applications may depend on the former
behaviour and don't become magically C99 conformant.  Is there a chance
to have a separated C90 compliant libm?

Anyway, here's a patch to give C99 application at least the possibility
to notice that errno doesn't get set for these functions.  Because we
don't have <fenv.h> to access the floating point status flags, I'm
setting math_errhandling to 0.

-------------- next part --------------
Index: src/lib/msun/src/math.h
RCS file: /usr/home/ncvs/src/lib/msun/src/math.h,v
retrieving revision 1.26
diff -u -r1.26 math.h
--- src/lib/msun/src/math.h	22 May 2003 17:07:57 -0000	1.26
+++ src/lib/msun/src/math.h	16 Sep 2003 12:31:42 -0000
@@ -339,4 +339,10 @@
 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
+#if __ISO_C_VISIBLE >= 1999
+#define	MATH_ERRNO	1
+#define	math_errhandling	0
 #endif /* !_MATH_H_ */

More information about the freebsd-standards mailing list