This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Forgetting return values
- From: Adam Nemet <anemet at caviumnetworks dot com>
- To: Jamie Prescott <jpresss at yahoo dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Thu, 28 May 2009 11:10:49 -0700
- Subject: Re: Forgetting return values
- References: <516867.32690.qm@web111606.mail.gq1.yahoo.com>
Jamie Prescott <jpresss@yahoo.com> 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.
Adam