Re: missing declaration for floorl

2007-08-01 Thread Brian Dessent
Fred Hansen wrote:

 The random nubers package in http://www.agner.org/random/ uses function
 floorl. It is present in the cygwin g++ library
 (/lib/gcc/i686-pc-cygwin/3.4.4/libstdc++.a), but is not declared in any of
 the header files (cd /usr/include; grep -rI floorl). If I declare it:
 long double floorl(long double x);
 then I can call it, link it, and get the correct result.
 
 Should math.h be augmented with the declaration of floorl?

No.  It's not a mistake that the definition is missing from math.h,
because Cygwin does not provide this function.  libstdc++ is the C++
standard library, and in general it does not implement basic libc
functions like floorl, it relies on the target's C library
implementation for those.  And in fact the floorl that is in libstdc++
is not a real implementation of floorl, it's just a stub:

#ifndef HAVE_FLOORL
long double
floorl(long double x)
{
  return floor((double) x);
}
#endif

The comment at the top of this file (libmath/stubs.c) even says:

/* For targets which do not have support for long double versions,
   we use the crude approximation.  We'll do better later.  */

So it's clear that these functions are only provided as a last resort,
and they aren't even fully correct implementations either since they
just cast away the extra bits.

And even if you added a prototype to math.h for this crude floorl(),
linking would still fail on plain C source using the gcc driver, because
you do not link with libstdc++ unless you use g++.  So it would still be
a broken implementation, but even more confusingly broken since it would
appear to support something that it doesn't.

No, the real problem is not that there are missing prototypes, it's that
actual long double support is missing.

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: Re: missing declaration for floorl

2007-08-01 Thread Fred Hansen
Aha. There is no floorl in cygwin.

It is too bad that the stub function causes autoconf to believe there IS a
floorl. AC_CHECK_FUNCS finds the stub and reports that the function is
available. 

Fred Hansen




   

Be a better Globetrotter. Get better travel answers from someone who knows. 
Yahoo! Answers - Check it out.
http://answers.yahoo.com/dir/?link=listsid=396545469

--
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: missing declaration for floorl

2007-08-01 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Fred Hansen on 8/1/2007 5:54 PM:
 Aha. There is no floorl in cygwin.
 
 It is too bad that the stub function causes autoconf to believe there IS a
 floorl. AC_CHECK_FUNCS finds the stub and reports that the function is
 available. 

But I bet AC_CHECK_DECLS gets the right answer; so you should consider
using both autoconf macros rather than just relying on one of them.

- --
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

iD8DBQFGsSaI84KuGfSFAYARAiciAJwPyKpNypHprW0uiXKzGvJTUJkqVACferM1
q1maI7a4RDqDxRqvnwZAcno=
=nuls
-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/