[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: gcc 4.5 and TLS



On Sun, Jun 6, 2010 at 05:49, Brad Boyer <flar@allandria.com> wrote:
> On Thu, Jun 03, 2010 at 06:12:29PM +0200, Andreas Schwab wrote:
>> It is basically working quite well.  Unfortunately there is a big
>> problem which becomes apparent when running the libstdc++ testsuite: the
>> m68k compiler only guarantees a maximum alignment of 2 bytes, but the
>> futex syscall requires 4 byte alignment.  So if your pthread mutex is
>> not aligned on a 4 byte boundary this will result in passing an
>> unaligned address to futex.  I haven't yet decided on what would be the
>> best way to fix that.
>
> I may be missing something obvious, but why don't we just change the
> kernel to allow 2-byte alignment for m68k? The comment in futex.c
> just says "natural" alignment but is then hard-coded for sizeof(u32).
> What would break if we just changed the code in get_futex_key to
> allow this?

You mean (white-space damaged):

--- a/kernel/futex.c.orig	2010-04-15 20:41:58.000000000 +0200
+++ b/kernel/futex.c	2010-06-06 10:26:47.000000000 +0200
@@ -225,7 +225,7 @@ get_futex_key(u32 __user *uaddr, int fsh
 	 * The futex address must be "naturally" aligned.
 	 */
 	key->both.offset = address % PAGE_SIZE;
-	if (unlikely((address % sizeof(u32)) != 0))
+	if (unlikely((address % __alignof__(u32)) != 0))
 		return -EINVAL;
 	address -= key->both.offset;

Technically, it would bring the implementation in sync with the comment ;-)

Don't know if there are other places that make assumptions about
__alignof__(u32) == sizeof(u32).

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
							    -- Linus Torvalds


Reply to: