zdtm/atomic: atomic_inc should return the old value

Submitted by Andrei Vagin on April 27, 2016, 12:26 a.m.

Details

Message ID 1461716788-1102-1-git-send-email-avagin@openvz.org
State Accepted
Series "zdtm/atomic: atomic_inc should return the old value"
Commit 06995b538231bc54448bdc1d0ee15c6236e77b83
Headers show

Commit Message

Andrei Vagin April 27, 2016, 12:26 a.m.
From: Andrei Vagin <avagin+ppc@gmail.com>

00:24:30.269:    44: ERR: test.c:208: Test exited on unexpected signal

Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
---
 test/zdtm/lib/arch/ppc64/include/asm/atomic.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
index 9463006..bd14cc0 100644
--- a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
+++ b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
@@ -47,7 +47,7 @@  ATOMIC_OP(sub, subf)
 
 #undef ATOMIC_OP
 
-static __inline__ int atomic_inc(atomic_t *v)
+static __inline__ int atomic_inc_return(atomic_t *v)
 {
 	int t;
 
@@ -65,6 +65,11 @@  static __inline__ int atomic_inc(atomic_t *v)
 	return t;
 }
 
+static __inline__ int atomic_inc(atomic_t *v)
+{
+	return atomic_inc_return(v) - 1;
+}
+
 static __inline__ void atomic_dec(atomic_t *v)
 {
 	int t;

Comments

Pavel Emelianov April 27, 2016, 12:05 p.m.
On 04/27/2016 03:26 AM, Andrey Vagin wrote:
> From: Andrei Vagin <avagin+ppc@gmail.com>
> 
> 00:24:30.269:    44: ERR: test.c:208: Test exited on unexpected signal

And how does s/atomic_inc/atomic_inc_return/g help?

> Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
> ---
>  test/zdtm/lib/arch/ppc64/include/asm/atomic.h | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> index 9463006..bd14cc0 100644
> --- a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> +++ b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> @@ -47,7 +47,7 @@ ATOMIC_OP(sub, subf)
>  
>  #undef ATOMIC_OP
>  
> -static __inline__ int atomic_inc(atomic_t *v)
> +static __inline__ int atomic_inc_return(atomic_t *v)
>  {
>  	int t;
>  
> @@ -65,6 +65,11 @@ static __inline__ int atomic_inc(atomic_t *v)
>  	return t;
>  }
>  
> +static __inline__ int atomic_inc(atomic_t *v)
> +{
> +	return atomic_inc_return(v) - 1;
> +}
> +
>  static __inline__ void atomic_dec(atomic_t *v)
>  {
>  	int t;
>
Andrey Vagin April 28, 2016, 10:52 p.m.
On Wed, Apr 27, 2016 at 03:05:53PM +0300, Pavel Emelyanov wrote:
> On 04/27/2016 03:26 AM, Andrey Vagin wrote:
> > From: Andrei Vagin <avagin+ppc@gmail.com>
> > 
> > 00:24:30.269:    44: ERR: test.c:208: Test exited on unexpected signal
> 
> And how does s/atomic_inc/atomic_inc_return/g help?

It's a correct name for this function. For example, we use this name
here criu/arch/ppc64/include/asm/atomic.h

And you can find the same set of functions here:
test/zdtm/lib/arch/aarch64/include/asm/atomic.h

I think this code is more readable (understandable) than just
return t - 1.

> 
> > Signed-off-by: Andrew Vagin <avagin@virtuozzo.com>
> > ---
> >  test/zdtm/lib/arch/ppc64/include/asm/atomic.h | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> > 
> > diff --git a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> > index 9463006..bd14cc0 100644
> > --- a/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> > +++ b/test/zdtm/lib/arch/ppc64/include/asm/atomic.h
> > @@ -47,7 +47,7 @@ ATOMIC_OP(sub, subf)
> >  
> >  #undef ATOMIC_OP
> >  
> > -static __inline__ int atomic_inc(atomic_t *v)
> > +static __inline__ int atomic_inc_return(atomic_t *v)
> >  {
> >  	int t;
> >  
> > @@ -65,6 +65,11 @@ static __inline__ int atomic_inc(atomic_t *v)
> >  	return t;
> >  }
> >  
> > +static __inline__ int atomic_inc(atomic_t *v)
> > +{
> > +	return atomic_inc_return(v) - 1;
> > +}
> > +
> >  static __inline__ void atomic_dec(atomic_t *v)
> >  {
> >  	int t;
> > 
>
Pavel Emelianov May 4, 2016, 7:26 a.m.
Applied