[Top] [All Lists]

Re: Float / Double issues - solved, perhaps

To: Tim Hockin <>
Subject: Re: Float / Double issues - solved, perhaps
From: Ralf Baechle <>
Date: Fri, 16 Jul 1999 02:57:32 +0200
In-reply-to: <>; from Tim Hockin on Wed, Jul 14, 1999 at 06:18:29PM -0700
References: <> <> <>
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,


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