delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/02/23/10:16:04

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: 1.5.12: FPU affected by gethostname call
Date: Wed, 23 Feb 2005 15:15:53 -0000
MIME-Version: 1.0
In-Reply-To: <1109168860.421c92dc7c3bd@webmail.inet.dkfz-heidelberg.de>
Message-ID: <SERRANOgRBhOedyDJS000000032@SERRANO.CAM.ARTIMI.COM>
X-OriginalArrivalTime: 23 Feb 2005 15:15:53.0257 (UTC) FILETIME=[90B8D190:01C519BA]

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019