mirror of
https://git.FreeBSD.org/ports.git
synced 2024-11-28 01:06:17 +00:00
Port the atomic_fetchadd_int function for use on 5.X.
Reported by: pointyhat via pav
This commit is contained in:
parent
bb2a641b04
commit
864ba2de5d
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=208305
@ -1,6 +1,6 @@
|
||||
--- src/pulsecore/atomic.h.orig 2008-01-23 19:44:20.000000000 -0500
|
||||
+++ src/pulsecore/atomic.h 2008-02-25 14:02:59.000000000 -0500
|
||||
@@ -106,6 +106,76 @@ static inline int pa_atomic_ptr_cmpxchg(
|
||||
+++ src/pulsecore/atomic.h 2008-03-02 01:02:20.000000000 -0500
|
||||
@@ -106,6 +106,108 @@ static inline int pa_atomic_ptr_cmpxchg(
|
||||
return __sync_bool_compare_and_swap(&a->value, (long) old_p, (long) new_p);
|
||||
}
|
||||
|
||||
@ -8,8 +8,40 @@
|
||||
+
|
||||
+#include <sys/cdefs.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/param.h>
|
||||
+#include <machine/atomic.h>
|
||||
+
|
||||
+#if __FreeBSD_version < 600000
|
||||
+#if defined(__i386__) || defined(__amd64__)
|
||||
+static inline u_int
|
||||
+atomic_fetchadd_int(volatile u_int *p, u_int v)
|
||||
+{
|
||||
+ __asm __volatile(
|
||||
+ " " MPLOCKED " "
|
||||
+ " xaddl %0, %1 ; "
|
||||
+ "# atomic_fetchadd_int"
|
||||
+ : "+r" (v),
|
||||
+ "=m" (*p)
|
||||
+ : "m" (*p));
|
||||
+
|
||||
+ return (v);
|
||||
+}
|
||||
+#elif defined(__sparc64__)
|
||||
+#define atomic_fetchadd_int atomic_add_int
|
||||
+#elif defined(__ia64__)
|
||||
+static inline uint32_t
|
||||
+atomic_fetchadd_int(volatile uint32_t *p, uint32_t v)
|
||||
+{
|
||||
+ uint32_t value;
|
||||
+
|
||||
+ do {
|
||||
+ value = *p;
|
||||
+ } while (!atomic_cmpset_32(p, value, value + v));
|
||||
+ return (value);
|
||||
+}
|
||||
+#endif
|
||||
+#endif
|
||||
+
|
||||
+typedef struct pa_atomic {
|
||||
+ volatile unsigned long value;
|
||||
+} pa_atomic_t;
|
||||
|
Loading…
Reference in New Issue
Block a user