Date: Mon, 10 Feb 2020 13:52:26 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357728 - head/sys/sys Message-ID: <202002101352.01ADqQLh039003@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Mon Feb 10 13:52:25 2020 New Revision: 357728 URL: https://svnweb.freebsd.org/changeset/base/357728 Log: 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. Modified: head/sys/sys/pcpu.h Modified: head/sys/sys/pcpu.h ============================================================================== --- head/sys/sys/pcpu.h Mon Feb 10 13:24:14 2020 (r357727) +++ head/sys/sys/pcpu.h Mon Feb 10 13:52:25 2020 (r357728) @@ -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); \ })
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002101352.01ADqQLh039003>