Date: Mon, 13 Jan 2014 22:21:29 +0000 (UTC) From: Andreas Tobler <andreast@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r260610 - head/sys/powerpc/include Message-ID: <201401132221.s0DMLTMB019223@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andreast Date: Mon Jan 13 22:21:29 2014 New Revision: 260610 URL: http://svnweb.freebsd.org/changeset/base/260610 Log: Described in the man page but not implemented. Here it comes, atomic_swap_32/64. The latter only for powerpc64. MFC after: 1 month Modified: head/sys/powerpc/include/atomic.h Modified: head/sys/powerpc/include/atomic.h ============================================================================== --- head/sys/powerpc/include/atomic.h Mon Jan 13 22:15:57 2014 (r260609) +++ head/sys/powerpc/include/atomic.h Mon Jan 13 22:21:29 2014 (r260610) @@ -684,10 +684,47 @@ atomic_fetchadd_long(volatile u_long *p, return (value); } +static __inline u_int +atomic_swap_32(volatile u_int *p, u_int v) +{ + u_int prev; + + __asm __volatile( + "1: lwarx %0,0,%2\n" + " stwcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_int *)p) + : "r" (p), "r" (v) + : "cc", "memory"); + + return (prev); +} + +#ifdef __powerpc64__ +static __inline u_long +atomic_swap_64(volatile u_long *p, u_long v) +{ + u_long prev; + + __asm __volatile( + "1: ldarx %0,0,%2\n" + " stdcx. %3,0,%2\n" + " bne- 1b\n" + : "=&r" (prev), "+m" (*(volatile u_long *)p) + : "r" (p), "r" (v) + : "cc", "memory"); + + return (prev); +} +#endif + #define atomic_fetchadd_32 atomic_fetchadd_int +#define atomic_swap_int atomic_swap_32 #ifdef __powerpc64__ #define atomic_fetchadd_64 atomic_fetchadd_long +#define atomic_swap_long atomic_swap_64 +#define atomic_swap_ptr atomic_swap_64 #endif #undef __ATOMIC_REL
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201401132221.s0DMLTMB019223>