From: "Kevin D. Kissell" <kevink@mips.com>
To: "Mike K." <linux_linux_2003@hotmail.com>, <linux-mips@linux-mips.org>
Subject: Re: __asm__ C code in mips-Linux
Date: Thu, 3 Apr 2003 14:58:25 +0200 [thread overview]
Message-ID: <013101c2f9e0$bc582900$10eca8c0@grendel> (raw)
In-Reply-To: BAY2-F148jSQU0d0uub000985dc@hotmail.com
> extern __inline__ void atomic_add(int i, atomic_t * v)
> {
> unsigned long temp;
>
> __asm__ __volatile__(
> "1: ll %0, %1 # atomic_add\n"
> " addu %0, %2 \n"
> " sc %0, %1 \n"
> " beqz %0, 1b \n"
> : "=&r" (temp), "=m" (v->counter)
> : "Ir" (i), "m" (v->counter));
> }
>
>
> Beginner questions on the above code...
See http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC93
or any of a number of other on-line copies of the gcc documentation.
Gcc has a very powerful and cool means of binding C variables to
assembly-language operands. The syntax can be painful, but you
can do amazing things with it - in this case, an in-line atomic add
for C.
WARNING: multiple messages have this Message-ID (diff)
From: "Kevin D. Kissell" <kevink@mips.com>
To: "Mike K." <linux_linux_2003@hotmail.com>, linux-mips@linux-mips.org
Subject: Re: __asm__ C code in mips-Linux
Date: Thu, 3 Apr 2003 14:58:25 +0200 [thread overview]
Message-ID: <013101c2f9e0$bc582900$10eca8c0@grendel> (raw)
Message-ID: <20030403125825.hZc9Xd9DGvmmedLmGB6qK4ciUDZ4OI5vvaKVMGuglWg@z> (raw)
In-Reply-To: BAY2-F148jSQU0d0uub000985dc@hotmail.com
> extern __inline__ void atomic_add(int i, atomic_t * v)
> {
> unsigned long temp;
>
> __asm__ __volatile__(
> "1: ll %0, %1 # atomic_add\n"
> " addu %0, %2 \n"
> " sc %0, %1 \n"
> " beqz %0, 1b \n"
> : "=&r" (temp), "=m" (v->counter)
> : "Ir" (i), "m" (v->counter));
> }
>
>
> Beginner questions on the above code...
See http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC93
or any of a number of other on-line copies of the gcc documentation.
Gcc has a very powerful and cool means of binding C variables to
assembly-language operands. The syntax can be painful, but you
can do amazing things with it - in this case, an in-line atomic add
for C.
next prev parent reply other threads:[~2003-04-03 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-04-03 1:02 __asm__ C code in mips-Linux Mike K.
2003-04-03 2:09 ` Ralf Baechle
2003-04-03 12:58 ` Kevin D. Kissell [this message]
2003-04-03 12:58 ` Kevin D. Kissell
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='013101c2f9e0$bc582900$10eca8c0@grendel' \
--to=kevink@mips.com \
--cc=linux-mips@linux-mips.org \
--cc=linux_linux_2003@hotmail.com \
/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