X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f Sender: rich AT phekda DOT freeserve DOT co DOT uk Message-ID: <3FAE0A56.7E603E9F@phekda.freeserve.co.uk> Date: Sun, 09 Nov 2003 09:35:18 +0000 From: Richard Dawe X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.23 i586) X-Accept-Language: de,fr MIME-Version: 1.0 To: DJGPP workers Subject: Re: C99 Functions Under Development and Checkout Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Hello. KB Williams wrote: > Rich Dawe: > > In a message dated 11/8/2003 7:09:46 AM Eastern Standard Time, > rich AT phekda DOT freeserve DOT co DOT uk writes: > > > Do the maths functions use get_math_errhandling, to get the value of > > math_errhandling? Or do they just read math_errhandling? If they look > > at math_errhandling, then get_math_errhandling is useless. The library > > user could modify math_errhandling, making the value returned by > > get_math_errhandling completely bogus. > > Functions get_math_errhandling() and set_math_errhandling() are meant > to be used by external programs. For example, the test programs > in the cygnus subdirectory will probably call set_math_errhandling() > with MATH_ERRNO as a parameter. > > The only way to retrieve the original value of math_errhandling is through > get_math_errhandling(). The global variable math_errhandling can be set > exactly once during the life of the program. Thereafter, it cannot be > reset; any attempt to do so at runtime either by resetting the global > variable or by calling set_math_errhandling() again will fail. It won't fail. The change will just be ignored. E.g.: some_maths_function(); math_errhandling = MATH_ERRNO; > The math functions use the other two functions, raise_except() > and set_errno(). Each call to these functions will freshen the original > value of math_errhandling. > > The code tells the story. It should have been attached to your email. It was. I read it. You missed my point. My point was that by making math_errhandling a macro that calls a function to return the math error handling method(s), you stop the user from being able to modify math_errhandling. I.e.: the following code will not compile: some_maths_function(); math_errhandling = MATH_ERRNO; Summary: Advantages of using a macro to call the get function: * User cannot modify math_errhandling. * The code is clearer (no copying of local setting to global setting). Bye, Rich =] -- Richard Dawe [ http://www.phekda.freeserve.co.uk/richdawe/ ] "You can't evaluate a man by logic alone." -- McCoy, "I, Mudd", Star Trek