Messages in this thread | | | Date | Thu, 17 Apr 2008 10:35:05 +1000 | From | Paul Mackerras <> | Subject | Re: [RFC patch 23/27] Immediate Values - Powerpc Optimization NMI MCE support |
| |
Mathieu Desnoyers writes:
> * Paul Mackerras (paulus@samba.org) wrote: > > Mathieu Desnoyers writes: > > > > > Use an atomic update for immediate values. > > > > What is meant by an "atomic" update in this context? AFAICS you are > > using memcpy, which is not in any way guaranteed to be atomic. > > > > Paul. > > I expect memcpy to perform the copy in one memory access, given I put a > > .align 2 > > before the 2 bytes instruction. It makes sure the instruction modified > fits in a single, aligned, memory write.
My original question was in the context of the powerpc architecture, where instructions are always 4 bytes long and aligned. So that's not an issue.
> Or maybe am I expecting too much from memcpy ?
I don't think memcpy gives you any such guarantees. It would be quite within its rights to say "it's only a few bytes, I'll do it byte by byte".
If you really want it to be atomic (which I agree is probably a good idea), I think the best way to do it is to use an asm to generate a sth (store halfword) instruction to the immediate field (instruction address + 2). That's on powerpc of course; I don't know what you would do on other architectures.
Paul.
| |