public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jamie Prescott <jpresss@yahoo.com>
To: Adam Nemet <anemet@caviumnetworks.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Forgetting return values
Date: Thu, 28 May 2009 20:59:00 -0000	[thread overview]
Message-ID: <353851.97620.qm@web111617.mail.gq1.yahoo.com> (raw)
In-Reply-To: <o7tz352j4m.fsf@ropi.home>


> From: Adam Nemet <anemet@caviumnetworks.com>
> To: Jamie Prescott <jpresss@yahoo.com>
> Cc: gcc@gcc.gnu.org
> Sent: Thursday, May 28, 2009 11:10:49 AM
> Subject: Re: Forgetting return values
> 
> Jamie Prescott writes:
> > static inline int set_prop(char const *path, char const *name,
> >                                           void const *data, int size)
> > {
> >         int error;
> >
> >         asm volatile ("int\t11\n\t"
> >                       : "=a0" (error): "a0" (path), "a1" (name), "a2" (data),
> >                         "a3" (size));
> >
> >         return error;
> > }
> >
> > extern int calc(int);
> >
> > int proc(int i)
> > {
> >         int j = calc(i);
> >
> >         return set_prop(0, 0, &j, sizeof(int));
> > }
> ...
> >
> > Why is the memory clobber required, and why GCC does not understand to
> > sync the value to memory when passing the address to a function?
> 
> Because you never inform GCC that you will use the value at
> address *NAME.  Try to use "m"(*name) rather than "a1"(name) in the asm.

That's 'data', not 'name'. But OK, got it. unfortunately, I cannot use "m" since
that value need to go into a specific register.
Any other solution?


- Jamie


      

  reply	other threads:[~2009-05-28 18:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-28 18:55 Jamie Prescott
2009-05-28 19:10 ` Adam Nemet
2009-05-28 20:59   ` Jamie Prescott [this message]
2009-05-28 21:01     ` Adam Nemet
     [not found]     ` <4A1EDC7E.4040209@redhat.com>
2009-05-28 21:05       ` Jamie Prescott

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=353851.97620.qm@web111617.mail.gq1.yahoo.com \
    --to=jpresss@yahoo.com \
    --cc=anemet@caviumnetworks.com \
    --cc=gcc@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).