> From: Adam Nemet <[email protected]>
> To: Jamie Prescott <[email protected]>
> Cc: [email protected]
> 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