lkml.org 
[lkml]   [2008]   [Mar]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [patch] Re: using long instead of atomic_t when only set/read is required
From
Date
On Mon, 2008-03-03 at 18:24 +0100, Pavel Machek wrote:
> Ok, I can understand the gcc side. But do we actually run on an
> architecture where
>
> long *x;
>
> *x = 0;
>
> racing with
>
> *x = 0x12345678;
>
> can produce
>
> *x == 0x12340000;
>
> or something like that? I'm told RCU relies on architectures not doing
> this, and I'd like to get this clarified.

ARM6, ARM7500 and similar do exactly this for short (and unsigned
short), although not for int, long, or pointers:

> struct foo { short b; short c; };
> void baa(struct foo *f, short cc) { f->c = cc; }

becomes (arm-linux-gcc -mcpu=arm6):

> baa:
> mov r3, r1, lsr #8
> strb r3, [r0, #3]
> strb r1, [r0, #2]
> mov pc, lr

note the two single-byte stores, as ARM6 didn't have the "store
halfword" instruction.

So I think Alan Stern's
"For all properly-aligned pointer and integral types other than long
long..."
should be amended to
"For all properly-aligned pointer and integral types other than short or
long long..."

Peter




\
 
 \ /
  Last update: 2008-03-05 01:19    [W:2.540 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site