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: <3FACD2AA.8C08E9F4@phekda.freeserve.co.uk> Date: Sat, 08 Nov 2003 11:25:30 +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 AT delorie DOT com Subject: Re: C99 Functions Under Development and Checkout References: <1eb DOT 12bb4eae DOT 2cdd71ca AT aol DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com Hello. Kbwms AT aol DOT com wrote: > > Attached to this email is the C code that implements global variable > math_errhandling and associated macros. Cool, thanks! > Noted below are additions to math.h: > > #define MATH_ERRNO 1 > #define MATH_ERREXCEPT 2 > extern int math_errhandling; > > int get_math_errhandling (void); > int set_math_errhandling (int); > void set_errno (int); > int raise_except (int); This are functions internal to libc. They should be prefixed with "__", to avoid polluting the global namespace. They should also go in the not-ANSI, not-POSIX section of . I'd also suggest that set_errno and raise_except are renamed. These names are fairly generic and not obviously related to the maths module. How about these names instead? __get_math_errhandling __set_math_errhandling __math_set_errno __math_raise_exception The second two have math at the start of their names, because they're internal to the maths module. The first two actually manipulate math_errhandling, hence they have get/set at the start of their names. [snip] > Comments are welcome. Please look the code over and let me know whether > there is a gotcha lurking. 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. It would be better for math_errhandling to be a macro calling get_math_errhandling. That way the user cannot modify math_errhandling. Put something like this in : #define math_errhandling (__get_math_errhandling()) And modify errhndlr.c like this: [snip] > int math_errhandling; [snip] static int math_errhandling = 0; Then use math_errhandling instead of LocalMathErrHandling in the code. What do you think? Thanks, 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