LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* Please correct this code
@ 2011-01-31 16:37 Sri Ram Vemulpali
  2011-01-31 17:58 ` Rajat Sharma
  0 siblings, 1 reply; 4+ messages in thread
From: Sri Ram Vemulpali @ 2011-01-31 16:37 UTC (permalink / raw)
  To: Kernel-newbies, linux-kernel-mail

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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Please correct this code
  2011-01-31 16:37 Please correct this code Sri Ram Vemulpali
@ 2011-01-31 17:58 ` Rajat Sharma
  2011-01-31 20:22   ` Sri Ram Vemulpali
  0 siblings, 1 reply; 4+ messages in thread
From: Rajat Sharma @ 2011-01-31 17:58 UTC (permalink / raw)
  To: Sri Ram Vemulpali; +Cc: Kernel-newbies, linux-kernel-mail

> 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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Please correct this code
  2011-01-31 17:58 ` Rajat Sharma
@ 2011-01-31 20:22   ` Sri Ram Vemulpali
  0 siblings, 0 replies; 4+ messages in thread
From: Sri Ram Vemulpali @ 2011-01-31 20:22 UTC (permalink / raw)
  To: Rajat Sharma; +Cc: Kernel-newbies, linux-kernel-mail

thanks for all explanation, it really helped to refine my code

Sri

On Mon, Jan 31, 2011 at 12:58 PM, Rajat Sharma <fs.rajat@gmail.com> wrote:
>> 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
>>
>



-- 
Regards,
Sri.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Please correct this code
@ 2011-01-31 16:23 Sri Ram Vemulpali
  0 siblings, 0 replies; 4+ messages in thread
From: Sri Ram Vemulpali @ 2011-01-31 16:23 UTC (permalink / raw)
  To: Kernel-newbies, linux-kernel-mail

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.
-- 
Regards,
Sri.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-01-31 20:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-31 16:37 Please correct this code Sri Ram Vemulpali
2011-01-31 17:58 ` Rajat Sharma
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

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).