<asm/atomic.h> adjustments
v4 cover <asm/atomic.h> adjustments
Corneliu ZUZU (7):
1/7: asm-arm/atomic.h: fix arm32|arm64 macros duplication
Changed:
* update README.LinuxPrimitives file
2/7: asm-x86/atomic.h: minor: proper atomic_inc_and_test() placement
Changed: <nothing>
3/7: asm-arm/atomic.h: reorder macros to match x86-side
Changed: <nothing>
4/7: asm/atomic.h: common prototyping (add xen/atomic.h)
Changed:
* update README.LinuxPrimitives file
5/7: xen/atomic.h: fix: make atomic_read() param const
Changed: <nothing>
6/7: asm-arm/atomic.h: atomic_{inc,dec}_return: macros to inline functions
Changed:
* update README.LinuxPrimitives file
7/7: asm/atomic.h: implement missing and add common prototypes
Changed:
* add wrapper over arm-side __atomic_add_unless() instead of removing the leading underscores
xen/arch/arm/README.LinuxPrimitives | 24 +++++ xen/include/asm-arm/arm32/atomic.h | 15 +-- xen/include/asm-arm/arm64/atomic.h | 15 +-- xen/include/asm-arm/atomic.h | 60 +++++++++-- xen/include/asm-x86/atomic.h | 151 +++++++------------------- xen/include/xen/atomic.h | 207 ++++++++++++++++++++++++++++++++++++ 6 files changed, 323 insertions(+), 149 deletions(-) create mode 100644 xen/include/xen/atomic.h
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 1/7 asm-arm/atomic.h: fix arm32|arm64 macros duplication
Move duplicate macros between asm-arm/arm32/atomic.h and asm-arm/arm64/atomic.h to asm-arm/atomic.h. Adjust README.LinuxPrimitives in the process. Also empty line fixes.
---
Changed since v3:
* update README.LinuxPrimitives file
--- xen/arch/arm/README.LinuxPrimitives | 20 ++++++++++++++++++++ xen/include/asm-arm/arm32/atomic.h | 15 ++------------- xen/include/asm-arm/arm64/atomic.h | 15 ++------------- xen/include/asm-arm/atomic.h | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 26 deletions(-)
xen/arch/arm/README.LinuxPrimitives +20 -0
@@ -23,6 +23,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) linux/arch/arm64/include/asm/atomic.h xen/include/asm-arm/arm64/atomic.h +The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), + atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v) + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d875c9b37240)
@@ -91,6 +101,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 030d0178bdbd) linux/arch/arm/include/asm/atomic.h xen/include/asm-arm/arm32/atomic.h +The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), + atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v) + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d98b90ea22b0)
xen/include/asm-arm/arm32/atomic.h +2 -13
@@ -8,6 +8,7 @@* it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ +#ifndef __ARCH_ARM_ARM32_ATOMIC__#define __ARCH_ARM_ARM32_ATOMIC__
@@ -147,20 +148,8 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) return oldval; } -#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) - -#define atomic_inc (v) atomic_add(1, v) -#define atomic_dec (v) atomic_sub(1, v) - -#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) -#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) - -#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0) -#endif /* __ARCH_ARM_ARM32_ATOMIC__ */ +/* * Local variables: * mode: C
xen/include/asm-arm/arm64/atomic.h +2 -13
@@ -19,6 +19,7 @@* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#ifndef __ARCH_ARM_ARM64_ATOMIC#define __ARCH_ARM_ARM64_ATOMIC
@@ -113,8 +114,6 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)return oldval; } -#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) -static inline int __atomic_add_unless (atomic_t *v,int a,int u) {int c, old;
@@ -125,18 +124,8 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u) return c; } -#define atomic_inc (v) atomic_add(1, v) -#define atomic_dec (v) atomic_sub(1, v) - -#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) -#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) - -#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0) -#endif +/* * Local variables: * mode: C
xen/include/asm-arm/atomic.h +14 -0
@@ -138,7 +138,21 @@ static inline void _atomic_set(atomic_t *v, int i)# error "unknown ARM variant"#endif +#define atomic_inc (v) atomic_add(1, v) +#define atomic_dec (v) atomic_sub(1, v) + +#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) +#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) +#define atomic_inc_return (v) (atomic_add_return(1, v)) +#define atomic_dec_return (v) (atomic_sub_return(1, v)) +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) + +#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0) + +#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +#endif /* __ARCH_ARM_ATOMIC__ */ +/* * Local variables: * mode: C
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/7] asm-arm/atomic.h: fix arm32|arm64 macros duplication
Hi Corneliu,
Quoted 3 lines · Corneliu ZUZU
Move duplicate macros between
asm-arm/arm32/atomic.handasm-arm/arm64/atomic.htoasm-arm/atomic.h. Adjust README.LinuxPrimitives in the process. Also empty line fixes.
Why do you add empty lines?
They are not necessary nor coding style requirement nor in Linux headers. Please don't introduce changes without a valid reason.
Quoted 19 lines
Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changed since v3:
* update README.LinuxPrimitives file--- xen/arch/arm/README.LinuxPrimitives | 20 ++++++++++++++++++++ xen/include/asm-arm/arm32/atomic.h | 15 ++------------- xen/include/asm-arm/arm64/atomic.h | 15 ++------------- xen/include/asm-arm/atomic.h | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 26 deletions(-)xen/arch/arm/README.LinuxPrimitives +0
-0@@ -23,6 +23,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) linux/arch/arm64/include/asm/atomic.h xen/include/asm-arm/arm64/atomic.h
xen/arch/arm/README.LinuxPrimitives atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) · line 34
Quoted 10 lines
xen/arch/arm/README.LinuxPrimitives +9
-0+The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), + atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v)
I would drop the second paragraph because they are moved outside of arm/*atomic.h and you turn into inline. So IHMO they are not sync-able anymore.
Quoted 7 lines
xen/arch/arm/README.LinuxPrimitives +1
-0+ --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d875c9b37240)@@ -91,6 +101,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 030d0178bdbd) linux/arch/arm/include/asm/atomic.h xen/include/asm-arm/arm32/atomic.h
xen/arch/arm/README.LinuxPrimitives atomics: last sync @ v3.16-rc6 (last commit: 030d0178bdbd) · line 112
Quoted 10 lines
xen/arch/arm/README.LinuxPrimitives +9
-0+The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), + atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v)
Ditto.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/7] asm-arm/atomic.h: fix arm32|arm64 macros duplication
Quoted 8 lines · Julien Grall
Hi Corneliu,
Quoted 3 lines · Corneliu ZUZU
Move duplicate macros between
asm-arm/arm32/atomic.handasm-arm/arm64/atomic.htoasm-arm/atomic.h. Adjust README.LinuxPrimitives in the process. Also empty line fixes.Why do you add empty lines?
A little picky today, aren't we? :-)
I added empty lines:
- before local variables block
- between header comment and #ifndef guard
because IMO -it looks better- and is consistent with the format of -most of- the rest of the files (thus I assumed that's the preferred format and that deviations from that are honest mistakes :-)).
Quoted 1 line
They are not necessary nor coding style requirement nor in Linux headers. Please don't introduce changes without a valid reason.
I just peeked in the Linux source tree and I noticed there are also headers there with an empty line between the file-comment and #ifndef. Plus, this is the Xen code-base and I don't see why I'd look in the Linux source tree to determine rules that apply to the Xen source-tree. I didn't expect for a rule like this to -need- putting in CODING_STYLE. Anyway, they'll be dropped in v5 if it really matters.
Quoted 24 lines
Quoted 24 lines
Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changed since v3:
* update README.LinuxPrimitives file--- xen/arch/arm/README.LinuxPrimitives | 20 ++++++++++++++++++++ xen/include/asm-arm/arm32/atomic.h | 15 ++------------- xen/include/asm-arm/arm64/atomic.h | 15 ++------------- xen/include/asm-arm/atomic.h | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 26 deletions(-)xen/arch/arm/README.LinuxPrimitives +0
-0@@ -23,6 +23,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) linux/arch/arm64/include/asm/atomic.h
xen/include/asm-arm/arm64/atomic.h
Quoted 14 lines
xen/arch/arm/README.LinuxPrimitives atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) · line 34
Quoted 11 lines
xen/arch/arm/README.LinuxPrimitives +2
-0+The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(),
atomic_sub_return(),xen/arch/arm/README.LinuxPrimitives +3
-0+ atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to
asm-arm/atomic.h:xen/arch/arm/README.LinuxPrimitives +4
-0+ atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v)I would drop the second paragraph because they are moved outside of
arm/*atomic.hand you turn into inline. So IHMO they are not sync-able anymore.
Ok.
Quoted 24 lines
Quoted 17 lines
xen/arch/arm/README.LinuxPrimitives +6
-1+ --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d875c9b37240)@@ -91,6 +101,16 @@ atomics: last sync @ v3.16-rc6 (last commit: 030d0178bdbd) linux/arch/arm/include/asm/atomic.h xen/include/asm-arm/arm32/atomic.h +The following functions were taken from Linux: + atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), + atomic_cmpxchg(), __atomic_add_unless() + +Also, the following macros which were in the meantime moved to
asm-arm/atomic.h:xen/arch/arm/README.LinuxPrimitives atomics: last sync @ v3.16-rc6 (last commit: 8715466b6027) · line 34
Quoted 4 lines
xen/arch/arm/README.LinuxPrimitives +4
-0+ atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), + atomic_inc_and_test(v), atomic_dec_and_test(v), + atomic_inc_return(v), atomic_dec_return(v), + atomic_sub_and_test(i, v), atomic_add_negative(i,v)Ditto.
Quoted 1 line
Regards,
Ack.
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v4 1/7] asm-arm/atomic.h: fix arm32|arm64 macros duplication
Quoted 4 lines · Corneliu ZUZU
Quoted 3 lines · Julien Grall
Hi Corneliu,
On 15/07/16 07:48, Corneliu ZUZU wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Move duplicate macros between
asm-arm/arm32/atomic.handasm-arm/arm64/atomic.h
toasm-arm/atomic.h. Adjust README.LinuxPrimitives in the process. Also empty line fixes.Why do you add empty lines?
A little picky today, aren't we? :-)
Same as usual ;).
[...]
Quoted 7 lines
Quoted 2 lines
They are not necessary nor coding style requirement nor in Linux headers. Please don't introduce changes without a valid reason.
I just peeked in the Linux source tree and I noticed there are also headers there with an empty line between the file-comment and #ifndef. Plus, this is the Xen code-base and I don't see why I'd look in the Linux source tree to determine rules that apply to the Xen source-tree.
Because files taken from Linux respect Linux coding style.
I did the mistake on other files to diverge (such as the SMMU code) and it was a pain to re-sync it later. So I prefer to have a strict rule on it, even for cosmetic changes.
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 1/7] asm-arm/atomic.h: fix arm32|arm64 macros duplication
Quoted 28 lines · Julien Grall
Quoted 4 lines · Corneliu ZUZU
Quoted 3 lines · Julien Grall
Hi Corneliu,
On 15/07/16 07:48, Corneliu ZUZU wrote:
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Move duplicate macros between
asm-arm/arm32/atomic.handasm-arm/arm64/atomic.h
toasm-arm/atomic.h. Adjust README.LinuxPrimitives in the process. Also empty line fixes.Why do you add empty lines?
A little picky today, aren't we? :-)
Same as usual ;).
[...]
Quoted 7 lines
Quoted 2 lines
They are not necessary nor coding style requirement nor in Linux headers. Please don't introduce changes without a valid reason.
I just peeked in the Linux source tree and I noticed there are also headers there with an empty line between the file-comment and #ifndef. Plus, this is the Xen code-base and I don't see why I'd look in the Linux source tree to determine rules that apply to the Xen source-tree.
Quoted 5 lines
Because files taken from Linux respect Linux coding style.
I did the mistake on other files to diverge (such as the SMMU code) and it was a pain to re-sync it later. So I prefer to have a strict rule on it, even for cosmetic changes.
Regards,
Makes sense and much better than "Please don't introduce changes without a valid reason". ;-)
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 2/7 asm-x86/atomic.h: minor: proper atomic_inc_and_test() placement
In reply to Corneliu ZUZUPlace atomic_inc_and_test() implementation after atomic_inc(). Also empty line fix.
---
Changed since v3: <nothing>
--- xen/include/asm-x86/atomic.h | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-)
xen/include/asm-x86/atomic.h +19 -20
@@ -110,7 +110,6 @@ static inline int _atomic_read(atomic_t v)return v.counter; } -/** * atomic_set - set atomic variable * @v: pointer of type atomic_t
@@ -217,6 +216,25 @@ static inline void atomic_inc(atomic_t *v) }/** +* atomic_inc_and_test - increment and test +* @v: pointer of type atomic_t +* +* Atomically increments @v by 1 +* and returns true if the result is zero, or false for all +* other cases. +*/ +static inline int atomic_inc_and_test (atomic_t *v) +{ +unsigned char c; + + asmvolatile ( +"lock; incl %0; sete %1" + :"=m" (*(volatile int *)&v->counter),"=qm" (c) + :"m" (*(volatile int *)&v->counter) :"memory" ); +return c !=0 ; +} + +/** * atomic_dec - decrement atomic variable * @v: pointer of type atomic_t *
@@ -250,25 +268,6 @@ static inline int atomic_dec_and_test(atomic_t *v) }/** -* atomic_inc_and_test - increment and test -* @v: pointer of type atomic_t -* -* Atomically increments @v by 1 -* and returns true if the result is zero, or false for all -* other cases. -*/ -static inline int atomic_inc_and_test (atomic_t *v) -{ -unsigned char c; - - asmvolatile ( -"lock; incl %0; sete %1" - :"=m" (*(volatile int *)&v->counter),"=qm" (c) - :"m" (*(volatile int *)&v->counter) :"memory" ); -return c !=0 ; -} - -/** * atomic_add_negative - add and test if negative * @v: pointer of type atomic_t * @i: integer value to add
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 3/7 asm-arm/atomic.h: reorder macros to match x86-side
In reply to Corneliu ZUZUReorder macro definitions to match x86-side.
---
Changed since v3: <nothing>
--- xen/include/asm-arm/atomic.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
xen/include/asm-arm/atomic.h +9 -10
@@ -138,16 +138,15 @@ static inline void _atomic_set(atomic_t *v, int i)# error "unknown ARM variant"#endif -#define atomic_inc (v) atomic_add(1, v) -#define atomic_dec (v) atomic_sub(1, v) - -#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) -#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) - -#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0) +#define atomic_inc_return (v) (atomic_add_return(1, v)) +#define atomic_dec_return (v) (atomic_sub_return(1, v)) + +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) +#define atomic_inc (v) atomic_add(1, v) +#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) +#define atomic_dec (v) atomic_sub(1, v) +#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) +#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0)#define atomic_xchg (v, new) (xchg(&((v)->counter), new))
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 3/7] asm-arm/atomic.h: reorder macros to match x86-side
Quoted 4 lines · Corneliu ZUZU
Reorder macro definitions to match x86-side.
Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Regards,
Quoted 37 lines
---
Changed since v3: <nothing>--- xen/include/asm-arm/atomic.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)xen/include/asm-arm/atomic.h +9
-10@@ -138,16 +138,15 @@ static inline void _atomic_set(atomic_t *v, int i)# error "unknown ARM variant"#endif -#define atomic_inc (v) atomic_add(1, v) -#define atomic_dec (v) atomic_sub(1, v) - -#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) -#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) - -#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0) +#define atomic_inc_return (v) (atomic_add_return(1, v)) +#define atomic_dec_return (v) (atomic_sub_return(1, v)) + +#define atomic_sub_and_test (i, v) (atomic_sub_return(i, v) == 0) +#define atomic_inc (v) atomic_add(1, v) +#define atomic_inc_and_test (v) (atomic_add_return(1, v) == 0) +#define atomic_dec (v) atomic_sub(1, v) +#define atomic_dec_and_test (v) (atomic_sub_return(1, v) == 0) +#define atomic_add_negative (i,v) (atomic_add_return(i, v) < 0)#define atomic_xchg (v, new) (xchg(&((v)->counter), new))
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 4/7 asm/atomic.h: common prototyping (add xen/atomic.h)
In reply to Corneliu ZUZUCreate a common-side <xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them. Some arm-side macros had to be turned into inline functions in the process (also updated README.LinuxPrimitives file).
Removed outdated comment ("NB. I've [...]").
---
Changed since v3:
* update README.LinuxPrimitives file
--- xen/arch/arm/README.LinuxPrimitives | 14 +-- xen/include/asm-arm/atomic.h | 45 ++++++---- xen/include/asm-x86/atomic.h | 103 +--------------------- xen/include/xen/atomic.h | 171 ++++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+), 123 deletions(-) create mode 100644 xen/include/xen/atomic.h
xen/arch/arm/README.LinuxPrimitives +8 -6
@@ -27,10 +27,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h: - atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h +and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], atomic_sub_and_test(i, v), atomic_add_negative(i,v) ---------------------------------------------------------------------
@@ -105,10 +106,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h: - atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h +and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], atomic_sub_and_test(i, v), atomic_add_negative(i,v) ---------------------------------------------------------------------
xen/include/asm-arm/atomic.h +30 -15
63 lines not on this page · raw message
xen/include/asm-x86/atomic.h +1 -102
183 lines not on this page · raw message
xen/include/xen/atomic.h new file +171 -0
171 lines not on this page · raw message
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 4/7] asm/atomic.h: common prototyping (add xen/atomic.h)
Quoted 30 lines · Corneliu ZUZU
Create a common-side <
xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them. Some arm-side macros had to be turned into inline functions in the process (also updated README.LinuxPrimitives file).Removed outdated comment ("NB. I've [...]").
Signed-off-by Corneliu ZUZU <[email protected]>Suggested-by Andrew Cooper <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changed since v3:
* update README.LinuxPrimitives file--- xen/arch/arm/README.LinuxPrimitives | 14 +-- xen/include/asm-arm/atomic.h | 45 ++++++---- xen/include/asm-x86/atomic.h | 103 +--------------------- xen/include/xen/atomic.h | 171 ++++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+), 123 deletions(-)create mode 100644
xen/include/xen/atomic.hxen/arch/arm/README.LinuxPrimitives +0
-0@@ -27,10 +27,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless()
xen/arch/arm/README.LinuxPrimitives The following functions were taken from Linux: · line 35
Quoted 10 lines
xen/arch/arm/README.LinuxPrimitives +4
-3-Also, the following macros which were in the meantime moved to asm-arm/atomic.h: - atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h +and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], atomic_sub_and_test(i, v), atomic_add_negative(i,v)
As mentioned in patch #1, those functions are not easily sync-able after this patch. Please drop them from README.LinuxPrimitives.
Quoted 5 lines
xen/arch/arm/README.LinuxPrimitives +0
-0---------------------------------------------------------------------@@ -105,10 +106,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless()
xen/arch/arm/README.LinuxPrimitives The following functions were taken from Linux: · line 114
Quoted 10 lines
xen/arch/arm/README.LinuxPrimitives +4
-3-Also, the following macros which were in the meantime moved to asm-arm/atomic.h: - atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h +and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], atomic_sub_and_test(i, v), atomic_add_negative(i,v)
Ditto.
With that:
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 4/7] asm/atomic.h: common prototyping (add xen/atomic.h)
Quoted 36 lines · Julien Grall
Quoted 33 lines · Corneliu ZUZU
Create a common-side <
xen/atomic.h> to establish, among others, prototypes of atomic functions called from common-code. Done to avoid introducing inconsistencies between arch-side <asm/atomic.h> headers when we make subtle changes to one of them. Some arm-side macros had to be turned into inline functions in the process (also updated README.LinuxPrimitives file).Removed outdated comment ("NB. I've [...]").
Signed-off-by Corneliu ZUZU <[email protected]>Suggested-by Andrew Cooper <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changed since v3:
* update README.LinuxPrimitives file--- xen/arch/arm/README.LinuxPrimitives | 14 +-- xen/include/asm-arm/atomic.h | 45 ++++++---- xen/include/asm-x86/atomic.h | 103 +--------------------- xen/include/xen/atomic.h | 171 ++++++++++++++++++++++++++++++++++++ 4 files changed, 210 insertions(+), 123 deletions(-)create mode 100644
xen/include/xen/atomic.hxen/arch/arm/README.LinuxPrimitives +0
-0@@ -27,10 +27,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless()
Quoted 15 lines
Quoted 10 lines
xen/arch/arm/README.LinuxPrimitives +0
-1-Also, the following macros which were in the meantime moved to
asm-arm/atomic.h:xen/arch/arm/README.LinuxPrimitives +1
-1- atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to
asm-arm/atomic.hxen/arch/arm/README.LinuxPrimitives +3
-1+and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [stillQuoted 2 lines
macro],
atomic_sub_and_test(i, v),atomic_add_negative(i,v)As mentioned in patch #1, those functions are not easily sync-able after this patch. Please drop them from README.LinuxPrimitives.
Ack.
Quoted 23 lines
Quoted 17 lines
---------------------------------------------------------------------
xen/arch/arm/README.LinuxPrimitives +0
-1@@ -105,10 +106,11 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to
asm-arm/atomic.h:xen/arch/arm/README.LinuxPrimitives +1
-1- atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to
asm-arm/atomic.hxen/arch/arm/README.LinuxPrimitives +3
-1+and most of them turned to inline functions: + atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v), atomic_dec_return(v), + atomic_inc_return(v) [still macro], atomic_dec_return(v) [stillQuoted 2 lines
macro],
atomic_sub_and_test(i, v),atomic_add_negative(i,v)Ditto.
Quoted 6 lines
With that:
Acked-by Julien Grall <[email protected]>Regards,
Thanks,
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 5/7 xen/atomic.h: fix: make atomic_read() param const
In reply to Corneliu ZUZUThis wouldn't let me make a param of a function that used atomic_read() const.
---
Changed since v3: <nothing>
--- xen/include/asm-arm/atomic.h | 2 +- xen/include/asm-x86/atomic.h | 2 +- xen/include/xen/atomic.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
xen/include/asm-arm/atomic.h +1 -1
@@ -102,7 +102,7 @@ void __bad_atomic_size(void);* strex/ldrex monitor on some implementations. The reason we can use it for * atomic_set() is the clrex or dummy strex done on every exception return. */ -static inline int atomic_read (atomic_t *v) +static inline int atomic_read (const atomic_t *v) {return *(volatile int *)&v->counter; }
xen/include/asm-x86/atomic.h +1 -1
@@ -80,7 +80,7 @@ void __bad_atomic_size(void); } \ }) -static inline int atomic_read (atomic_t *v) +static inline int atomic_read (const atomic_t *v) {return read_atomic (&v->counter); }
xen/include/xen/atomic.h +1 -1
@@ -32,7 +32,7 @@ typedef struct { int counter; } atomic_t;* * Atomically reads the value of @v. */ -static inline int atomic_read (atomic_t *v); +static inline int atomic_read (const atomic_t *v);/** * _atomic_read - read atomic variable non-atomically
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 5/7] xen/atomic.h: fix: make atomic_read() param const
Quoted 5 lines · Corneliu ZUZU
This wouldn't let me make a param of a function that used
atomic_read()const.Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Andrew Cooper <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>
Regards,
Quoted 48 lines
---
Changed since v3: <nothing>--- xen/include/asm-arm/atomic.h | 2 +- xen/include/asm-x86/atomic.h | 2 +- xen/include/xen/atomic.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)xen/include/asm-arm/atomic.h +1
-1@@ -102,7 +102,7 @@ void __bad_atomic_size(void);* strex/ldrex monitor on some implementations. The reason we can use it for * atomic_set() is the clrex or dummy strex done on every exception return. */ -static inline int atomic_read (atomic_t *v) +static inline int atomic_read (const atomic_t *v) {return *(volatile int *)&v->counter; }xen/include/asm-x86/atomic.h +1
-1@@ -80,7 +80,7 @@ void __bad_atomic_size(void); } \ }) -static inline int atomic_read (atomic_t *v) +static inline int atomic_read (const atomic_t *v) {return read_atomic (&v->counter); }xen/include/xen/atomic.h +1
-1@@ -32,7 +32,7 @@ typedef struct { int counter; } atomic_t;* * Atomically reads the value of @v. */ -static inline int atomic_read (atomic_t *v); +static inline int atomic_read (const atomic_t *v);/** * _atomic_read - read atomic variable non-atomically
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v4 6/7 asm-arm/atomic.h: atomic_{inc, dec}_return: macros to inline functions
In reply to Corneliu ZUZUTurn atomic_inc_return and atomic_dec_return atomic.h macros to inline functions. Adjust README.LinuxPrimitives in the process.
---
Changed since v3:
* update README.LinuxPrimitives file
--- xen/arch/arm/README.LinuxPrimitives | 18 ++++++++++-------- xen/include/asm-arm/atomic.h | 13 ++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-)
xen/arch/arm/README.LinuxPrimitives +10 -8
@@ -27,13 +27,14 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h -and most of them turned to inline functions: - atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], + atomic_inc_return(v), atomic_dec_return(v), atomic_sub_and_test(i, v), atomic_add_negative(i,v) + * Note: all but atomic_xchg() were turned to inline functions + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d875c9b37240)
@@ -106,13 +107,14 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h -and most of them turned to inline functions: - atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], + atomic_inc_return(v), atomic_dec_return(v), atomic_sub_and_test(i, v), atomic_add_negative(i,v) + * Note: all but atomic_xchg() were turned to inline functions + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d98b90ea22b0)
xen/include/asm-arm/atomic.h +10 -3
@@ -130,9 +130,6 @@ static inline void _atomic_set(atomic_t *v, int i)# error "unknown ARM variant"#endif -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -static inline int atomic_sub_and_test (int i,atomic_t *v) {return atomic_sub_return (i, v) ==0 ;
@@ -143,6 +140,11 @@ static inline void atomic_inc(atomic_t *v)atomic_add (1 , v); } +static inline int atomic_inc_return (atomic_t *v) +{ +return atomic_add_return (1 , v); +} +static inline int atomic_inc_and_test (atomic_t *v) {return atomic_add_return (1 , v) ==0 ;
@@ -153,6 +155,11 @@ static inline void atomic_dec(atomic_t *v)atomic_sub (1 , v); } +static inline int atomic_dec_return (atomic_t *v) +{ +return atomic_sub_return (1 , v); +} +static inline int atomic_dec_and_test (atomic_t *v) {return atomic_sub_return (1 , v) ==0 ;
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 6/7] asm-arm/atomic.h: atomic_{inc, dec}_return: macros to inline functions
Quoted 83 lines · Corneliu ZUZU
Turn
atomic_inc_returnandatomic_dec_returnatomic.hmacros to inline functions. Adjust README.LinuxPrimitives in the process.Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Changed since v3:
* update README.LinuxPrimitives file--- xen/arch/arm/README.LinuxPrimitives | 18 ++++++++++-------- xen/include/asm-arm/atomic.h | 13 ++++++++++--- 2 files changed, 20 insertions(+), 11 deletions(-)xen/arch/arm/README.LinuxPrimitives +10
-8@@ -27,13 +27,14 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h -and most of them turned to inline functions: - atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], + atomic_inc_return(v), atomic_dec_return(v), atomic_sub_and_test(i, v), atomic_add_negative(i,v) + * Note: all but atomic_xchg() were turned to inline functions + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d875c9b37240)@@ -106,13 +107,14 @@ The following functions were taken from Linux: atomic_add(), atomic_add_return(), atomic_sub(), atomic_sub_return(), atomic_cmpxchg(), __atomic_add_unless() -Also, the following macros which were in the meantime moved to asm-arm/atomic.h -and most of them turned to inline functions: - atomic_xchg(v, new) [still macro], atomic_inc(v), atomic_dec(v), +Also, the following macros which were in the meantime moved to asm-arm/atomic.h: + atomic_xchg(v, new), atomic_inc(v), atomic_dec(v), atomic_inc_and_test(v), atomic_dec_and_test(v), - atomic_inc_return(v) [still macro], atomic_dec_return(v) [still macro], + atomic_inc_return(v), atomic_dec_return(v), atomic_sub_and_test(i, v), atomic_add_negative(i,v) + * Note: all but atomic_xchg() were turned to inline functions + --------------------------------------------------------------------- mem*: last sync @ v3.16-rc6 (last commit: d98b90ea22b0)xen/include/asm-arm/atomic.h +5
-3@@ -130,9 +130,6 @@ static inline void _atomic_set(atomic_t *v, int i)# error "unknown ARM variant"#endif -#define atomic_inc_return (v) (atomic_add_return(1, v)) -#define atomic_dec_return (v) (atomic_sub_return(1, v)) -static inline int atomic_sub_and_test (int i,atomic_t *v) {return atomic_sub_return (i, v) ==0 ;@@ -143,6 +140,11 @@ static inline void atomic_inc(atomic_t *v)atomic_add (1 , v); } +static inline int atomic_inc_return (atomic_t *v) +{ +return atomic_add_return (1 , v); +} +static inline int atomic_inc_and_test (atomic_t *v) {return atomic_add_return (1 , v) ==0 ;@@ -153,6 +155,11 @@ static inline void atomic_dec(atomic_t *v)atomic_sub (1 , v);
xen/include/asm-arm/atomic.h static inline void atomic_dec(atomic_t *v) · line 165
Quoted 10 lines
xen/include/asm-arm/atomic.h +5
-0} +static inline int atomic_dec_return (atomic_t *v) +{ +return atomic_sub_return (1 , v); +} +static inline int atomic_dec_and_test (atomic_t *v) {return atomic_sub_return (1 , v) ==0 ;
I mistakenly inserted a TAB instead of 4 spaces in README.LinuxPrimitives (under arm32/atomic.h):
+ * Note: all but atomic_xchg() were turned to inline functions
If there won't be a v5 only for this change, please correct that before pushing the commit.
Thanks,
Corneliu.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH v4 7/7 asm/atomic.h: implement missing and add common prototypes
In reply to Corneliu ZUZUARM (<asm-arm/atomic.h>):
* add atomic_add_unless() wrapper over __atomic_add_unless() (for common-code interface, i.e. <xen/atomic.h>)
X86 (<asm-x86/atomic.h>):
* implement missing functions atomic_{sub,inc,dec}_return(), atomic_add_unless()
* implement missing macro atomic_xchg()
COMMON (<xen/atomic.h>):
* add prototypes for the aforementioned newly implemented X86 functions in common <xen/atomic.h>
---
Changed since v3:
* add wrapper over arm-side __atomic_add_unless() instead of removing the leading underscores
--- xen/include/asm-arm/atomic.h | 5 +++++ xen/include/asm-x86/atomic.h | 27 +++++++++++++++++++++++++++ xen/include/xen/atomic.h | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+)
xen/include/asm-arm/atomic.h +5 -0
@@ -170,6 +170,11 @@ static inline int atomic_add_negative(int i, atomic_t *v) return atomic_add_return(i, v) < 0; } +static inline int atomic_add_unless (atomic_t *v,int a,int u) +{ +return __atomic_add_unless (v, a, u); +} +#define atomic_xchg (v, new) (xchg(&((v)->counter), new))#endif /* __ARCH_ARM_ATOMIC__ */
xen/include/asm-x86/atomic.h +27 -0
@@ -126,6 +126,11 @@ static inline void atomic_sub(int i, atomic_t *v) : "ir" (i), "m" (*(volatile int *)&v->counter) ); } +static inline int atomic_sub_return (int i,atomic_t *v) +{ +return arch_fetch_and_add (&v->counter, -i) - i; +} +static inline int atomic_sub_and_test (int i,atomic_t *v) {unsigned char c;
@@ -145,6 +150,11 @@ static inline void atomic_inc(atomic_t *v) : "m" (*(volatile int *)&v->counter) ); } +static inline int atomic_inc_return (atomic_t *v) +{ +return atomic_add_return (1 , v); +} +static inline int atomic_inc_and_test (atomic_t *v) {unsigned char c;
@@ -164,6 +174,11 @@ static inline void atomic_dec(atomic_t *v) : "m" (*(volatile int *)&v->counter) ); } +static inline int atomic_dec_return (atomic_t *v) +{ +return atomic_sub_return (1 , v); +} +static inline int atomic_dec_and_test (atomic_t *v) {unsigned char c;
@@ -186,4 +201,16 @@ static inline int atomic_add_negative(int i, atomic_t *v) return c; } +static inline int atomic_add_unless (atomic_t *v,int a,int u) +{ +int c, old; + + c =atomic_read (v); +while (c != u && (old =atomic_cmpxchg (v, c, c + a)) != c) + c = old; +return c; +} + +#define atomic_xchg (v, new) (xchg(&((v)->counter), new)) +#endif /* __ARCH_X86_ATOMIC__ */
xen/include/xen/atomic.h +36 -0
@@ -111,6 +111,15 @@ static inline int atomic_add_return(int i, atomic_t *v);static inline void atomic_sub (int i,atomic_t *v);/** +* atomic_sub_return - sub integer and return +* @i: integer value to sub +* @v: pointer of type atomic_t +* +* Atomically subtracts @i from @v and returns @v - @i. +*/ +static inline int atomic_sub_return (int i,atomic_t *v); + +/** * atomic_sub_and_test - subtract value from variable and test result * @i: integer value to subtract * @v: pointer of type atomic_t
@@ -130,6 +139,14 @@ static inline int atomic_sub_and_test(int i, atomic_t *v);static inline void atomic_inc (atomic_t *v);/** +* atomic_inc_return - increment atomic variable and return +* @v: pointer of type atomic_t +* +* Atomically increments @v by 1 and returns @v + 1. +*/ +static inline int atomic_inc_return (atomic_t *v); + +/** * atomic_inc_and_test - increment and test * @v: pointer of type atomic_t *
@@ -148,6 +165,14 @@ static inline int atomic_inc_and_test(atomic_t *v);static inline void atomic_dec (atomic_t *v);/** +* atomic_dec_return - decrement atomic variable and return +* @v: pointer of type atomic_t +* +* Atomically decrements @v by 1 and returns @v - 1. +*/ +static inline int atomic_dec_return (atomic_t *v); + +/** * atomic_dec_and_test - decrement and test * @v: pointer of type atomic_t *
@@ -168,4 +193,15 @@ static inline int atomic_dec_and_test(atomic_t *v);*/ static inline int atomic_add_negative (int i,atomic_t *v); +/** +* atomic_add_unless - add to atomic variable unless it has a specified value +* @v: pointer of type atomic_t +* @a: integer value to add +* @u: integer value @v must -not- be for the add to be performed +* +* If @v != @u, adds @a to @v and returns @v + @a. +* Otherwise returns @u (== @v). +*/ +static inline int atomic_add_unless (atomic_t *v,int a,int u); +#endif /* __XEN_ATOMIC_H__ */
Signature · 7 lines
2.5.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v4 7/7] asm/atomic.h: implement missing and add common prototypes
Quoted 8 lines · Corneliu ZUZU
ARM (<
asm-arm/atomic.h>):
* addatomic_add_unless()wrapper over__atomic_add_unless()(for common-code interface, i.e. <xen/atomic.h>)X86 (<
asm-x86/atomic.h>):
* implement missing functions atomic_{sub,inc,dec}_return(),atomic_add_unless()
* implement missing macroatomic_xchg()
Quoted 6 lines
COMMON (<
xen/atomic.h>):
* add prototypes for the aforementioned newly implemented X86 functions in common <xen/atomic.h>Signed-off-by Corneliu ZUZU <[email protected]>Reviewed-by Andrew Cooper <[email protected]>
For ARM bits:
Regards,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel