[0/3] Add fenv.h generic infrastructure and default implementations

Message ID 1564614832-28017-1-git-send-email-joel@rtems.org
Headers show
Series
  • Add fenv.h generic infrastructure and default implementations
Related show

Message

Joel Sherrill July 31, 2019, 11:13 p.m.
This patch series adds generic infrastructure for fenv.h methods.
The file libc/include/fenv.h is the RISC-V one with no modifications.
The template/default libc/include/sys/fenv.h is derived from
the RISC-V but is just an arbitrary defintion of the required values.
I assumed the RISC-V implementation was correct per POSIX given
the high quality comments.

The first patch is to pick up some files which got regenerated
using the script Jeff emailed me. Not sure about those but I
included them. Note: When bootstrapping, don't forget I added
libm/fenv/Makefile.am.

Second patch is the core of the work.

Third patch is regenerated output from the files I touched.

I did test builds on sparc-rtems5 and riscv-rtems5. The sparc
got default versions of fenv methods and the riscv got its own.

When merged and the RISC-V folks are happy, I think their 
specific implementation of fenv.h can be removed.

The SPU implementation has incorrect signatures. I have no
idea about that and no SPU experience.

Interested to hear comments.

Thanks.

--joel


Joel Sherrill (3):
  Miscellaneous Makefile.in regenerated
  Add default implementation of fenv.h and all methods
  Regenerated files from fenv.h addition

 newlib/libc/include/fenv.h              |  42 +++
 newlib/libc/include/sys/fenv.h          |  47 +++
 newlib/libc/machine/msp430/Makefile.in  |   1 -
 newlib/libc/machine/riscv/Makefile.in   |  21 +-
 newlib/libc/search/Makefile.in          |  50 +--
 newlib/libm/Makefile.am                 |   6 +-
 newlib/libm/Makefile.in                 |  12 +-
 newlib/libm/configure                   |   3 +-
 newlib/libm/configure.in                |   2 +-
 newlib/libm/fenv/Makefile.am            |  36 ++
 newlib/libm/fenv/Makefile.in            | 628 ++++++++++++++++++++++++++++++++
 newlib/libm/fenv/fe_dfl_env.c           |  32 ++
 newlib/libm/fenv/feclearexcept.c        |  35 ++
 newlib/libm/fenv/fegetenv.c             |  35 ++
 newlib/libm/fenv/fegetexceptflag.c      |  36 ++
 newlib/libm/fenv/fegetround.c           |  36 ++
 newlib/libm/fenv/feholdexcept.c         |  36 ++
 newlib/libm/fenv/feraiseexcept.c        |  36 ++
 newlib/libm/fenv/fesetenv.c             |  36 ++
 newlib/libm/fenv/fesetexceptflag.c      |  36 ++
 newlib/libm/fenv/fesetround.c           |  36 ++
 newlib/libm/fenv/fetestexcept.c         |  36 ++
 newlib/libm/fenv/feupdateenv.c          |  36 ++
 newlib/libm/machine/aarch64/Makefile.in |   7 +-
 24 files changed, 1224 insertions(+), 57 deletions(-)
 create mode 100644 newlib/libc/include/fenv.h
 create mode 100644 newlib/libc/include/sys/fenv.h
 create mode 100644 newlib/libm/fenv/Makefile.am
 create mode 100644 newlib/libm/fenv/Makefile.in
 create mode 100644 newlib/libm/fenv/fe_dfl_env.c
 create mode 100644 newlib/libm/fenv/feclearexcept.c
 create mode 100644 newlib/libm/fenv/fegetenv.c
 create mode 100644 newlib/libm/fenv/fegetexceptflag.c
 create mode 100644 newlib/libm/fenv/fegetround.c
 create mode 100644 newlib/libm/fenv/feholdexcept.c
 create mode 100644 newlib/libm/fenv/feraiseexcept.c
 create mode 100644 newlib/libm/fenv/fesetenv.c
 create mode 100644 newlib/libm/fenv/fesetexceptflag.c
 create mode 100644 newlib/libm/fenv/fesetround.c
 create mode 100644 newlib/libm/fenv/fetestexcept.c
 create mode 100644 newlib/libm/fenv/feupdateenv.c

-- 
1.8.3.1

Comments

Joel Sherrill Aug. 1, 2019, 4:30 p.m. | #1
On Wed, Jul 31, 2019 at 6:58 PM Howland, Craig D. - US via newlib <
newlib@sourceware.org> wrote:

> > From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on

> behalf of Joel Sherrill <joel@rtems.org>

> > Sent: Wednesday, July 31, 2019 7:13 PM

> > To: newlib@sourceware.org

> > Cc: Joel Sherrill

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

> >

> >         The default implementation of the fenv.h methods return

> >         -EOPNOTSUPP.

> >

> >         The intention of the new fenv.h is that it be portable

> >         and that architectures provide their own implementation

> >         of sys/fenv.h.

> > ...

>

> The RISC-V-specific things would probably be best removed from

> libc/include/sys/fenv.h, leaving the original one in machine (unlike the

> primary fenv.h, which will no longer need to be under machine, as you

> noted.)  At a glance, using shorthand:

> -#define FE_TONEAREST_MM 0x00000004

> -#define FE_RMODE_MASK   0x7

> (Put another way, it should only have the bare-bones items defined in C

> and POSIX.)

>


Thanks. I hadn't reviewed it against C/POSIX yet and should have.

Do you think there should be comments about constants and types in the
default sys/fenv.h or just a blanket, this is the POSIX minimum that a port
has to define

I honestly was worried the structure of this work or the regenerated stuff
would be awfully broken. I am thrilled to get meaty technical comments.


>

> In general:

> +  return -EOPNOTSUPP;

>      ENOTSUP, not EOPNOTSUPP.  (The latter appears first, so I'm guessing

> you searched on NOTSUP and just copied the wrong one).

>

>

Oh. My grep was included OP and missed ENOTSUPP


> I'd suggest comments in the .c files to say they are non-functional

> placeholders, even though that should be obvious.

>


Gotcha. Will do.

>

> While the fenv/Makefile stuff does set up the chewout files, there is no

> man page stuff in the C files to get.

>


I was planning to add it.  Especially since there isn't much to add.

>

> libm/Makefile.am I think also needs:

> -libm.dvi: targetdep.tex math/stmp-def complex/stmp-def

> +libm.dvi: targetdep.tex math/stmp-def complex/stmp-def fenv/stmp-def

> +fenv/stmp-def: stmp-targetdep ; @true

> (It is set up poorly for maintenance, as ideally you'd want these to be

> automatic from the SUBDIRS line.)

>


Thanks. I had no idea on this.

I will fix all this and submit a v2.

>

> Craig
Christian Biesinger via Newlib Aug. 1, 2019, 5:30 p.m. | #2
> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Joel Sherrill <joel@rtems.org>

> Sent: Thursday, August 1, 2019 12:30 PM

> To: Howland, Craig D. - US

> Cc: newlib@sourceware.org

> Subject: Re: [PATCH 2/3] Add default implementation of fenv.h and all methods

>

> On Wed, Jul 31, 2019 at 6:58 PM Howland, Craig D. - US via newlib <

> newlib@sourceware.org> wrote:

> > The RISC-V-specific things would probably be best removed from

> > libc/include/sys/fenv.h, leaving the original one in machine (unlike the

> > primary fenv.h, which will no longer need to be under machine, as you

> > noted.)  At a glance, using shorthand:

> > -#define FE_TONEAREST_MM 0x00000004

> > -#define FE_RMODE_MASK   0x7

> > (Put another way, it should only have the bare-bones items defined in C

> > and POSIX.)

> >

>

> Thanks. I hadn't reviewed it against C/POSIX yet and should have.

>

> Do you think there should be comments about constants and types in the

> default sys/fenv.h or just a blanket, this is the POSIX minimum that a port

> has to define

>

> I honestly was worried the structure of this work or the regenerated stuff

> would be awfully broken. I am thrilled to get meaty technical comments.

>

     I did check the fenv.h and sys/fenv.h against POSIX.
     It certainly would be nice for sys/fenv.h to at a minimum point to POSIX 
for people to look up easily, and perhaps even better to also have a quick 
summary of what it wants, since it's intended as a template.
                Craig