David Miller <[EMAIL PROTECTED]> writes:
> Even in cases like:
>
> typedef unsigned char spinlock_t;
> extern int spin_trylock(spinlock_t *);
> extern int spin_unlock(spinlock_t *);
>
> struct foo {
> spinlock_t lock;
> int a;
> };
>
> extern void foo_register(struct foo *p);
> extern void foo_unregister(struct foo *p);
>
> void example(void)
> {
> struct foo local;
>
> foo_register(&local);
>
> if (spin_trylock(&local.lock)) {
> local.a++;
> spin_unlock(&local.lock);
> }
>
> foo_unregister(&local);
> }
>
>
> I suspect that local.a++ will be represented as a frame relative
> access. Test compiles show that gcc does update the on-stack
> copy on Sparc, now just to check if the conditional memory
> operation cases trigger here too.
This code isn't going to be a problem, because spin_unlock presumably
includes a memory barrier.
The cases which are problems are the ones in which there is no memory
barrier, as in the original example.
Ian