linux-mips
[Top] [All Lists]

Re: Float / Double issues - solved, perhaps

To: Tim Hockin <thockin@cobaltnet.com>
Subject: Re: Float / Double issues - solved, perhaps
From: Ralf Baechle <ralf@uni-koblenz.de>
Date: Fri, 16 Jul 1999 02:57:32 +0200
Cc: linux@cthulhu.engr.sgi.com, cjohnson@cobaltnet.com
In-reply-to: <378D36E5.CBF85556@cobaltnet.com>; from Tim Hockin on Wed, Jul 14, 1999 at 06:18:29PM -0700
References: <378AADF5.96152E0B@cobaltnet.com> <19990714235346.A1231@uni-koblenz.de> <378D36E5.CBF85556@cobaltnet.com>
Sender: owner-linux@cthulhu.engr.sgi.com
On Wed, Jul 14, 1999 at 06:18:29PM -0700, Tim Hockin wrote:

> We have the fix, I think.  Not clone.S, but in
> glibc-2.0.7/linuxthreads/internals.h line 86 we need to tell gcc that this
> struct (_pthread_descr_struct - which defines the offset of a thread's stack
> from a well-aligned, malloc() returned addr) be padded to be aligned
> correctly on an 8byte boundary:
> 
> -};
> +} __attribute__ ((aligned(__alignof__(double))));
> 
> It's working for us now.  Please confirm if it works for you folks, too.  A
> bug report has been filed for glibc, though I doubt if anything official
> goes on for 2.0.x, now. Hopefully 2.1.x will fold this in.  A thread's stack
> really should always be well aligned :)  Funny, the doubles were actually
> calculated right,

It's dangerous though.  If the code would have attempted to use a MIPS II
ldc1 / sdc1 instruction to access the floating point number, the code
would have been killed by arch/mips/kernel/unaligned.c.

> but stdio functions use va_arg - which expected double's
> to be aligned, and weren't.  The work got done, but it couldn't tell us!

The MIPS ABI wants a 8 byte alignment for the stack and even 16 byte for
ABI64.  Now we know what can happen if not :-)

Thanks for your fix,

  Ralf

<Prev in Thread] Current Thread [Next in Thread>