[PATCH 4/4] x86: Final unification of local_{32|64}.h

Previous thread: [PATCH 2/9] readahead: clean up and simplify the code for filemap page fault readahead by Fengguang Wu on Sunday, December 16, 2007 - 4:59 am. (1 message)

Next thread: Issue with 2.6.23 and drbd 8.0.7 by Laurent CARON on Sunday, December 16, 2007 - 4:58 am. (1 message)
From: Harvey Harrison
Date: Sunday, December 16, 2007 - 5:04 am

No differences except for the defintion of local_add_return on
X86_64. The X86_32 version is just fine as it is protected with
ifdef CONFIG_M386 so use it directly.

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 include/asm-x86/local.h    |  149 ++++++++++++++++++++++++++++++++++++++++++-
 include/asm-x86/local_32.h |  150 --------------------------------------------
 include/asm-x86/local_64.h |  134 ---------------------------------------
 3 files changed, 145 insertions(+), 288 deletions(-)

diff --git a/include/asm-x86/local.h b/include/asm-x86/local.h
index 8839c36..3939859 100644
--- a/include/asm-x86/local.h
+++ b/include/asm-x86/local.h
@@ -14,6 +14,7 @@ typedef struct
 
 #define local_read(l)	atomic_long_read(&(l)->a)
 #define local_set(l,i)	atomic_long_set(&(l)->a, (i))
+
 /*
  * X86_32 uses longs
  * X86_64 uses quads
@@ -32,11 +33,151 @@ typedef struct
 # define ASM_XADD xaddq
 #endif
 
-#ifdef CONFIG_X86_32
-# include "local_32.h"
-#else
-# include "local_64.h"
+static inline void local_inc(local_t *l)
+{
+	__asm__ __volatile__(
+		"ASM_INC %0"
+		:"+m" (l->a.counter));
+}
+
+static inline void local_dec(local_t *l)
+{
+	__asm__ __volatile__(
+		"ASM_DEC %0"
+		:"+m" (l->a.counter));
+}
+
+static inline void local_add(long i, local_t *l)
+{
+	__asm__ __volatile__(
+		"ASM_ADD %1,%0"
+		:"+m" (l->a.counter)
+		:"ir" (i));
+}
+
+static inline void local_sub(long i, local_t *l)
+{
+	__asm__ __volatile__(
+		"ASM_SUB %1,%0"
+		:"+m" (l->a.counter)
+		:"ir" (i));
+}
+
+/**
+ * local_sub_and_test - subtract value from variable and test result
+ * @i: integer value to subtract
+ * @l: pointer to type local_t
+ *
+ * Atomically subtracts @i from @l and returns
+ * true if the result is zero, or false for all
+ * other cases.
+ */
+static inline int local_sub_and_test(long i, local_t *l)
+{
+	unsigned char c;
+
+	__asm__ __volatile__(
+		"ASM_SUB %2,%0; sete %1"
+		:"+m" (l->a.counter), "=qm" (c)
+		:"ir" (i) : ...
From: Ingo Molnar
Date: Sunday, December 16, 2007 - 8:31 am

thanks, i've applied your 4 patches to x86.git.

btw., now that we have a single unified file, it might make sense to fix 
these checkpatch complaints:

  total: 10 errors, 1 warnings, 257 lines checked

in case you are interested ;-)

	Ingo
--

Previous thread: [PATCH 2/9] readahead: clean up and simplify the code for filemap page fault readahead by Fengguang Wu on Sunday, December 16, 2007 - 4:59 am. (1 message)

Next thread: Issue with 2.6.23 and drbd 8.0.7 by Laurent CARON on Sunday, December 16, 2007 - 4:58 am. (1 message)