svn commit: r248662 - projects/counters/sys/powerpc/include
Konstantin Belousov
kib at FreeBSD.org
Sat Mar 23 20:43:28 UTC 2013
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__ */
More information about the svn-src-projects
mailing list