Re: Cygwin Perl and -Duselongdouble

2010-04-21 Thread Corinna Vinschen
On Apr 21 21:20, Reini Urban wrote:
> Yitzchak Scott-Thoennes schrieb:
> >On Thu, July 26, 2007 5:19 am, Corinna Vinschen wrote:
> >>On Jul 26 22:09, Sisyphus wrote:
> >>>I'd like to have a perl on Cygwin built with -Duselongdouble, so I tried
> >
> >>>*** You requested the use of long doubles but you do not seem to have
> >>>*** the following mathematical functions needed for long double support:
> >>>  *** sqrtl modfl frexpl
> >>
> >>Long double functions are not supported by newlib so far.  There are a
> >>couple of C99 functions not available in newlib.  Volunteers implementing
> >>these functions in a license compatible way (BSD, not GPL) in newlib are
> >>always welcome.
> >
> >Note that changing perl to use long doubles is a binary incompatible change.
> >So if anyone is going to jump on this, it would be nice to have it happen
> >before the already incompatible 5.10 is out Septemberish.
> >
> >modfl isn't strictly necessary; perl will substitute aintl (a solaris
> >flavor of truncl) + copysignl.
> >And ilogbl + scalbnl can be used to emulate frexpl.
> 
> I think I'll bite the bullet for the upcoming perl-5.12.0, for which
> I already have an API change (-Uusemymalloc) so adding
> -Duselongdouble can be easily added.
> 
> I dissected long doubles for my parrot pbc_compat work last year so
> I believe I can do modfl and frexpl without looking at GPL infected
> code.
> http://code.google.com/p/cygwin-rurban/source/browse/trunk/release/parrot/patches/r36819-tt308-more-pf_items.patch
> 
> sqrtl is trivial in intel assembler:
> 
> long double sqrtl(long double ld) {
>   long double _result;
>   asm ("fsqrt" : "=t" (_result) : "0"(ld));
>   return _result;
> }

Adding real long double support to newlib would be extremly cool.
If you look into http://cygwin.com/cygwin-api/std-notimpl.html you'll
notice that the majority of the unimplemented functions are math
functions, and most of them are the long double and the complex number
functions.

Basically:

> These questions are for newlib later:
> Can I keep such a newlib code to 12-byte intel long doubles or must
> I add 16-byte long double support also?
> Our gcc has -m128bit-long-double and the bastard -m96bit-long-double.

It's ok to add 12 byte intel only for now.  It's much better than no
long double at all.

> Does newlib needs papers?

No.  Just add a liberal copyright notice to all your files, 2-clause BSD
or similar is fine.

> I see a comment about --enable-newlib-hw-fp in
> /usr/include/machine/ieeefp.h
> I have no idea what this should be. Is there some hidden prior art?

No idea, sorry.  Better ask on the newlib list.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cygwin Perl and -Duselongdouble

2010-04-21 Thread Reini Urban

Yitzchak Scott-Thoennes schrieb:

On Thu, July 26, 2007 5:19 am, Corinna Vinschen wrote:

On Jul 26 22:09, Sisyphus wrote:

I'd like to have a perl on Cygwin built with -Duselongdouble, so I tried



*** You requested the use of long doubles but you do not seem to have
*** the following mathematical functions needed for long double support:
  *** sqrtl modfl frexpl


Long double functions are not supported by newlib so far.  There are a
couple of C99 functions not available in newlib.  Volunteers implementing
these functions in a license compatible way (BSD, not GPL) in newlib are
always welcome.


Note that changing perl to use long doubles is a binary incompatible change.
So if anyone is going to jump on this, it would be nice to have it happen
before the already incompatible 5.10 is out Septemberish.

modfl isn't strictly necessary; perl will substitute aintl (a solaris
flavor of truncl) + copysignl.
And ilogbl + scalbnl can be used to emulate frexpl.


I think I'll bite the bullet for the upcoming perl-5.12.0, for which I 
already have an API change (-Uusemymalloc) so adding -Duselongdouble can 
be easily added.


I dissected long doubles for my parrot pbc_compat work last year so I 
believe I can do modfl and frexpl without looking at GPL infected code.

http://code.google.com/p/cygwin-rurban/source/browse/trunk/release/parrot/patches/r36819-tt308-more-pf_items.patch

sqrtl is trivial in intel assembler:

long double sqrtl(long double ld) {
  long double _result;
  asm ("fsqrt" : "=t" (_result) : "0"(ld));
  return _result;
}

These questions are for newlib later:
Can I keep such a newlib code to 12-byte intel long doubles or must I 
add 16-byte long double support also?

Our gcc has -m128bit-long-double and the bastard -m96bit-long-double.
Does newlib needs papers?

I see a comment about --enable-newlib-hw-fp in
/usr/include/machine/ieeefp.h
I have no idea what this should be. Is there some hidden prior art?

I only know about Dave Korn's libm/machine/i386/f_*l.c stuff and I have 
newlib cvs.

--
Reini Urban
http://phpwiki.org/  http://murbreak.at/

--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple



Re: Cygwin Perl and -Duselongdouble

2007-07-27 Thread Brian Dessent
Sisyphus wrote:

> It certainly works for me for 'sqrtl' (but fails for 'frexpl' with
> "undefined reference to `_frexpl'"):

This is an invalid testcase in several ways.

It only "works" inasmuch as the compiler recognises that 7 is a constant
and replaces the call to sqrtl() with a value.  Any nontrivial use of
sqrtl() however will result in a linker error, so this testcase is not
doing what you think it is.

Also, you didn't include math.h, which if combined with -Wall would have
given you an "implicit declaration of sqrtl" warning.  As it is you're
relying on the fact that ancient C conventions allow for calling a
function without first seeing a definition or declaration for that
function, but in the modern age doing this is extremely bad because the
compiler has to guess as to the argument types.

long double x = sqrtl(7);
  40106a:   b8 bc 4d c7 97  mov$0x97c74dbc,%eax
  40106f:   ba 4e fd 53 a9  mov$0xa953fd4e,%edx
  401074:   b9 00 40 00 00  mov$0x4000,%ecx
  401079:   89 45 e8mov%eax,0xffe8(%ebp)
  40107c:   89 55 ecmov%edx,0xffec(%ebp)
  40107f:   89 4d f0mov%ecx,0xfff0(%ebp)
printf("%.19Lf\n", x);
  401082:   8b 45 e8mov0xffe8(%ebp),%eax
  401085:   8b 55 ecmov0xffec(%ebp),%edx
  401088:   8b 4d f0mov0xfff0(%ebp),%ecx
  40108b:   89 44 24 04 mov%eax,0x4(%esp)
  40108f:   89 54 24 08 mov%edx,0x8(%esp)
  401093:   89 4c 24 0c mov%ecx,0xc(%esp)
  401097:   c7 04 24 00 20 40 00movl   $0x402000,(%esp)
  40109e:   e8 ad 00 00 00  call   401150 <_printf>

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-27 Thread Sisyphus


- Original Message - 
From: "Brian Dessent" <[EMAIL PROTECTED]>

.
.
If I can successfully run 'gcc script.c' (where 'script.c' contains a 
call

to 'sqrtl') then I'm inclined to say that sqrtl is "available in the C
compiler" (or something like that).


But you can't.  That command should fail on Cygwin.


It certainly works for me for 'sqrtl' (but fails for 'frexpl' with 
"undefined reference to `_frexpl'"):


--
[EMAIL PROTECTED] ~/C
$ cat script.c
#include 

int main(void) {
   long double x = sqrtl(7);
   printf("%.19Lf\n", x);
   return 0;
}

[EMAIL PROTECTED] ~/C
$ gcc script.c

[EMAIL PROTECTED] ~/C
$ ./a.exe
2.6457513110645905904

[EMAIL PROTECTED] ~/C
--

[Snip - a most helpful explanation of where libc and newlib fit into the 
picture, and of other aspects that I was finding confusing. Thanks for that 
Brian ... much appreciated.]


Cheers,
Rob 



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Yitzchak Scott-Thoennes
On Thu, July 26, 2007 5:19 am, Corinna Vinschen wrote:
> On Jul 26 22:09, Sisyphus wrote:

>> I'd like to have a perl on Cygwin built with -Duselongdouble, so I tried

>> *** You requested the use of long doubles but you do not seem to have
>> *** the following mathematical functions needed for long double support:
>>  *** sqrtl modfl frexpl
>
> Long double functions are not supported by newlib so far.  There are a
> couple of C99 functions not available in newlib.  Volunteers implementing
> these functions in a license compatible way (BSD, not GPL) in newlib are
> always welcome.

Note that changing perl to use long doubles is a binary incompatible change.
So if anyone is going to jump on this, it would be nice to have it happen
before the already incompatible 5.10 is out Septemberish.

modfl isn't strictly necessary; perl will substitute aintl (a solaris
flavor of truncl) + copysignl.
And ilogbl + scalbnl can be used to emulate frexpl.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Brian Dessent
Sisyphus wrote:

> >> I haven't checked for 'modfl' and 'frexpl', but 'sqrtl' at least seems to
> >> be
> >> available in the C compiler. Why does configure report that it's not
> >
> > Why do you say this?
> 
> Oh ... it's probably just ignorance on my part.
> If I can successfully run 'gcc script.c' (where 'script.c' contains a call
> to 'sqrtl') then I'm inclined to say that sqrtl is "available in the C
> compiler" (or something like that).

But you can't.  That command should fail on Cygwin.

> I gather from your response (and Corinna's) that there are also a couple of
> things called 'newlib' and 'libc' that enter into the equation. I don't know
> how they fit in. Feel free to enlighten me (but only if you're so inclined,
> as I realise that such an explanation is probably not on topic for this
> list).

libc is the generic name for the C standard library of functions.  It
has to come from somewhere; it's not part of gcc.  On Linux it is
typically the GNU libc (glibc), though on embedded Linux it might be
something else such as uclibc or dietlibc or newlib or ...  On Cygwin,
the libc functionality is provided by the Cygwin DLL, which internally
uses newlib to implement substantial portions (such as the stdio and
math related functions.)  On MinGW the libc is the Microsoft C library,
MSVCRT.DLL.

Again, note that this is totally independent of the compiler.  gcc runs
on all three of those systems but gcc is just a compiler, *not* a C
library.  It uses whatever the system provides.  Now gcc may provide
built-in replacements of some standard C library functions which it uses
when inlining -- for example it might know that it can replace a call to
the library function memcpy() with a simple direct assembly copy loop. 
But there always must be a library copy of the function backing these
builtins, they are only suppliments.

> I find it all quite confusing. My MinGW version of math.h specifically
> prototypes the "long double" version of a number of functions (ceill,
> floorl, sqrtl, modfl, ...), yet I can't find any mention of those functions
> in any of the gcc headers on Linux or Cygwin.

Thing these are three separate platforms, so don't expect them to behave
the same.  
glibc most definitely provides all those functions.  If you blindly grep
for them in header files you may not find them as glibc uses a twisty
maze of macros to implement headers.  Instead of blindly grepping around
in the dark though, use the manual.  There is a nice index that shows
precisely what the library supports:
.

On MinGW, most of those C99 math functions don't exist in MSVCRT.DLL so
there is the mingwex helper library that implements them.

> If I call sqrtl on linux I have to link to -lm, on Cygwin I don't.

This is just a bit of historical trivia.  Back before shared libraries
were common and everything was statically linked, you had to be mindful
of the size of the executable and it was an "optimization" to leave all
the math stuff in a separate library so that it wouldn't accidently get
pulled in unless you wanted it.  This separation continues to this day
on some POSIX platforms even though nobody uses static linking any more,
so there's no real point to it.  Cygwin just puts everything in one
library, cygwin1.dll, so there is no point in this superfluous "-lm"
business, but it provides a "libm" for Makefiles that hard-code -lm.

> On linux I can build perl with -Duselongdouble, on Cygwin I can't.

Because linux has a C99-conforming libc where Cygwin doesn't.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Tim Prince

[EMAIL PROTECTED] wrote:


- Original Message - From: "Brian Dessent" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, July 26, 2007 10:29 PM
Subject: Re: Cygwin Perl and -Duselongdouble



Oh ... it's probably just ignorance on my part.
If I can successfully run 'gcc script.c' (where 'script.c' contains a 
call to 'sqrtl') then I'm inclined to say that sqrtl is "available in 
the C compiler" (or something like that).
If your position is that availability as a built-in should suffice, you 
may have a long row to hoe.


I gather from your response (and Corinna's) that there are also a couple 
of things called 'newlib' and 'libc' that enter into the equation.
gcc itself supports only built-in functions.  There are plenty of posts 
in the archives concerning why cygwin doesn't use glibc rather than newlib.


I find it all quite confusing. My MinGW version of math.h specifically 
prototypes the "long double" version of a number of functions (ceill, 
floorl, sqrtl, modfl, ...), yet I can't find any mention of those 
functions in any of the gcc headers on Linux or Cygwin.
mingw relies on Microsoft library support, where again there is no 
separate long double.  You are free to add prototypes to your cygwin 
, but you must take the further step of actually supplying a 
function.  It should not be difficult to make one for cygwin which 
satisfies your purposes, whatever they are.  For example, you could 
build a function which uses the built-in, with its limitations.



/definitely Off Topic

If I call sqrtl on linux I have to link to -lm, on Cygwin I don't.


Most compilers on linux also have a built-in sqrtl.  If you set the 
right options in gcc, for example, you should be able to make a simple 
test which gets by with that.  You may have to check for bugs in 
mathinline.h.  Many distros do ugly things which can't be blamed on gcc 
or glibc maintainers.


--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Sisyphus


- Original Message - 
From: "Brian Dessent" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, July 26, 2007 10:29 PM
Subject: Re: Cygwin Perl and -Duselongdouble



Sisyphus wrote:

I haven't checked for 'modfl' and 'frexpl', but 'sqrtl' at least seems to 
be

available in the C compiler. Why does configure report that it's not


Why do you say this?


Oh ... it's probably just ignorance on my part.
If I can successfully run 'gcc script.c' (where 'script.c' contains a call 
to 'sqrtl') then I'm inclined to say that sqrtl is "available in the C 
compiler" (or something like that).


I gather from your response (and Corinna's) that there are also a couple of 
things called 'newlib' and 'libc' that enter into the equation. I don't know 
how they fit in. Feel free to enlighten me (but only if you're so inclined, 
as I realise that such an explanation is probably not on topic for this 
list).


I find it all quite confusing. My MinGW version of math.h specifically 
prototypes the "long double" version of a number of functions (ceill, 
floorl, sqrtl, modfl, ...), yet I can't find any mention of those functions 
in any of the gcc headers on Linux or Cygwin.


If I call sqrtl on linux I have to link to -lm, on Cygwin I don't.

On linux I can build perl with -Duselongdouble, on Cygwin I can't.

Anyway  I gather that -Duselongdouble is out of the question while 
newlib remains in its current state. (That's pretty much the confirmation I 
was seeking.)


Thanks guys.

Cheers,
Rob 



--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Corinna Vinschen on 7/26/2007 6:19 AM:
> Long double functions are not supported by newlib so far.  There are a
> couple of C99 functions not available in newlib.  Volunteers implementing
> these functions in a license compatible way (BSD, not GPL) in newlib
> are always welcome.

Also note that until frexpl is implemented, you can make printf in a CVS
snapshot of cygwin go into an infloop or coredump with certain long double
values.

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.5 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGqJKz84KuGfSFAYARAnc7AJ9e6GmUcok1z+q1QxExf4pTrT3t5QCeORd0
IxzNJ0A7EAmsoYEyLWJDRPk=
=nSMh
-END PGP SIGNATURE-

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Brian Dessent
Sisyphus wrote:

> I haven't checked for 'modfl' and 'frexpl', but 'sqrtl' at least seems to be
> available in the C compiler. Why does configure report that it's not

Why do you say this?  It's not available.  And it's not something the
compiler provides, it's something the libc provides, and in the case of
newlib, none of these three functions exist, so the results are
expected.  At the moment newlib only supports long double I/O, i.e.
printf and scanf.

Brian

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/



Re: Cygwin Perl and -Duselongdouble

2007-07-26 Thread Corinna Vinschen
On Jul 26 22:09, Sisyphus wrote:
> Hi,
> I'd like to have a perl on Cygwin built with -Duselongdouble, so I tried 
> building blead (5.9.5) from source with:
> 
> ./configure -de -Dusemorebits -Dprefix=~/Rob -Dusethreads -Uusemymalloc 
> -Doptimize=-O3 -Dusedevel
> 
> but that failed, culminating as follows:
> 
> 
> .
> .
> sqrtl() NOT found.
> 
> scalbnl() NOT found.
> 
> modfl() NOT found.
> 
> modfl() prototype NOT found.
> 
> *** You requested the use of long doubles but you do not seem to have
> *** the following mathematical functions needed for long double support:
> *** sqrtl modfl frexpl
> *** Please rerun Configure without -Duselongdouble and/or -Dusemorebits.
> *** Cannot continue, aborting.
> 

Long double functions are not supported by newlib so far.  There are a
couple of C99 functions not available in newlib.  Volunteers implementing
these functions in a license compatible way (BSD, not GPL) in newlib
are always welcome.


Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader  cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple
Problem reports:   http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ:   http://cygwin.com/faq/