LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Rajat Sharma <fs.rajat@gmail.com>
To: Sri Ram Vemulpali <sri.ram.gmu06@gmail.com>
Cc: Kernel-newbies <kernelnewbies@nl.linux.org>,
	linux-kernel-mail <linux-kernel@vger.kernel.org>
Subject: Re: Please correct this code
Date: Mon, 31 Jan 2011 23:28:52 +0530	[thread overview]
Message-ID: <AANLkTik76t-BUv0SUMOCBaoiGhH0PKq7cQwM8Q1Lmkei@mail.gmail.com> (raw)
In-Reply-To: <AANLkTinR=GN+rNqAUcFrnUXea0aWmew-wde0oP22uPcj@mail.gmail.com>

> Is is not that Code A is wrong, for not mentioning cobbler list
> 'memory' to indicate memory contents are getting updated.
> Please rectify me, if I am wrong.

>From Code B, it looks like instruction to compiler for not using extra
memory location other than ones specified for input param and output
param. Is it some sort of memory synchronization code?

> Also, what does '+m' constraint mean, if I use in inline assembly.

It means the memory location for param is both Readable and Writable

Rajat

On Mon, Jan 31, 2011 at 10:07 PM, Sri Ram Vemulpali
<sri.ram.gmu06@gmail.com> wrote:
> Hi,
>
> I have following snippet of code.
>
> Code A
>
> __asm__ __volatile__(
>                     "   lock       ;\n"
>                     "   addl %1,%0 ;\n"
>                     : "=m"  (my_var)
>                     : "ir"  (my_int), "m" (my_var)
>                     :                                 /* no clobber-list */
>                     );
>
> Code B
>
>  __asm__ __volatile__(  "decl %0; sete %1"
>                     : "=m" (my_var), "=q" (cond)
>                     : "m" (my_var)
>                     : "memory"
>                     );
>
> In Code A memory contents are getting updated. And in Code B memory
> contents and 'cond' var are getting updated.
> In Code B in cobbler column 'memory' is used to indicate that this
> code modifies memory contents. But where as in Code A it was not
> mentioned
>
> Is is not that Code A is wrong, for not mentioning cobbler list
> 'memory' to indicate memory contents are getting updated.
> Please rectify me, if I am wrong.
>
> Also, what does '+m' constraint mean, if I use in inline assembly.
> --
> Regards,
> Sri.
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

  reply	other threads:[~2011-01-31 17:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31 16:37 Sri Ram Vemulpali
2011-01-31 17:58 ` Rajat Sharma [this message]
2011-01-31 20:22   ` Sri Ram Vemulpali
  -- strict thread matches above, loose matches on Subject: below --
2011-01-31 16:23 Sri Ram Vemulpali

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=AANLkTik76t-BUv0SUMOCBaoiGhH0PKq7cQwM8Q1Lmkei@mail.gmail.com \
    --to=fs.rajat@gmail.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sri.ram.gmu06@gmail.com \
    --subject='Re: Please correct this code' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).