* [RFC][PATCH 2.4 3/4] inotify 0.22 2.4.x backport - atomic_inc_return
@ 2005-05-10 15:14 Mihai Rusu
0 siblings, 0 replies; only message in thread
From: Mihai Rusu @ 2005-05-10 15:14 UTC (permalink / raw)
To: linux-kernel; +Cc: Robert Love
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
Hi
Backported atomic_inc_return() from 2.6.11 for x86. Needed by inotify.c.
I have not backported for other architectures as I don't have access to
such devices and I could not test. It should be easy to do that tho.
This also means that this inotify backport currently only works for x86.
--
Mihai Rusu
Linux System Development
Schlund + Partner AG Tel : +40-21-231-2544
Str Mircea Eliade 18 EMail : dizzy@schlund.ro
Sect 1, Bucuresti
71295, Romania
[-- Attachment #2: 03_atomic_inc_return-x86-2.4.30.patch --]
[-- Type: text/x-patch, Size: 1372 bytes --]
atomic.h | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+)
diff -uNr linux-2.4.30.orig/include/asm-i386/atomic.h linux-2.4.30/include/asm-i386/atomic.h
--- linux-2.4.30.orig/include/asm-i386/atomic.h 2001-11-22 21:46:18.000000000 +0200
+++ linux-2.4.30/include/asm-i386/atomic.h 2005-05-09 11:58:56.000000000 +0300
@@ -186,6 +186,40 @@
return c;
}
+/**
+ * atomic_add_return - add and return
+ * @v: pointer of type atomic_t
+ * @i: integer value to add
+ *
+ * Atomically adds @i to @v and returns @i + @v
+ */
+static __inline__ int atomic_add_return(int i, atomic_t *v)
+{
+ int __i;
+#ifdef CONFIG_M386
+ if(unlikely(boot_cpu_data.x86==3))
+ goto no_xadd;
+#endif
+ /* Modern 486+ processor */
+ __i = i;
+ __asm__ __volatile__(
+ LOCK "xaddl %0, %1;"
+ :"=r"(i)
+ :"m"(v->counter), "0"(i));
+ return i + __i;
+
+#ifdef CONFIG_M386
+no_xadd: /* Legacy 386 processor */
+ local_irq_disable();
+ __i = atomic_read(v);
+ atomic_set(v, i + __i);
+ local_irq_enable();
+ return i + __i;
+#endif
+}
+
+#define atomic_inc_return(v) (atomic_add_return(1,v))
+
/* These are x86-specific, used by some header files */
#define atomic_clear_mask(mask, addr) \
__asm__ __volatile__(LOCK "andl %0,%1" \
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-05-10 15:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-05-10 15:14 [RFC][PATCH 2.4 3/4] inotify 0.22 2.4.x backport - atomic_inc_return Mihai Rusu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox