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

Howland, Craig D. - US via newlib newlib@sourceware.org
Thu Aug 8 04:12:00 GMT 2019


I think I have identified all of the individual places where return values should be 0 as Joseph Myers noted in general, as well as some other small items.
Craig

> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Joel Sherrill <joel@rtems.org>
> Sent: Wednesday, August 7, 2019 12:14 PM
> To: newlib@sourceware.org
> Cc: Joel Sherrill
> Subject: [PATCH v4 2/3] Add default implementation of fenv.h and all methods
>
>         The default implementation of the fenv.h methods return
>         -EOPNOTSUPP.
[typo:]  -ENOTSUP
>
>         The intention of the new fenv.h is that it be portable
>         and that architectures provide their own implementation
>         of sys/fenv.h.
> ---
>  ...

> diff --git a/newlib/libm/fenv/feclearexcept.c b/newlib/libm/fenv/feclearexcept.c
> new file mode 100644
> +int feclearexcept(int excepts)
> +{
> +  return -ENOTSUP;
return (excepts  ?  -ENOTSUP : 0);
> ...

> diff --git a/newlib/libm/fenv/fegetround.c b/newlib/libm/fenv/fegetround.c
> ...
> +FUNCTION
> +<<fegetround>>---get current rounding direction
> +
> +INDEX
> +       feclearexcept
[typo, not feclearexcept:] fegetround
> +SYNOPSIS
> +       #include <fenv.h>
> +       int fegetround(void);
> +
> +       Link with -lm.
> +
> +DESCRIPTION
> +This method returns the current rounding direction.
> +
> +RETURNS
> +This method returns the rounding direction. If the current rounding
> +direction cannot be determined, then a negative value is returned.
[Small edit, pointing out macro value needed:]
This method returns the rounding direction, corresponding to the value
of the respective rounding macro. If the current rounding
direction cannot be determined, then a negative value is returned.
> ...

> diff --git a/newlib/libm/fenv/feraiseexcept.c b/newlib/libm/fenv/feraiseexcept.c
> ...
> +int feraiseexcept(int excepts)
> +{
> +  return -ENOTSUP;
return (excepts  ?  -ENOTSUP : 0);
> +}
> ...

> diff --git a/newlib/libm/fenv/fesetenv.c b/newlib/libm/fenv/fesetenv.c
> ...
> +SYNOPSIS
> +       #include <fenv.h>
> +       int fesetenv(const fenv_t *[<envp>]);
> +
> +       Link with -lm.
> +
> +DESCRIPTION
> +This method attempts to establish the floating-point environment
> +pointed to by <[envp]>. The argument [<envp>] must point to a
> +floating-point environment obtained via <<fegetenv>> or <<feholdexcept>>
> +or a floating-point environment macro such as <<FE_DFL_ENV>>.
[Add:]
It only sets the states of the flags as recorded in its argument, and
does not actually raise the associated floating-point exceptions.
> ...

> diff --git a/newlib/libm/fenv/fesetround.c b/newlib/libm/fenv/fesetround.c
> ...
> +SYNOPSIS
> +       #include <fenv.h>
> +       int fesetround(int <[round]>);
> +
> +       Link with -lm.
> +
> +DESCRIPTION
> +This method attempts to set the current rounding direction represented
> +by <[round]>.
[Add:]
<[round]> must be the value of one of the rounding-direction macros.
> ...

> diff --git a/newlib/libm/fenv/fetestexcept.c b/newlib/libm/fenv/fetestexcept.c
> ...
> +int fetestexcept(int excepts)
> +{
> +  return -ENOTSUP;
return 0;
> ...



More information about the Newlib mailing list