[PATCH v3 2/3] Add default implementation of fenv.h and all methods

Howland, Craig D. - US via newlib newlib@sourceware.org
Wed Aug 7 13:27:00 GMT 2019


> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Corinna Vinschen <vinschen@redhat.com>
> Sent: Wednesday, August 7, 2019 4:36 AM
> To: Joel Sherrill
> Cc: newlib@sourceware.org
> Subject: Re: [PATCH v3 2/3] Add default implementation of fenv.h and all methods
>
> Hi Joel,
>
> On Aug  6 14:13, Joel Sherrill wrote:
> > [...]
> > +//#define FE_DIVBYZERO 0x00000001
> > +//#define FE_INEXACT   0x00000002
> > +//#define FE_INVALID   0x00000004
> > +//#define FE_OVERFLOW  0x00000008
> > +//#define FE_UNDERFLOW 0x00000010
> > +
> > +//#define FE_ALL_EXCEPT \
> > +          //(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
> > +#define FE_ALL_EXCEPT 0      /* NONE SUPPORTED IN PLACEHOLDER TEMPLATE */
> > +
> > +/*
> > + * The following macros are to be defined if the respective rounding
> > + * direction is supported by the implementation via the fegetround() and
> > + * fesetround() functions, each with a unique positive value.
> > + *
> > + *   FE_DOWNWARD
> > + *   FE_TONEAREST
> > + *   FE_TOWARDZERO
> > + *   FE_UPWARD
> > + *
> > + * Other implementation-specific rounding modes may be defined, and must start
> > + * with FE_ followed by a capital letter.
> > + */
> > +//#define FE_DOWNWARD        1
> > +//#define FE_TONEAREST       2
> > +//#define FE_TOWARDZERO      3
> > +//#define FE_UPWARD          4
> > +   
> > +/* 
> > + * The following typedefs are required. See the C and POSIX standards for
> > + * details:
> > + *
> > + *   fenv_t
> > + *   fexcept_t
> > + */
> > +typedef size_t fenv_t;     
> > +typedef size_t fexcept_t;
> 
> While these types are defined, the above macros are not.  Wouldn't
> it make sense to define all or nothing by default? 
> 
The standards require the types to be defined, but the individual macros
are to be defined only if supported by the implementation.  The
default implementation being provided supports nothing, only
returning error, so it is proper for them to not be defined.  But having
them there commented out to serve as a template seems to be a good thing.
>
>
> Thanks,
> Corinna
Craig    


More information about the Newlib mailing list