delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2003/09/02/14:24:41

Date: Tue, 02 Sep 2003 13:24:54 -0500
From: Eric Rudd <rudd AT cyberoptics DOT com>
Subject: Re: Arithmetic Exceptions in C99
In-reply-to: <2593-Sat30Aug2003120721+0300-eliz@elta.co.il>
To: djgpp-workers AT delorie DOT com
Message-id: <3F54E076.8030807@cyberoptics.com>
Organization: CyberOptics
MIME-version: 1.0
X-Accept-Language: en,pdf
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.3) Gecko/20030312
References: <200308292046 DOT h7TKkAEJ012781 AT speedy DOT ludd DOT luth DOT se>
<3F4FC482 DOT A71D96A1 AT phekda DOT freeserve DOT co DOT uk> <3F4FCD2D DOT 5070204 AT cyberoptics DOT com>
<2593-Sat30Aug2003120721+0300-eliz AT elta DOT co DOT il>
X-MailScanner-Information: Please contact the ISP for more information
X-MailScanner: Found to be clean
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Eli Zaretskii wrote:

>We could implement the exceptions bitmap as a special word that is
>physically different from the x87 status register.  The functions that
>return the exceptions info could then look at that word and also at
>the x87 status word.
>
>Would that be okay?
>  
>
I don't think that the C standard cares whether we implement the 
exceptions as a separate word, or as part of the x87 status register, as 
long as the external behavior is consistent with the standard.  I can 
think of several criteria to evaluate such a technique: conformance with 
the C99 standard, compability with existing code, amount of work 
required to implement the technique, and general usefulness of the 
technique.

Your proposed technique would indeed achieve compatibility with existing 
code, but let's hear from KB Williams on how difficult it would be to 
implement.  It may be easy, since it appears that the change would be 
confined to the fraiseexcept() routine.  If it is indeed the case that 
the DJGPP startup code masks all the FP exceptions, perhaps it would be 
easier to use the x87 status word for these functions.  My worry about 
that was that (if I recall correctly) older startup code didn't mask all 
the exceptions.

In some ways, Annex F makes it easy for the library programmer, since 
one can often dispense with the argument tests and simply depend on the 
processor to issue the appropriate exceptions.  For instance, if the 
routine is attempting to compute asin(2.0), somewhere one probably 
computes sqrt(1. - x*x) = sqrt(-3.), which sets a floating-point 
exception.  Unfortunately, reliance on the built-in hardware mechanisms 
does not set errno properly.  C99 makes setting errno optional.

Whether Annex F make good mathematical sense is another story.

-Eric Rudd
rudd AT cyberoptics DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019