| To: | "Mike K." <linux_linux_2003@hotmail.com>, <linux-mips@linux-mips.org> |
|---|---|
| Subject: | Re: __asm__ C code in mips-Linux |
| From: | "Kevin D. Kissell" <kevink@mips.com> |
| Date: | Thu, 3 Apr 2003 14:58:25 +0200 |
| Original-recipient: | rfc822;linux-mips@linux-mips.org |
| References: | <BAY2-F148jSQU0d0uub000985dc@hotmail.com> |
| Sender: | linux-mips-bounce@linux-mips.org |
> 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.
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Relocation overflow problem with MIPS, Madhavi |
|---|---|
| Next by Date: | Re: CVS Update@-mips.org: linux, Maciej W. Rozycki |
| Previous by Thread: | Re: __asm__ C code in mips-Linux, Ralf Baechle |
| Next by Thread: | Relocation overflow problem with MIPS, Madhavi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |