public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Vineet Gupta <Vineet.Gupta1@synopsys.com>
To: ltp@lists.linux.it
Subject: [LTP]  tst_atomic: add atomic_add_return for ARC
Date: Wed, 31 Aug 2016 16:39:48 -0700	[thread overview]
Message-ID: <1472686788-8992-1-git-send-email-vgupta@synopsys.com> (raw)

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
 include/tst_atomic.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/tst_atomic.h b/include/tst_atomic.h
index cfe9b4f4b4df..799d7356b97a 100644
--- a/include/tst_atomic.h
+++ b/include/tst_atomic.h
@@ -101,6 +101,36 @@ static inline int tst_atomic_add_return(int i, int *v)
 
 	return old_val + i;
 }
+
+#elif defined(__arc__)
+
+/*ARCv2 defines the smp barriers */
+#ifdef __ARC700__
+#define smp_mb()
+#else
+#define smp_mb()	asm volatile("dmb 3\n" : : : "memory")
+#endif
+
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned int val;
+
+	smp_mb();
+
+	asm volatile(
+		"1:	llock   %[val], [%[ctr]]	\n"
+		"	add     %[val], %[val], %[i]	\n"
+		"	scond   %[val], [%[ctr]]	\n"
+		"	bnz     1b			\n"
+		: [val]	"=&r"	(val)
+		: [ctr]	"r"	(v),
+		  [i]	"ir"	(i)
+		: "cc", "memory");
+
+	smp_mb();
+
+	return val;
+}
 #else /* HAVE_SYNC_ADD_AND_FETCH == 1 */
 # error Your compiler does not provide __sync_add_and_fetch and LTP\
 	implementation is missing for your architecture.
-- 
2.7.4


             reply	other threads:[~2016-08-31 23:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 23:39 Vineet Gupta [this message]
2016-09-05 10:09 ` [LTP] tst_atomic: add atomic_add_return for ARC Jan Stancek

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=1472686788-8992-1-git-send-email-vgupta@synopsys.com \
    --to=vineet.gupta1@synopsys.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