aboutsummaryrefslogtreecommitdiff
path: root/sys/sys
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-02-10 13:52:25 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-02-10 13:52:25 +0000
commitd1e553875865bbbba22421bd7b6d51bddaff673b (patch)
treee6c01830b61d0b3c1738d98498d397df5adada58 /sys/sys
parent0b40dcbe32fd67646eb84ed89c6f4c1477bcc884 (diff)
downloadsrc-d1e553875865bbbba22421bd7b6d51bddaff673b.tar.gz
src-d1e553875865bbbba22421bd7b6d51bddaff673b.zip
Tidy up zpcpu_replace*
- only compute the target address once - remove spurious type casting, zpcpu_get already return the correct type While here add missing newlines to other routines.
Notes
Notes: svn path=/head/; revision=357728
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/pcpu.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index f859d09554c0..0a6764b80e9d 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -245,32 +245,41 @@ extern struct pcpu *cpuid_to_pcpu[];
* If you need atomicity use xchg.
* */
#define zpcpu_replace(base, val) ({ \
- __typeof(val) _old = *(__typeof(base))zpcpu_get(base); \
- *(__typeof(val) *)zpcpu_get(base) = val; \
+ __typeof(val) *_ptr = zpcpu_get(base); \
+ __typeof(val) _old; \
+ \
+ _old = *_ptr; \
+ *_ptr = val; \
_old; \
})
#define zpcpu_replace_cpu(base, val, cpu) ({ \
- __typeof(val) _old = *(__typeof(base))zpcpu_get_cpu(base, cpu); \
- *(__typeof(val) *)zpcpu_get_cpu(base, cpu) = val; \
+ __typeof(val) *_ptr = zpcpu_get_cpu(base, cpu); \
+ __typeof(val) _old; \
+ \
+ _old = *_ptr; \
+ *_ptr = val; \
_old; \
})
#define zpcpu_set_protected(base, val) ({ \
MPASS(curthread->td_critnest > 0); \
__typeof(val) *_ptr = zpcpu_get(base); \
+ \
*_ptr = (val); \
})
#define zpcpu_add_protected(base, val) ({ \
MPASS(curthread->td_critnest > 0); \
__typeof(val) *_ptr = zpcpu_get(base); \
+ \
*_ptr += (val); \
})
#define zpcpu_sub_protected(base, val) ({ \
MPASS(curthread->td_critnest > 0); \
__typeof(val) *_ptr = zpcpu_get(base); \
+ \
*_ptr -= (val); \
})