This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: 1.5.12: FPU affected by gethostname call


-----Original Message-----
>From: cygwin-owner On Behalf Of R.Schulz
>Sent: 23 February 2005 14:28

>the following c++ program (see below) is affected by a strange bug:
floating 
>point precision is decreased by uncommenting the call to gethostname(). 

>* if you change the long doubles to normal doubles, values seem to be not
>affected by the gethostname call
>* the resulting values for double precision are equal to the values
obtained
>with long doubles in case the gethostname() function is invoked


  I'd bet the -ffloat-store flag makes a difference too.  This is a
well-known issue with x86 floating point implementations:

http://gcc.gnu.org/ml/gcc-help/2005-01/msg00173.html
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
http://gcc.gnu.org/ml/gcc-help/2005-02/msg00081.html
http://www.vinc17.org/research/extended.en.html
http://www.srware.com/linux_numerics.txt

http://www.google.co.uk/search?q=+site:gcc.gnu.org+x86+extended+precision+co
mpiler+problem&hl=en&lr=&client=firefox-a&rls=org.mozilla:en-US:official&sta
rt=20&sa=N

  To summarize:  inside the FP registers of the cpu, long doubles are stored
in extended (80-bit) precision format.  When these values have to be stored
to memory locations, however, they are truncated to 64 bits.  So you get
different results from a calculation depending if it's entirely done in
registers or if some of the intermediate results need to be spilled to the
stack, or otherwise stored in memory.

  In this case, the FP registers are presumably being saved and restored
owing to the call to gethostname, so that's why removing the call fixes it.

  If you use normal doubles, you're only ever working with 64-bit values, so
that's why changing to doubles gets the same result as long doubles with the
function call uncommented, even if the registers are not in this case
spilled to memory.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]