Index: sys/rwlock.h =================================================================== RCS file: /cvs/src/sys/sys/rwlock.h,v retrieving revision 1.17 diff -u -p -r1.17 rwlock.h --- sys/rwlock.h 10 Feb 2015 10:04:27 -0000 1.17 +++ sys/rwlock.h 10 Feb 2015 12:01:10 -0000 @@ -110,10 +110,6 @@ int rw_status(struct rwlock *); */ #define RW_WRITE_OTHER 0x0100UL -#ifndef rw_cas -int rw_cas(volatile unsigned long *, unsigned long, unsigned long); -#endif - /* recursive rwlocks; */ struct rrwlock { struct rwlock rrwl_lock; Index: kern/kern_rwlock.c =================================================================== RCS file: /cvs/src/sys/kern/kern_rwlock.c,v retrieving revision 1.24 diff -u -p -r1.24 kern_rwlock.c --- kern/kern_rwlock.c 10 Feb 2015 10:04:27 -0000 1.24 +++ kern/kern_rwlock.c 10 Feb 2015 12:01:10 -0000 @@ -24,11 +24,23 @@ #include #include -#include - /* XXX - temporary measure until proc0 is properly aligned */ #define RW_PROC(p) (((long)p) & ~RWLOCK_MASK) +#ifdef MULTIPROCESSOR +#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) +#else +static inline int +rw_cas(volatile unsigned long *p, unsigned long o, unsigned long n) +{ + if (*p != o) + return (1); + *p = n; + + return (0); +} +#endif + /* * Magic wand for lock operations. Every operation checks if certain * flags are set and if they aren't, it increments the lock with some @@ -123,18 +135,6 @@ rw_exit_write(struct rwlock *rwl) rw_cas(&rwl->rwl_owner, owner, 0))) rw_exit(rwl); } - -#ifndef rw_cas -int -rw_cas(volatile unsigned long *p, unsigned long o, unsigned long n) -{ - if (*p != o) - return (1); - *p = n; - - return (0); -} -#endif #ifdef DIAGNOSTIC /* Index: arch/alpha/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/alpha/include/lock.h,v retrieving revision 1.7 diff -u -p -r1.7 lock.h --- arch/alpha/include/lock.h 29 Mar 2014 18:09:28 -0000 1.7 +++ arch/alpha/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -61,7 +61,6 @@ do { \ } while (0) #endif /* MULTIPROCESSOR */ -#define rw_cas __cpu_cas static inline int __cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) { Index: arch/amd64/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/amd64/include/lock.h,v retrieving revision 1.9 diff -u -p -r1.9 lock.h --- arch/amd64/include/lock.h 29 Mar 2014 18:09:28 -0000 1.9 +++ arch/amd64/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -48,8 +48,4 @@ #define __lockbarrier() __asm volatile("": : :"memory") #define SPINLOCK_SPIN_HOOK __asm volatile("pause": : :"memory"); -#include - -#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) - #endif /* _MACHINE_LOCK_H_ */ Index: arch/hppa/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/hppa/include/lock.h,v retrieving revision 1.8 diff -u -p -r1.8 lock.h --- arch/hppa/include/lock.h 22 Sep 2014 12:12:23 -0000 1.8 +++ arch/hppa/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -5,8 +5,4 @@ #ifndef _MACHINE_LOCK_H_ #define _MACHINE_LOCK_H_ -#include - -#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) - #endif /* _MACHINE_LOCK_H_ */ Index: arch/i386/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/i386/include/lock.h,v retrieving revision 1.9 diff -u -p -r1.9 lock.h --- arch/i386/include/lock.h 29 Mar 2014 18:09:29 -0000 1.9 +++ arch/i386/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -53,7 +53,6 @@ #ifdef _KERNEL extern int rw_cas_486(volatile unsigned long *, unsigned long, unsigned long); -#define rw_cas rw_cas_486 #endif #endif /* _MACHINE_LOCK_H_ */ Index: arch/m88k/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/m88k/include/lock.h,v retrieving revision 1.10 diff -u -p -r1.10 lock.h --- arch/m88k/include/lock.h 15 Jul 2014 16:28:11 -0000 1.10 +++ arch/m88k/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -74,8 +74,4 @@ __cpu_simple_unlock(__cpu_simple_lock_t *l = __SIMPLELOCK_UNLOCKED; } -#if defined(_KERNEL) && defined(MULTIPROCESSOR) -#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) -#endif - #endif /* _M88K_LOCK_H_ */ Index: arch/mips64/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/mips64/include/lock.h,v retrieving revision 1.6 diff -u -p -r1.6 lock.h --- arch/mips64/include/lock.h 30 Sep 2014 06:51:58 -0000 1.6 +++ arch/mips64/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -7,7 +7,6 @@ #include -#define rw_cas __cpu_cas static __inline int __cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) { Index: arch/powerpc/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/powerpc/include/lock.h,v retrieving revision 1.4 diff -u -p -r1.4 lock.h --- arch/powerpc/include/lock.h 21 May 2013 20:05:30 -0000 1.4 +++ arch/powerpc/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -37,7 +37,6 @@ #ifndef _POWERPC_LOCK_H_ #define _POWERPC_LOCK_H_ -#define rw_cas __cpu_cas static __inline int __cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) { Index: arch/sparc64/include/lock.h =================================================================== RCS file: /cvs/src/sys/arch/sparc64/include/lock.h,v retrieving revision 1.9 diff -u -p -r1.9 lock.h --- arch/sparc64/include/lock.h 30 Jan 2014 00:51:13 -0000 1.9 +++ arch/sparc64/include/lock.h 10 Feb 2015 12:01:10 -0000 @@ -5,8 +5,4 @@ #ifndef _MACHINE_LOCK_H_ #define _MACHINE_LOCK_H_ -#include - -#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) - #endif /* _MACHINE_LOCK_H_ */