Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Jun Sun <jsun@mvista.com>
To: linux-mips@linux-mips.org
Cc: jsun@mvista.com
Subject: [PATCH 2.6] missing _raw_write_trylock
Date: Tue, 16 Mar 2004 07:09:11 -0800	[thread overview]
Message-ID: <20040316070911.B29232@mvista.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 102 bytes --]

Please help me reviewing the code, because inline assembly bug is
always tricky and miserable.  

Jun

[-- Attachment #2: junk --]
[-- Type: text/plain, Size: 752 bytes --]

diff -Nru linux/include/asm-mips/spinlock.h.orig linux/include/asm-mips/spinlock.h
--- linux/include/asm-mips/spinlock.h.orig	2004-01-05 10:48:38.000000000 -0800
+++ linux/include/asm-mips/spinlock.h	2004-03-15 18:50:30.000000000 -0800
@@ -167,4 +167,28 @@
 	: "memory");
 }
 
+static inline int _raw_write_trylock(rwlock_t *rw)
+{
+	unsigned int tmp;
+	int ret;
+
+	__asm__ __volatile__(
+	".set\tnoreorder\t\t\t# _raw_write_trylock\n"
+	"li\t%2, 0\n\t"
+	"1:\tll\t%1, %3\n\t"
+	"bnez\t%1, 2f\n\t"
+	"lui\t%1, 0x8000\n\t"
+	"sc\t%1, %0\n\t"
+	"beqz\t%1, 1b\n\t"
+	"sync\n\t"
+	"li\t%2, 1\n\t"
+	".set\treorder\n"
+	"2:"
+	: "=m" (rw->lock), "=&r" (tmp), "=&r" (ret)
+	: "m" (rw->lock)
+	: "memory");
+
+	return ret;
+}
+
 #endif /* _ASM_SPINLOCK_H */

             reply	other threads:[~2004-03-16 15:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-16 15:09 Jun Sun [this message]
2004-03-16 15:11 ` [PATCH 2.6] missing _raw_write_trylock Steven J. Hill
2004-03-16 17:50   ` Jun Sun
2004-03-16 19:08     ` Christoph Hellwig
2004-03-16 19:14       ` Christopher G. Stach II

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=20040316070911.B29232@mvista.com \
    --to=jsun@mvista.com \
    --cc=linux-mips@linux-mips.org \
    /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