Skip to content

Commit

Permalink
Pull cmpswap implementation into archbcm2.c to avoid bringing in libc…
Browse files Browse the repository at this point in the history
….a dependencies on lock
  • Loading branch information
sirnewton01 committed Sep 8, 2016
1 parent 2cc8ae5 commit a5abfad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion bcm/archbcm2.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,24 @@ l2ap(int ap)
return (AP(0, (ap)));
}

int
cas32(void* addr, u32int old, u32int new)
{
int r, s;

s = splhi();
if(r = (*(u32int*)addr == old))
*(u32int*)addr = new;
splx(s);
if (r)
coherence();
return r;
}

int
cmpswap(long *addr, long old, long new)
{
return cas((ulong*)addr, old, new);
return cas32((ulong*)addr, old, new);
}

void
Expand Down

0 comments on commit a5abfad

Please sign in to comment.