From a5abfadfca46607b6826a7d2870eabb85fd7c5ae Mon Sep 17 00:00:00 2001 From: Chris McGee Date: Wed, 7 Sep 2016 22:09:27 -0400 Subject: [PATCH] Pull cmpswap implementation into archbcm2.c to avoid bringing in libc.a dependencies on lock --- bcm/archbcm2.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bcm/archbcm2.c b/bcm/archbcm2.c index a081e8e..b98d97a 100644 --- a/bcm/archbcm2.c +++ b/bcm/archbcm2.c @@ -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