public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jan Stancek <jstancek@redhat.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/4] tst_atomic: make tst_atomic_inc take a signed integer
Date: Wed, 13 Apr 2016 10:32:02 -0400 (EDT)	[thread overview]
Message-ID: <1325842962.871291.1460557922959.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <20160413140702.GC11529@rei.lan>



----- Original Message -----
> From: "Cyril Hrubis" <chrubis@suse.cz>
> To: "Jan Stancek" <jstancek@redhat.com>
> Cc: ltp@lists.linux.it
> Sent: Wednesday, 13 April, 2016 4:07:02 PM
> Subject: Re: [LTP] [PATCH 1/4] tst_atomic: make tst_atomic_inc take a signed integer
> 
> Hi!
> > This is a preparation for upcoming patches, which add atomic_add_return(),
> > that takes signed integer.
> 
> What is the problem with unsigned integer?

All atomic code in kernel is int based. I wanted to match that as closely
as possible in our code.

> 
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> >  doc/test-writing-guidelines.txt | 2 +-
> >  include/tst_atomic.h            | 2 +-
> >  lib/newlib_tests/test08.c       | 2 +-
> >  lib/tst_test.c                  | 8 ++++----
> >  4 files changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/doc/test-writing-guidelines.txt
> > b/doc/test-writing-guidelines.txt
> > index d0b14084c90b..c0ef33afd5bb 100644
> > --- a/doc/test-writing-guidelines.txt
> > +++ b/doc/test-writing-guidelines.txt
> > @@ -780,7 +780,7 @@ the user supplied cleanup to the test library.
> >  
> >  static void cleanup(void)
> >  {
> > -	static unsigned int flag;
> > +	static int flag;
> >  
> >  	if (tst_atomic_inc(&flag) != 1)
> >  		pthread_exit(NULL);
> > diff --git a/include/tst_atomic.h b/include/tst_atomic.h
> > index 75c713d38d2a..40b2c581f19d 100644
> > --- a/include/tst_atomic.h
> > +++ b/include/tst_atomic.h
> > @@ -18,7 +18,7 @@
> >  #ifndef TST_ATOMIC_H__
> >  #define TST_ATOMIC_H__
> >  
> > -static inline unsigned int tst_atomic_inc(unsigned int *v)
> > +static inline unsigned int tst_atomic_inc(int *v)
>                     ^
> 		 This should be removed as well, right?

Correct. I missed that.

> 
> >  {
> >  	return __sync_add_and_fetch(v, 1);
> >  }
> > diff --git a/lib/newlib_tests/test08.c b/lib/newlib_tests/test08.c
> > index 8fefc182650d..0a2023119a71 100644
> > --- a/lib/newlib_tests/test08.c
> > +++ b/lib/newlib_tests/test08.c
> > @@ -35,7 +35,7 @@ static void setup(void)
> >  
> >  static void cleanup(void)
> >  {
> > -	static unsigned int flag;
> > +	static int flag;
> >  
> >  	/* Avoid subsequent threads to enter the cleanup */
> >  	if (tst_atomic_inc(&flag) != 1)
> > diff --git a/lib/tst_test.c b/lib/tst_test.c
> > index 37265fe50951..66c0bc67127f 100644
> > --- a/lib/tst_test.c
> > +++ b/lib/tst_test.c
> > @@ -43,10 +43,10 @@ static float duration = -1;
> >  static pid_t main_pid;
> >  
> >  struct results {
> > -	unsigned int passed;
> > -	unsigned int skipped;
> > -	unsigned int failed;
> > -	unsigned int warnings;
> > +	int passed;
> > +	int skipped;
> > +	int failed;
> > +	int warnings;
> >  };
> 
> We print these values with %u in do_exit(), that should be updated as
> well.

This as well.

> 
> >  static struct results *results;
> > --
> > 1.8.3.1
> > 
> > 
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
> 
> --
> Cyril Hrubis
> chrubis@suse.cz
> 

  reply	other threads:[~2016-04-13 14:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-13 13:10 [LTP] [PATCH 1/4] tst_atomic: make tst_atomic_inc take a signed integer Jan Stancek
2016-04-13 13:10 ` [LTP] [PATCH 2/4] m4: add a check for __sync_add_and_fetch Jan Stancek
2016-04-13 14:04   ` Cyril Hrubis
2016-04-13 13:10 ` [LTP] [PATCH 3/4] tst_atomic: add atomic_add_return for x86/64, ppc/64 and s390/x Jan Stancek
2016-04-13 13:59   ` Cyril Hrubis
2016-04-13 14:36     ` Jan Stancek
2016-04-13 15:03       ` Cyril Hrubis
2016-04-13 13:10 ` [LTP] [PATCH 4/4] tst_atomic: add test for tst_atomic_inc Jan Stancek
2016-04-13 14:15   ` Cyril Hrubis
2016-04-13 14:07 ` [LTP] [PATCH 1/4] tst_atomic: make tst_atomic_inc take a signed integer Cyril Hrubis
2016-04-13 14:32   ` Jan Stancek [this message]
2016-04-13 15:33     ` Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325842962.871291.1460557922959.JavaMail.zimbra@redhat.com \
    --to=jstancek@redhat.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox