From c77649d8e7ecbeb083a50ff6526844c3b616b2d3 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Fri, 7 Feb 2020 22:43:58 +0000 Subject: [PATCH] Add zpcpu_{set,add,sub}_protected. The _protected suffix follows counter(9). --- sys/sys/pcpu.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h index afccd9ec26f..f859d09554c 100644 --- a/sys/sys/pcpu.h +++ b/sys/sys/pcpu.h @@ -256,6 +256,24 @@ extern struct pcpu *cpuid_to_pcpu[]; _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); \ +}) + /* * Machine dependent callouts. cpu_pcpu_init() is responsible for * initializing machine dependent fields of struct pcpu, and