Mail Archives: djgpp-workers/2003/11/09/05:09:41
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
- Raw text -