From 1e82ca830c3ad2fd057b4c4fc5243b0622526473 Mon Sep 17 00:00:00 2001 From: "Bjoern B. Brandenburg" Date: Sat, 6 Nov 2010 16:46:55 -0400 Subject: refactor: remove all architecture-dependent code from include/ Move the architecture-dependent code to the arch/ subtree. --- include/asm.h | 15 ------ include/asm_sparc.h | 92 --------------------------------- include/asm_x86.h | 144 ---------------------------------------------------- 3 files changed, 251 deletions(-) delete mode 100644 include/asm.h delete mode 100644 include/asm_sparc.h delete mode 100644 include/asm_x86.h (limited to 'include') diff --git a/include/asm.h b/include/asm.h deleted file mode 100644 index bc15fae..0000000 --- a/include/asm.h +++ /dev/null @@ -1,15 +0,0 @@ -/* liblitmus platform dependent includes */ - -#ifndef ASM_H -#define ASM_H - -#if defined(__i386__) || defined(__x86_64__) -#include "asm_x86.h" -#endif - - -#ifdef __sparc__ -#include "asm_sparc.h" -#endif - -#endif diff --git a/include/asm_sparc.h b/include/asm_sparc.h deleted file mode 100644 index 96c8049..0000000 --- a/include/asm_sparc.h +++ /dev/null @@ -1,92 +0,0 @@ -/* sparc64 assembly. - * Don't include directly, use asm.h instead. - * - * Most of this code comes straight out of the Linux kernel. - * - * The terms of the GPL v2 apply. - * - */ - -#define membar_safe(type) \ -do { __asm__ __volatile__("ba,pt %%xcc, 1f\n\t" \ - " membar " type "\n" \ - "1:\n" \ - : : : "memory"); \ -} while (0) - -#define mb() \ - membar_safe("#LoadLoad | #LoadStore | #StoreStore | #StoreLoad") - -static inline void barrier(void) -{ - mb(); -} - - -#define cpu_relax() barrier() - -static inline int -cmpxchg(volatile int *m, int old, int new) -{ - __asm__ __volatile__("membar #StoreLoad | #LoadLoad\n" - "cas [%2], %3, %0\n\t" - "membar #StoreLoad | #StoreStore" - : "=&r" (new) - : "0" (new), "r" (m), "r" (old) - : "memory"); - - return new; -} - - -typedef struct { int counter; } atomic_t; - -#define ATOMIC_INIT(i) { (i) } - -/** - * atomic_read - read atomic variable - * @v: pointer of type atomic_t - * - * Atomically reads the value of @v. - */ -#define atomic_read(v) ((v)->counter) - -/** - * atomic_set - set atomic variable - * @v: pointer of type atomic_t - * @i: required value - * - * Atomically sets the value of @v to @i. - */ -#define atomic_set(v,i) (((v)->counter) = (i)) - - -/** - * 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 old; - int ret; - goto first; - do { - cpu_relax(); - first: - old = atomic_read(v); - ret = cmpxchg(&v->counter, old, old + i); - } while (ret != old); - return old + i; -} - -static __inline__ void atomic_add(int i, atomic_t *v) -{ - atomic_add_return(i, v); -} - -#define atomic_inc_return(v) (atomic_add_return(1,v)) - - diff --git a/include/asm_x86.h b/include/asm_x86.h deleted file mode 100644 index ccc6cce..0000000 --- a/include/asm_x86.h +++ /dev/null @@ -1,144 +0,0 @@ -/* Intel ia32 assembly. - * Don't include directly, use asm.h instead. - * - * Most of this code comes straight out of the Linux kernel. - * - * The terms of the GPL v2 apply. - */ - -static inline void barrier(void) -{ - __asm__ __volatile__("mfence": : :"memory"); -} - -static __inline__ void cpu_relax(void) -{ - __asm__ __volatile("pause"); -} - -/* please, use these only if you _really_ know what you're doing - * ... and remember iopl(3) first!! (include sys/io.h) - */ -static inline void cli(void) { - asm volatile("cli": : :"memory"); -} - -static inline void sti(void) { - asm volatile("sti": : :"memory"); -} - -typedef struct { int counter; } atomic_t; - -#ifdef __i386__ - -#define ATOMIC_INIT(i) { (i) } - -/** - * atomic_read - read atomic variable - * @v: pointer of type atomic_t - * - * Atomically reads the value of @v. - */ -#define atomic_read(v) ((v)->counter) - -/** - * atomic_set - set atomic variable - * @v: pointer of type atomic_t - * @i: required value - * - * Atomically sets the value of @v to @i. - */ -#define atomic_set(v,i) (((v)->counter) = (i)) - -static __inline__ void atomic_add(int i, atomic_t *v) -{ - __asm__ __volatile__( - "lock; addl %1,%0" - :"+m" (v->counter) - :"ir" (i)); -} - -/** - * 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; - __i = i; - __asm__ __volatile__( - "lock; xaddl %0, %1" - :"+r" (i), "+m" (v->counter) - : : "memory"); - return i + __i; -} - -#define atomic_inc_return(v) (atomic_add_return(1,v)) - -#elif defined(__x86_64__) - -/* almost the same as i386, but extra care must be taken when - * specifying clobbered registers - */ - -#define ATOMIC_INIT(i) { (i) } - -/** - * atomic_read - read atomic variable - * @v: pointer of type atomic_t - * - * Atomically reads the value of @v. - */ -static inline int atomic_read(const atomic_t *v) -{ - return v->counter; -} - -/** - * atomic_set - set atomic variable - * @v: pointer of type atomic_t - * @i: required value - * - * Atomically sets the value of @v to @i. - */ -static inline void atomic_set(atomic_t *v, int i) -{ - v->counter = i; -} - -/** - * atomic_add - add integer to atomic variable - * @i: integer value to add - * @v: pointer of type atomic_t - * - * Atomically adds @i to @v. - */ -static inline void atomic_add(int i, atomic_t *v) -{ - asm volatile("lock; addl %1,%0" - : "=m" (v->counter) - : "ir" (i), "m" (v->counter)); -} - -/** - * atomic_add_return - add and return - * @i: integer value to add - * @v: pointer of type atomic_t - * - * Atomically adds @i to @v and returns @i + @v - */ -static inline int atomic_add_return(int i, atomic_t *v) -{ - int __i = i; - asm volatile("lock; xaddl %0, %1" - : "+r" (i), "+m" (v->counter) - : : "memory"); - return i + __i; -} - -#define atomic_inc_return(v) (atomic_add_return(1, v)) - -#endif -- cgit v1.2.2