This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Ping Re: Make strtod respect the rounding mode (bug 14518)


On Tue, 11 Sep 2012, Richard Henderson wrote:

> On 2012-09-11 14:25, Joseph S. Myers wrote:
> > +/* Internal type for floating-point rounding modes.  */
> > +typedef enum
> > +{
> > +  round_downward,
> > +  round_tonearest,
> > +  round_towardzero,
> > +  round_upward
> > +} rounding_mode_t;
> 
> Is there a good reason why you're defining a new enumeration instead
> of letting the arch-specific header either (1) include bits/fenv.h,
> or (2) define some other names that are bit-compatible with what comes
> out of the fpu?

The idea is to have the same set of *names* present in the code 
everywhere, so that code using these values doesn't need to be conditioned 
on which are available on a particular architecture.  This includes 
setting the mode to round_tonearest in cases where there is no rounding 
mode support for an architecture and so no FE_* macros are defined at all.

There's no particular need for the *values* to be 
architecture-independent; it just keeps the architecture-independent part 
of the code simplest, and the compiler can optimize away the use of the 
internal enumeration (and the abort () calls, and any cases that are 
unreachable for a given architecture because it doesn't support the 
relevant rounding modes).

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]