public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP]  tst_atomic: add atomic_add_return for ARC
@ 2016-08-31 23:39 Vineet Gupta
  2016-09-05 10:09 ` Jan Stancek
  0 siblings, 1 reply; 2+ messages in thread
From: Vineet Gupta @ 2016-08-31 23:39 UTC (permalink / raw)
  To: ltp

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [LTP] tst_atomic: add atomic_add_return for ARC
  2016-08-31 23:39 [LTP] tst_atomic: add atomic_add_return for ARC Vineet Gupta
@ 2016-09-05 10:09 ` Jan Stancek
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Stancek @ 2016-09-05 10:09 UTC (permalink / raw)
  To: ltp




----- Original Message -----
> From: "Vineet Gupta" <Vineet.Gupta1@synopsys.com>
> To: ltp@lists.linux.it
> Cc: "Vineet Gupta" <Vineet.Gupta1@synopsys.com>, linux-snps-arc@lists.infreadead.org
> Sent: Thursday, 1 September, 2016 1:39:48 AM
> Subject: [LTP]  tst_atomic: add atomic_add_return for ARC
> 
> Signed-off-by: Vineet Gupta <vgupta@synopsys.com>

Pushed.

Thanks,
Jan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-09-05 10:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-31 23:39 [LTP] tst_atomic: add atomic_add_return for ARC Vineet Gupta
2016-09-05 10:09 ` Jan Stancek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox