All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yury Norov <ynorov@caviumnetworks.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] arm64: add tst_atomic_add_return
Date: Thu, 26 Jan 2017 02:43:42 +0530	[thread overview]
Message-ID: <1485378822-6059-1-git-send-email-ynorov@caviumnetworks.com> (raw)

The patch fixes build of LTP, at least with gcc 5.3.
The implementation is taken from kernel v4.9.

Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
 include/tst_atomic.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/tst_atomic.h b/include/tst_atomic.h
index 799d735..35a3b34 100644
--- a/include/tst_atomic.h
+++ b/include/tst_atomic.h
@@ -131,6 +131,27 @@ static inline int tst_atomic_add_return(int i, int *v)
 
 	return val;
 }
+
+#elif defined (__aarch64__)
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned long tmp;
+	int result;
+
+	__asm__ __volatile__(
+"       prfm    pstl1strm, %2	\n"
+"1:     ldxr 	%w0, %2		\n"
+"       add	%w0, %w0, %w3	\n"
+"       stlxr	%w1, %w0, %2	\n"
+"       cbnz	%w1, 1b		\n"
+"       dmb ish			\n"
+	: "=&r" (result), "=&r" (tmp), "+Q" (*v)
+	: "Ir" (i)
+	: "memory");
+
+	return result;
+}
+
 #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:[~2017-01-25 21:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-25 21:13 Yury Norov [this message]
2017-01-27 10:02 ` [LTP] [PATCH] arm64: add tst_atomic_add_return Jan Stancek
2017-01-27 12:21   ` Jan Stancek
2017-01-30 11:43     ` Cyril Hrubis
2017-01-30 12:11       ` 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=1485378822-6059-1-git-send-email-ynorov@caviumnetworks.com \
    --to=ynorov@caviumnetworks.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.