All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mihai Rusu <dizzy@schlund.ro>
To: linux-kernel@vger.kernel.org
Cc: Robert Love <rml@novell.com>
Subject: [RFC][PATCH 2.4 3/4] inotify 0.22 2.4.x backport - atomic_inc_return
Date: Tue, 10 May 2005 18:14:25 +0300	[thread overview]
Message-ID: <4280CFD1.5010108@schlund.ro> (raw)

[-- 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" \



                 reply	other threads:[~2005-05-10 15:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4280CFD1.5010108@schlund.ro \
    --to=dizzy@schlund.ro \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rml@novell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.