Subject: Re: pkg/30106
To: None <gnats-bugs@netbsd.org>
From: Shin'ichiro TAYA <taya@ba2.so-net.ne.jp>
List: pkgsrc-bugs
Date: 05/07/2005 18:40:37
This is a multi-part message in MIME format.
--------------020009060005080700080002
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

segv wrote:
>  It's not just Solaris problem, it's a 64-bit issue which will bite on 64-bit platforms like UltraSparc, not matter which OS is installed

I think source code itself has problem.
I tested this problem with attached source code on sparc64.
Simply compiled code has problem you mentioned.
But shared object created from this source code doesn't dump core.
I don't have much knowledge about toolchain nor sparc asm lang.
I don't known whether data is properly aligned or unaligned access is 
prevented. Anyway I never see this problem with alpha, amd64, 
sparc64(all NetBSD). And there is a official distribution for Solaris.
I wonder this patch is really required or not....

--------------020009060005080700080002
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
 name="doubletest.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="doubletest.cpp"

#include	<inttypes.h>

#define TX_DOUBLE_HI32_SIGNBIT   0x80000000
#define TX_DOUBLE_HI32_EXPMASK   0x7ff00000 
#define TX_DOUBLE_HI32_MANTMASK  0x000fffff
 
typedef uint32_t PRUint32;

//-- Initialize Double related constants
#ifdef IS_BIG_ENDIAN
const PRUint32 nanMask[2] =    {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK
, 
                                0xffffffff};
const PRUint32 infMask[2] =    {TX_DOUBLE_HI32_EXPMASK, 0};
const PRUint32 negInfMask[2] = {TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT,
 0};
#else   
const PRUint32 nanMask[2] =    {0xffffffff,
                                TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_MANTMASK
};  
const PRUint32 infMask[2] =    {0, TX_DOUBLE_HI32_EXPMASK};
const PRUint32 negInfMask[2] = {0, TX_DOUBLE_HI32_EXPMASK | TX_DOUBLE_HI32_SIGNBIT};
#endif
        
const double NaN = *((double*)nanMask); 
const double POSITIVE_INFINITY = *((double*)infMask);
const double NEGATIVE_INFINITY = *((double*)negInfMask);

double
get_double()
{
	return NaN;
}

#if 0
main()
{
	printf("%f", get_double());
}
#endif

--------------020009060005080700080002--