[CRIU] [PATCH] zdtm/atomic: atomic_inc should return the old value

Andrew Vagin avagin at virtuozzo.com
Thu Apr 28 15:52:50 PDT 2016


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 at 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 at 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;
> > 
> 


More information about the CRIU mailing list