Date: Sat, 23 Mar 2013 20:43:28 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r248662 - projects/counters/sys/powerpc/include Message-ID: <201303232043.r2NKhS2x077261@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sat Mar 23 20:43:28 2013 New Revision: 248662 URL: http://svnweb.freebsd.org/changeset/base/248662 Log: Implement counter_u64_inc() on powerpc64 AIM using ll/sc. Modified: projects/counters/sys/powerpc/include/counter.h Modified: projects/counters/sys/powerpc/include/counter.h ============================================================================== --- projects/counters/sys/powerpc/include/counter.h Sat Mar 23 20:43:26 2013 (r248661) +++ projects/counters/sys/powerpc/include/counter.h Sat Mar 23 20:43:28 2013 (r248662) @@ -31,6 +31,34 @@ #include <sys/pcpu.h> +#if defined(AIM) && defined(__powerpc64__) + +static inline void +counter_u64_inc(counter_u64_t c, uint64_t inc) +{ + uint64_t ccpu, old; + + __asm __volatile("\n" + "1:\n\t" + "mfsprg %0, 0\n\t" + "ldarx %1, %0, %2\n\t" + "add %1, %1, %3\n\t" + "stdcx. %1, %0, %2\n\t" + "bne- 1b" + : "=&b" (ccpu), "=&r" (old) + : "r" ((char *)c - (char *)&__pcpu[0]), "r" (inc) + : "cc", "memory"); +} + +static inline void +counter_u64_dec(counter_u64_t c, uint64_t dec) +{ + + counter_u64_inc(c, -dec); +} + +#else /* !AIM || !64bit */ + static inline void counter_u64_inc(counter_u64_t c, uint64_t inc) { @@ -49,4 +77,6 @@ counter_u64_dec(counter_u64_t c, uint64_ critical_exit(); } +#endif /* AIM 64bit */ + #endif /* ! __MACHINE_COUNTER_H__ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201303232043.r2NKhS2x077261>