From f124c7b964c4f67078d8cf287445d7f6810a848c Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Fri, 29 Nov 2019 18:18:09 +0000 Subject: [PATCH] Largely eliminate the MD rwlock.h header file. This was full of definitions that have been obsolete for over a decade. The file still remains for __HAVE_RW_STUBS but that's all. Used only internally in kern_rwlock.c now, not by . --- sys/arch/alpha/include/rwlock.h | 51 ------------------------- sys/arch/arm/include/rwlock.h | 60 ------------------------------ sys/arch/hppa/include/rwlock.h | 55 --------------------------- sys/arch/ia64/include/rwlock.h | 60 ------------------------------ sys/arch/m68k/include/rwlock.h | 49 ------------------------ sys/arch/mips/include/rwlock.h | 52 -------------------------- sys/arch/or1k/include/rwlock.h | 55 --------------------------- sys/arch/powerpc/include/rwlock.h | 51 ------------------------- sys/arch/riscv/include/rwlock.h | 55 --------------------------- sys/arch/sh3/include/rwlock.h | 51 ------------------------- sys/arch/sparc/include/rwlock.h | 53 -------------------------- sys/arch/sparc64/include/rwlock.h | 53 -------------------------- sys/arch/usermode/include/rwlock.h | 60 ------------------------------ sys/arch/vax/include/rwlock.h | 16 -------- sys/arch/x86/include/rwlock.h | 25 ------------- sys/kern/kern_rwlock.c | 2 + sys/sys/rwlock.h | 4 +- 17 files changed, 5 insertions(+), 747 deletions(-) diff --git a/sys/arch/alpha/include/rwlock.h b/sys/arch/alpha/include/rwlock.h index 26b94cd37562..cd7ff01367f3 100644 --- a/sys/arch/alpha/include/rwlock.h +++ b/sys/arch/alpha/include/rwlock.h @@ -1,52 +1 @@ /* $NetBSD: rwlock.h,v 1.4 2008/04/28 20:23:11 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ALPHA_RWLOCK_H_ -#define _ALPHA_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) _lock_cas((p), (o), (n)) - -int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _ALPHA_RWLOCK_H_ */ diff --git a/sys/arch/arm/include/rwlock.h b/sys/arch/arm/include/rwlock.h index 43061034355a..dfe8b2a5034e 100644 --- a/sys/arch/arm/include/rwlock.h +++ b/sys/arch/arm/include/rwlock.h @@ -1,61 +1 @@ /* $NetBSD: rwlock.h,v 1.9 2015/02/25 13:52:42 joerg Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ARM_RWLOCK_H_ -#define _ARM_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#ifdef MULTIPROCESSOR -#ifdef _ARM_ARCH_7 -#define RW_RECEIVE(rw) __asm __volatile("dmb" ::: "memory") -#define RW_GIVE(rw) __asm __volatile("dsb" ::: "memory") -#else -#define RW_RECEIVE(rw) membar_consumer() -#define RW_GIVE(rw) membar_producer() -#endif -#else -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ -#endif - -#define RW_CAS(p, o, n) \ - (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _ARM_RWLOCK_H_ */ diff --git a/sys/arch/hppa/include/rwlock.h b/sys/arch/hppa/include/rwlock.h index 9868991a2422..a348e93966f7 100644 --- a/sys/arch/hppa/include/rwlock.h +++ b/sys/arch/hppa/include/rwlock.h @@ -1,56 +1 @@ /* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:23 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _HPPA_RWLOCK_H_ -#define _HPPA_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -/* - * _lock_cas() will take care of any memory barrier that is needed. - */ -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -uintptr_t _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); - -#define RW_CAS(p, o, n) \ - (_lock_cas((volatile uintptr_t *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _HPPA_RWLOCK_H_ */ diff --git a/sys/arch/ia64/include/rwlock.h b/sys/arch/ia64/include/rwlock.h index deb7bbc0a4ae..d2d7bbaed4ba 100644 --- a/sys/arch/ia64/include/rwlock.h +++ b/sys/arch/ia64/include/rwlock.h @@ -1,61 +1 @@ /* $NetBSD: rwlock.h,v 1.3 2008/04/28 20:23:25 martin Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Takayoshi Kochi. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _IA64_RWLOCK_H_ -#define _IA64_RWLOCK_H_ - -#include - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 -/* #define __HAVE_RW_STUBS 1 */ - -/* - * RW_RECEIVE: no memory barrier required, as 'ret' implies a load fence. - */ -#define RW_RECEIVE(rw) /* nothing */ - -/* - * RW_GIVE: no memory barrier required, as _lock_cas() will take care of it. - */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) \ - (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _IA64_RWLOCK_H_ */ diff --git a/sys/arch/m68k/include/rwlock.h b/sys/arch/m68k/include/rwlock.h index 60e18dd78487..a93fb4716737 100644 --- a/sys/arch/m68k/include/rwlock.h +++ b/sys/arch/m68k/include/rwlock.h @@ -1,50 +1 @@ /* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:26 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _M68K_RWLOCK_H_ -#define _M68K_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) (atomic_cas_uint((p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _M68K_RWLOCK_H_ */ diff --git a/sys/arch/mips/include/rwlock.h b/sys/arch/mips/include/rwlock.h index b484ffac3c25..5146350a5854 100644 --- a/sys/arch/mips/include/rwlock.h +++ b/sys/arch/mips/include/rwlock.h @@ -1,53 +1 @@ /* $NetBSD: rwlock.h,v 1.8 2011/02/20 07:45:47 matt Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _MIPS_RWLOCK_H_ -#define _MIPS_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#include - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) membar_enter() -#define RW_GIVE(rw) membar_exit() - -#define RW_CAS(p, o, n) \ - (atomic_cas_ulong((volatile u_long *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _MIPS_RWLOCK_H_ */ diff --git a/sys/arch/or1k/include/rwlock.h b/sys/arch/or1k/include/rwlock.h index 323182bfb8fe..de61a5c65bd1 100644 --- a/sys/arch/or1k/include/rwlock.h +++ b/sys/arch/or1k/include/rwlock.h @@ -1,56 +1 @@ /* $NetBSD: rwlock.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _OR1K_RWLOCK_H_ -#define _OR1K_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#ifdef MULTIPROCESSOR -#define RW_RECEIVE(rw) membar_consumer() -#define RW_GIVE(rw) membar_producer() -#else -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ -#endif - -#define RW_CAS(p, o, n) \ - (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _OR1K_RWLOCK_H_ */ diff --git a/sys/arch/powerpc/include/rwlock.h b/sys/arch/powerpc/include/rwlock.h index 3df5c30d894a..da29c6c1a8cd 100644 --- a/sys/arch/powerpc/include/rwlock.h +++ b/sys/arch/powerpc/include/rwlock.h @@ -1,52 +1 @@ /* $NetBSD: rwlock.h,v 1.4 2008/04/28 20:23:32 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _POWERPC_RWLOCK_H_ -#define _POWERPC_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) _lock_cas((p), (o), (n)) - -int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _POWERPC_RWLOCK_H_ */ diff --git a/sys/arch/riscv/include/rwlock.h b/sys/arch/riscv/include/rwlock.h index 964fd201335f..06cd68b021e2 100644 --- a/sys/arch/riscv/include/rwlock.h +++ b/sys/arch/riscv/include/rwlock.h @@ -1,56 +1 @@ /* $NetBSD: rwlock.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _RISCV_RWLOCK_H_ -#define _RISCV_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#ifdef MULTIPROCESSOR -#define RW_RECEIVE(rw) membar_consumer() -#define RW_GIVE(rw) membar_producer() -#else -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ -#endif - -#define RW_CAS(p, o, n) \ - (atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _RISCV_RWLOCK_H_ */ diff --git a/sys/arch/sh3/include/rwlock.h b/sys/arch/sh3/include/rwlock.h index 2fdca00cc88e..cfe5c1628a25 100644 --- a/sys/arch/sh3/include/rwlock.h +++ b/sys/arch/sh3/include/rwlock.h @@ -1,52 +1 @@ /* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:35 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SH3_RWLOCK_H_ -#define _SH3_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) (_lock_cas((p), (o), (n)) == (o)) - -uintptr_t _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _SH3_RWLOCK_H_ */ diff --git a/sys/arch/sparc/include/rwlock.h b/sys/arch/sparc/include/rwlock.h index 1e6cb223436e..031d5179cb64 100644 --- a/sys/arch/sparc/include/rwlock.h +++ b/sys/arch/sparc/include/rwlock.h @@ -1,54 +1 @@ /* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:36 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SPARC_RWLOCK_H_ -#define _SPARC_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) \ - (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -unsigned long _atomic_cas_ulong(volatile unsigned long *, - unsigned long, unsigned long); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _SPARC_RWLOCK_H_ */ diff --git a/sys/arch/sparc64/include/rwlock.h b/sys/arch/sparc64/include/rwlock.h index 2c3849e2e9b7..45292ea212c2 100644 --- a/sys/arch/sparc64/include/rwlock.h +++ b/sys/arch/sparc64/include/rwlock.h @@ -1,54 +1 @@ /* $NetBSD: rwlock.h,v 1.5 2008/04/28 20:23:37 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _SPARC64_RWLOCK_H_ -#define _SPARC64_RWLOCK_H_ - -#include - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) mb_read() -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) _lock_cas((p), (o), (n)) - -int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _SPARC64_RWLOCK_H_ */ diff --git a/sys/arch/usermode/include/rwlock.h b/sys/arch/usermode/include/rwlock.h index 340a3d1fd77c..765fc4f57f9b 100644 --- a/sys/arch/usermode/include/rwlock.h +++ b/sys/arch/usermode/include/rwlock.h @@ -1,61 +1 @@ /* $NetBSD: rwlock.h,v 1.3 2008/04/28 20:23:39 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe and Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ARCH_USERMODE_INCLUDE_RWLOCK_H_ -#define _ARCH_USERMODE_INCLUDE_RWLOCK_H_ - -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 - -/* - * RW_RECEIVE: no memory barrier required, as 'ret' implies a load fence. - */ -#define RW_RECEIVE(rw) /* nothing */ - -/* - * RW_GIVE: no memory barrier required, as _lock_cas() will take care of it. - */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) \ - (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -unsigned long _atomic_cas_ulong(volatile unsigned long *, - unsigned long, unsigned long); - -#endif /* __RWLOCK_PRIVATE */ - -#endif /* _ARCH_USERMODE_INCLUDE_RWLOCK_H_ */ diff --git a/sys/arch/vax/include/rwlock.h b/sys/arch/vax/include/rwlock.h index 67b296b88fd1..9cae85fb23ec 100644 --- a/sys/arch/vax/include/rwlock.h +++ b/sys/arch/vax/include/rwlock.h @@ -32,22 +32,6 @@ #ifndef _VAX_RWLOCK_H_ #define _VAX_RWLOCK_H_ -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#include - #define __HAVE_RW_STUBS 1 -#define __HAVE_SIMPLE_RW_LOCKS 1 - -#define RW_RECEIVE(rw) /* nothing */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) (atomic_cas_ulong((p), (o), (n)) == (o)) - -#endif /* __RWLOCK_PRIVATE */ #endif /* _VAX_RWLOCK_H_ */ diff --git a/sys/arch/x86/include/rwlock.h b/sys/arch/x86/include/rwlock.h index 7f0c60cff6b7..a9323bb78833 100644 --- a/sys/arch/x86/include/rwlock.h +++ b/sys/arch/x86/include/rwlock.h @@ -32,31 +32,6 @@ #ifndef _X86_RWLOCK_H_ #define _X86_RWLOCK_H_ -struct krwlock { - volatile uintptr_t rw_owner; -}; - -#ifdef __RWLOCK_PRIVATE - -#define __HAVE_SIMPLE_RW_LOCKS 1 #define __HAVE_RW_STUBS 1 -/* - * RW_RECEIVE: no memory barrier required, as 'ret' implies a load fence. - */ -#define RW_RECEIVE(rw) /* nothing */ - -/* - * RW_GIVE: no memory barrier required, as _lock_cas() will take care of it. - */ -#define RW_GIVE(rw) /* nothing */ - -#define RW_CAS(p, o, n) \ - (_atomic_cas_ulong((volatile unsigned long *)(p), (o), (n)) == (o)) - -unsigned long _atomic_cas_ulong(volatile unsigned long *, - unsigned long, unsigned long); - -#endif /* __RWLOCK_PRIVATE */ - #endif /* _X86_RWLOCK_H_ */ diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index fbdbcdad870d..f6955f2a94a9 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -56,6 +56,8 @@ __KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.54 2019/05/09 05:00:31 ozaki-r Exp #include +#include + /* * LOCKDEBUG */ diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h index e64a1dca26ae..cfb6591a1d45 100644 --- a/sys/sys/rwlock.h +++ b/sys/sys/rwlock.h @@ -93,7 +93,9 @@ void rw_vector_exit(krwlock_t *); int rw_vector_tryenter(krwlock_t *, const krw_t); #endif /* __RWLOCK_PRIVATE */ -#include +struct krwlock { + volatile uintptr_t rw_owner; +}; #ifdef _KERNEL