RE: compiling newlib

Christophe MONAT via Newlib <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <PR3PR10MB3850AE3EE01A35C50B548F83E0570@PR3PR10MB3850.EURPRD10.PROD.OUTLOOK.COM>
Paul,

+ #include <errno.h>
probably would have avoided the trouble to add newlib-specific code.

It looks also that errno differs between glibc and newlib.

From my memory glibc has a quite thorough libm test suite checking among other things the edge cases, I don't know what exist in this domain for newlib.

Regards,
--C


-----Original Message-----
From: Newlib <[email protected]> On Behalf Of Paul Zimmermann
Sent: Tuesday, August 25, 2020 8:42 AM
To: Jeff Johnston <[email protected]>
Cc: [email protected]
Subject: Re: compiling newlib

thank you Jeff for your answer.

In return I found I believe an issue with newlib's tgammaf function, for input -0, where it gives +inf instead of -inf:

$ cat e.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#ifdef NEWLIB
/* without this, newlib says: undefined reference to `__errno' */ int errno;
int* __errno () { return &errno; }
#endif

int
main (int argc, char *argv[])
{
  float x = -0.0;
  float y = tgammaf (x);
  printf ("x=%.9e y=%.9e\n", x, y);
  return 0;
}

With glibc :

$ gcc e.c -lm
$ ./a.out
x=-0.000000000e+00 y=-inf

With NEWLIB :

$ gcc -DNEWLIB e.c /localdisk/zimmerma/newlib/libm/libm.a
$ ./a.out
x=-0.000000000e+00 y=inf

Best regards,
Paul
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.