Separate atomic_t declaration from asm/atomic.h into asm/atomic_def.h
Subsystems (8)
PATCH 1/1 Separate atomic_t declaration from asm/atomic.h into asm/atomic_def.h
From: Huang Ying <[email protected]>
asm/atomic.h contains both declaration and implementation of atomic_t. So there are some implementation related files included in asm/atomic.h. And atomic_t is a typedef. Combination of above makes it impossible to use atomic_t in files included by atomic.h. Such as atomic_t can not be used in linux/kernel.h on i386, because it is included by asm/atomic.h.
It is reasonable to separate declaration from implementation. So a new file atomic_def.h is added for every architecture to accommodate the declaration of atomic_t.
Includes fixes from Andrew Moton.
---
arch/alpha/include/asm/atomic.h | 10 +--------- arch/alpha/include/asm/atomic_def.h | 13 +++++++++++++ arch/arm/include/asm/atomic.h | 3 +-- arch/arm/include/asm/atomic_def.h | 6 ++++++ arch/avr32/include/asm/atomic.h | 2 +- arch/avr32/include/asm/atomic_def.h | 6 ++++++ arch/blackfin/include/asm/atomic.h | 4 +--- arch/blackfin/include/asm/atomic_def.h | 8 ++++++++ arch/h8300/include/asm/atomic.h | 3 ++- arch/h8300/include/asm/atomic_def.h | 6 ++++++ arch/ia64/include/asm/atomic.h | 8 +------- arch/ia64/include/asm/atomic_def.h | 11 +++++++++++ arch/m68knommu/include/asm/atomic.h | 2 +- arch/m68knommu/include/asm/atomic_def.h | 6 ++++++ arch/mips/include/asm/atomic.h | 3 +-- arch/mips/include/asm/atomic_def.h | 6 ++++++ arch/powerpc/include/asm/atomic.h | 2 +- arch/powerpc/include/asm/atomic_def.h | 6 ++++++ arch/s390/include/asm/atomic.h | 4 +--- arch/s390/include/asm/atomic_def.h | 8 ++++++++ arch/sh/include/asm/atomic.h | 2 +- arch/sh/include/asm/atomic_def.h | 8 ++++++++ arch/sparc/include/asm/atomic_32.h | 4 ++-- arch/sparc/include/asm/atomic_64.h | 2 +- arch/sparc/include/asm/atomic_def.h | 8 ++++++++ include/asm-cris/atomic.h | 3 +-- include/asm-cris/atomic_def.h | 6 ++++++ include/asm-frv/atomic.h | 5 +---- include/asm-frv/atomic_def.h | 8 ++++++++ include/asm-m32r/atomic.h | 8 +------- include/asm-m32r/atomic_def.h | 11 +++++++++++ include/asm-m68k/atomic.h | 2 +- include/asm-m68k/atomic_def.h | 6 ++++++ include/asm-mn10300/atomic.h | 11 ++--------- include/asm-mn10300/atomic_def.h | 13 +++++++++++++ include/asm-um/atomic_def.h | 6 ++++++ include/asm-x86/atomic_32.h | 10 +--------- include/asm-x86/atomic_64.h | 10 +--------- include/asm-x86/atomic_def.h | 13 +++++++++++++ include/asm-xtensa/atomic.h | 3 +-- include/asm-xtensa/atomic_def.h | 6 ++++++ 41 files changed, 185 insertions(+), 77 deletions(-)
arch/alpha/include/asm/atomic.h +1 -9
@@ -3,6 +3,7 @@#include <asm/barrier.h> #include <asm/system.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for
@@ -12,15 +13,6 @@* than regular operations. */ - -/* -* Counter is volatile to make sure gcc doesn't try to be clever -* and move things around on us. We need to use _exactly_ the address -* the user gave us, not some alias that contains the same information. -*/ -typedef struct {volatile int counter; }atomic_t ; -typedef struct {volatile long counter; }atomic64_t ; -#define ATOMIC_INIT (i) ( (atomic_t) { (i) } )#define ATOMIC64_INIT (i) ( (atomic64_t) { (i) } )
arch/arm/include/asm/atomic.h +1 -2
@@ -13,8 +13,7 @@#include <linux/compiler.h> #include <asm/system.h> - -typedef struct {volatile int counter; }atomic_t ; +#include <asm/atomic_def.h> #define ATOMIC_INIT (i) { (i) }
arch/avr32/include/asm/atomic.h +1 -1
@@ -15,8 +15,8 @@#define __ASM_AVR32_ATOMIC_H#include <asm/system.h> +#include <asm/atomic_def.h> -typedef struct {volatile int counter; }atomic_t ;#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
arch/blackfin/include/asm/atomic.h +1 -3
@@ -2,6 +2,7 @@#define __ARCH_BLACKFIN_ATOMIC__#include <asm/system.h> /* local_irq_XXX() */ +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for
@@ -13,9 +14,6 @@* Tony Kou ([email protected]) Lineo Inc. 2001 */ -typedef struct { -int counter; -}atomic_t ;#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
arch/h8300/include/asm/atomic.h +2 -1
@@ -1,12 +1,13 @@#ifndef __ARCH_H8300_ATOMIC__#define __ARCH_H8300_ATOMIC__ +#include <asm/atomic_def.h> +/* * Atomic operations that C can't guarantee us. Useful for * resource counting etc.. */ -typedef struct {int counter; }atomic_t ;#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
arch/ia64/include/asm/atomic.h +1 -7
@@ -16,13 +16,7 @@#include <asm/intrinsics.h> #include <asm/system.h> - -/* -* On IA-64, counter must always be volatile to ensure that that the -* memory accesses are ordered. -*/ -typedef struct {volatile __s32 counter; }atomic_t ; -typedef struct {volatile __s64 counter; }atomic64_t ; +#include <asm/atomic_def.h> #define ATOMIC_INIT (i) ((atomic_t) { (i) })#define ATOMIC64_INIT (i) ((atomic64_t) { (i) })
arch/m68knommu/include/asm/atomic.h +1 -1
@@ -2,6 +2,7 @@#define __ARCH_M68KNOMMU_ATOMIC__#include <asm/system.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for
@@ -12,7 +13,6 @@* We do not have SMP m68k systems, so we don't have to deal with that. */ -typedef struct {int counter; }atomic_t ;#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
arch/mips/include/asm/atomic.h +1 -2
@@ -19,8 +19,7 @@#include <asm/cpu-features.h> #include <asm/war.h> #include <asm/system.h> - -typedef struct {volatile int counter; }atomic_t ; +#include <asm/atomic_def.h> #define ATOMIC_INIT (i) { (i) }
arch/powerpc/include/asm/atomic.h +1 -1
@@ -5,7 +5,7 @@* PowerPC atomic operations */ -typedef struct {int counter; }atomic_t ; +#include <asm/atomic_def.h> #ifdef __KERNEL__#include <linux/compiler.h>
arch/s390/include/asm/atomic.h +1 -3
@@ -2,6 +2,7 @@#define __ARCH_S390_ATOMIC__#include <linux/compiler.h> +#include <asm/atomic_def.h> /* * include/asm-s390/atomic.h
@@ -23,9 +24,6 @@* S390 uses 'Compare And Swap' for atomicity in SMP enviroment */ -typedef struct { -int counter; -} __attribute__ ((aligned (4 )))atomic_t ;#define ATOMIC_INIT (i) { (i) }#ifdef __KERNEL__
arch/alpha/include/asm/atomic_def.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _ALPHA_ATOMIC_DEF_H +#define _ALPHA_ATOMIC_DEF_H + + +/* +* Counter is volatile to make sure gcc doesn't try to be clever +* and move things around on us. We need to use _exactly_ the address +* the user gave us, not some alias that contains the same information. +*/ +typedef struct {volatile int counter; }atomic_t ; +typedef struct {volatile long counter; }atomic64_t ; + +#endif
arch/arm/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_ARM_ATOMIC_DEF_H +#define __ASM_ARM_ATOMIC_DEF_H + +typedef struct {volatile int counter; }atomic_t ; + +#endif
arch/avr32/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_AVR32_ATOMIC_DEF_H +#define __ASM_AVR32_ATOMIC_DEF_H + +typedef struct {volatile int counter; }atomic_t ; + +#endif
arch/blackfin/include/asm/atomic_def.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ARCH_BLACKFIN_ATOMIC_DEF__ +#define __ARCH_BLACKFIN_ATOMIC_DEF__ + +typedef struct { +int counter; +}atomic_t ; + +#endif
include/asm-cris/atomic.h +1 -2
@@ -7,14 +7,13 @@#include <asm/system.h> #include <asm/arch/atomic.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for * resource counting etc.. */ -typedef struct {volatile int counter; }atomic_t ; -#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
include/asm-cris/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ASM_CRIS_ATOMIC_DEF__ +#define __ASM_CRIS_ATOMIC_DEF__ + +typedef struct {volatile int counter; }atomic_t ; + +#endif
include/asm-frv/atomic.h +1 -4
@@ -17,6 +17,7 @@#include <linux/types.h> #include <asm/spr-regs.h> #include <asm/system.h> +#include <asm/atomic_def.h> #ifdef CONFIG_SMP #error not SMP safe
@@ -35,10 +36,6 @@#define smp_mb__before_atomic_inc () barrier()#define smp_mb__after_atomic_inc () barrier() -typedef struct { -int counter; -}atomic_t ; -#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)#define atomic_set (v, i) (((v)->counter) = (i))
include/asm-frv/atomic_def.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _ASM_ATOMIC_DEF_H +#define _ASM_ATOMIC_DEF_H + +typedef struct { +int counter; +}atomic_t ; + +#endif
arch/h8300/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ARCH_H8300_ATOMIC_DEF__ +#define __ARCH_H8300_ATOMIC_DEF__ + +typedef struct {int counter; }atomic_t ; + +#endif
arch/ia64/include/asm/atomic_def.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ASM_IA64_ATOMIC_DEF_H +#define _ASM_IA64_ATOMIC_DEF_H + +/* +* On IA-64, counter must always be volatile to ensure that that the +* memory accesses are ordered. +*/ +typedef struct {volatile __s32 counter; }atomic_t ; +typedef struct {volatile __s64 counter; }atomic64_t ; + +#endif
include/asm-m32r/atomic.h +1 -7
@@ -11,19 +11,13 @@#include <asm/assembler.h> #include <asm/system.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for * resource counting etc.. */ -/* -* Make sure gcc doesn't try to be clever and move things around -* on us. We need to use _exactly_ the address the user gave us, -* not some alias that contains the same information. -*/ -typedef struct {volatile int counter; }atomic_t ; -#define ATOMIC_INIT (i) { (i) }/**
include/asm-m32r/atomic_def.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef _ASM_M32R_ATOMIC_DEF_H +#define _ASM_M32R_ATOMIC_DEF_H + +/* +* Make sure gcc doesn't try to be clever and move things around +* on us. We need to use _exactly_ the address the user gave us, +* not some alias that contains the same information. +*/ +typedef struct {volatile int counter; }atomic_t ; + +#endif
include/asm-m68k/atomic.h +1 -1
@@ -3,6 +3,7 @@#include <asm/system.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for
@@ -13,7 +14,6 @@* We do not have SMP m68k systems, so we don't have to deal with that. */ -typedef struct {int counter; }atomic_t ;#define ATOMIC_INIT (i) { (i) }#define atomic_read (v) ((v)->counter)
include/asm-m68k/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ARCH_M68K_ATOMIC_DEF__ +#define __ARCH_M68K_ATOMIC_DEF__ + +typedef struct {int counter; }atomic_t ; + +#endif
arch/m68knommu/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __ARCH_M68KNOMMU_ATOMIC_DEF__ +#define __ARCH_M68KNOMMU_ATOMIC_DEF__ + +typedef struct {int counter; }atomic_t ; + +#endif
arch/mips/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_ATOMIC_DEF_H +#define _ASM_ATOMIC_DEF_H + +typedef struct {volatile int counter; }atomic_t ; + +#endif
include/asm-mn10300/atomic.h +2 -9
@@ -11,6 +11,8 @@#ifndef _ASM_ATOMIC_H#define _ASM_ATOMIC_H +#include <asm/atomic_def.h> +#ifdef CONFIG_SMP #error not SMP safe#endif
@@ -20,15 +22,6 @@* resource counting etc.. */ -/* -* Make sure gcc doesn't try to be clever and move things around -* on us. We need to use _exactly_ the address the user gave us, -* not some alias that contains the same information. -*/ -typedef struct { -int counter; -}atomic_t ; -#define ATOMIC_INIT (i) { (i) }#ifdef __KERNEL__
include/asm-mn10300/atomic_def.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef _ASM_ATOMIC_DEF_H +#define _ASM_ATOMIC_DEF_H + +/* +* Make sure gcc doesn't try to be clever and move things around +* on us. We need to use _exactly_ the address the user gave us, +* not some alias that contains the same information. +*/ +typedef struct { +int counter; +}atomic_t ; + +#endif
arch/powerpc/include/asm/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _ASM_POWERPC_ATOMIC_DEF_H_ +#define _ASM_POWERPC_ATOMIC_DEF_H_ + +typedef struct {int counter; }atomic_t ; + +#endif
arch/s390/include/asm/atomic_def.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef __ARCH_S390_ATOMIC_DEF__ +#define __ARCH_S390_ATOMIC_DEF__ + +typedef struct { +int counter; +} __attribute__ ((aligned (4 )))atomic_t ; + +#endif
include/asm-um/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef __UM_ATOMIC_DEF_H +#define __UM_ATOMIC_DEF_H + +#include "asm/arch/atomic_def.h" + +#endif
include/asm-x86/atomic_32.h +1 -9
@@ -4,21 +4,13 @@#include <linux/compiler.h> #include <asm/processor.h> #include <asm/cmpxchg.h> +#include <asm/atomic_def.h> /* * Atomic operations that C can't guarantee us. Useful for * resource counting etc.. */ -/* -* Make sure gcc doesn't try to be clever and move things around -* on us. We need to use _exactly_ the address the user gave us, -* not some alias that contains the same information. -*/ -typedef struct { -int counter; -}atomic_t ; -#define ATOMIC_INIT (i) { (i) }/**
include/asm-x86/atomic_64.h +1 -9
@@ -3,6 +3,7 @@#include <asm/alternative.h> #include <asm/cmpxchg.h> +#include <asm/atomic_def.h> /* atomic_t should be 32 bit signed type */
@@ -11,15 +12,6 @@* resource counting etc.. */ -/* -* Make sure gcc doesn't try to be clever and move things around -* on us. We need to use _exactly_ the address the user gave us, -* not some alias that contains the same information. -*/ -typedef struct { -int counter; -}atomic_t ; -#define ATOMIC_INIT (i) { (i) }/**
include/asm-x86/atomic_def.h new file +13 -0
@@ -0,0 +1,13 @@ +#ifndef __ARCH_X86_ATOMIC_DEF__ +#define __ARCH_X86_ATOMIC_DEF__ + +/* +* Make sure gcc doesn't try to be clever and move things around +* on us. We need to use _exactly_ the address the user gave us, +* not some alias that contains the same information. +*/ +typedef struct { +int counter; +}atomic_t ; + +#endif
include/asm-xtensa/atomic.h +1 -2
@@ -14,8 +14,7 @@#define _XTENSA_ATOMIC_H#include <linux/stringify.h> - -typedef struct {volatile int counter; }atomic_t ; +#include <asm/atomic_def.h> #ifdef __KERNEL__#include <asm/processor.h>
include/asm-xtensa/atomic_def.h new file +6 -0
@@ -0,0 +1,6 @@ +#ifndef _XTENSA_ATOMIC_DEF_H +#define _XTENSA_ATOMIC_DEF_H + +typedef struct {volatile int counter; }atomic_t ; + +#endif
arch/sparc/include/asm/atomic_32.h +2 -2
@@ -13,10 +13,10 @@#include <linux/types.h> -typedef struct {volatile int counter; }atomic_t ; -#ifdef __KERNEL__ +#include <asm/atomic_def.h> +#define ATOMIC_INIT (i) { (i) }extern int __atomic_add_return (int ,atomic_t *);
arch/sparc/include/asm/atomic_64.h +1 -1
@@ -9,8 +9,8 @@#include <linux/types.h> #include <asm/system.h> +#include <asm/atomic_def.h> -typedef struct {volatile int counter; }atomic_t ;typedef struct {volatile __s64 counter; }atomic64_t ;#define ATOMIC_INIT (i) { (i) }
arch/sparc/include/asm/atomic_def.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _ATOMIC_DEF_H +#define _ATOMIC_DEF_H + +typedef struct { +volatile int counter; +}atomic_t ; + +#endif
arch/sh/include/asm/atomic.h +1 -1
@@ -7,7 +7,7 @@* */ -typedef struct {volatile int counter; }atomic_t ; +#include <asm/atomic_def.h> #define ATOMIC_INIT (i) ( (atomic_t) { (i) } )
arch/sh/include/asm/atomic_def.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _ASM_IA64_ATOMIC_DEF_H +#define _ASM_IA64_ATOMIC_DEF_H + +typedef struct { +volatile int counter; +}atomic_t ; + +#endif
Quoted 12 lines · Huang Ying
From: Huang Ying <[email protected]>
asm/atomic.hcontains both declaration and implementation ofatomic_t. So there are some implementation related files included inasm/atomic.h. Andatomic_tis a typedef. Combination of above makes it impossible to useatomic_tin files included byatomic.h. Such asatomic_tcan not be used inlinux/kernel.hon i386, because it is included byasm/atomic.h.It is reasonable to separate declaration from implementation. So a new file
atomic_def.his added for every architecture to accommodate the declaration ofatomic_t.
Quoted 8 lines
Includes fixes from Andrew Moton.
Signed-off-by Huang Ying <[email protected]>---
include/asm-x86/atomic_32.h | 10 +--------- include/asm-x86/atomic_64.h | 10 +--------- include/asm-x86/atomic_def.h | 13 +++++++++++++
nice cleanup!
One small request: could you please use the standard naming convention please and rename it to atomic_types.h?
That moves it in line with existing data type files: kvm_types.h, mm_types.h, posix_types.h, spinlock_types.h, amd_iommu_types.h, kmap_types.h, etc.
Easiest is to do it via:
sed -i 's/atomic_def.h/atomic_types.h/g' patches/separate-atomic.patch
Thanks,
Ingo
Quoted 11 lines · Huang Ying
From: Huang Ying <[email protected]>
asm/atomic.hcontains both declaration and implementation ofatomic_t. So there are some implementation related files included inasm/atomic.h. Andatomic_tis a typedef. Combination of above makes it impossible to useatomic_tin files included byatomic.h. Such asatomic_tcan not be used inlinux/kernel.hon i386, because it is included byasm/atomic.h.It is reasonable to separate declaration from implementation. So a new file
atomic_def.his added for every architecture to accommodate the declaration ofatomic_t.
And how many of these atomic_def.h are identical?
asm-generic?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi, Geert,
Quoted 9 lines · Geert Uytterhoeven
Quoted 8 lines · Huang Ying
From: Huang Ying <[email protected]>
asm/atomic.hcontains both declaration and implementation ofatomic_t. So there are some implementation related files included inasm/atomic.h. Andatomic_tis a typedef. Combination of above makes it impossible to useatomic_tin files included byatomic.h. Such asatomic_tcan not be used inlinux/kernel.hon i386, because it is included byasm/atomic.h.
Quoted 6 lines
Quoted 3 lines
It is reasonable to separate declaration from implementation. So a new file
atomic_def.his added for every architecture to accommodate the declaration ofatomic_t.And how many of these
atomic_def.hare identical?
asm-generic?
Most of them are identical. But <asm/atomic_def.h> will be a public API, included by not only <asm/atomic.h> but also <linux/xxx.h>. I don't know how to put it in asm-generic.
Best Regards,
Huang Ying