[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] [patch] errno corruption
Hi Yashi,
Yasushi SHOJI wrote:
>>I expect it might be optimisation related - although I'm not sure why
>>you and I would have different optimisation settings in the uClibc build...
>
> ugaaaa, that's right. I have been using -Os instead of -O2!!!
>
> -CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -O2 \
> +CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
>
> sorry about that! I've totally forgot about it!
Heh happens all the time to me. I've recently set up some structures
here, where I maintain a pure CVS checkout (updated everynight with a
cron job). Then, I have various working distros to test etc. Helps me
keep track of what "everyone else" is seeing, vs whatever hacked local
copy I'm using.
>>Anyway, the way forward: I think we need to digest Dave's earlier email
>>and do it properly - remove these assumptions that are causing the
>>problem. Basically that means rolling the syscall_return macro into the
>>syscallN declarations, with inline assembly done properly.
>
>
> basically my second patch + macro move, right?
>
> or do you want to implement in asm, so that we can optimise the way we
> want?
I think it should probably be done like in David's m68knommu example.
Declare the variable __res, then inline asm to make the syscall, being
explicit about the register allocations. Here's a quick hack:
#define _syscall2(type, name, atype, a, btype, b) \
type name(atype a, btype b) \
{ \
long __res; \
__asm__ __volatile__ ("addk SYSCALL_ARG0, %2, r0 \n\t" \
"addk SYSCALL_ARG1, %3, r0 \n\t" \
"bralid r17, 0x08 \n\t" \
"addik SYSCALL_NUM, r0, %1 \n\t" \
"addk %0, SYSCALL_RET, r0 \n\t" \
:"=r" (__res) \
: "i" (__NR_##name), \
"r" ((long)a), \
"r" ((long)b) \
: "cc", "SYSCALL_RET", "SYSCALL_ARG0", "SYSCALL_ARG1", \
"SYSCALL_NUM");\
if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
errno = -__res; \
__res = -1; \
} \
return (type)__res; \
}
Or something like it. Note with this explicit approach we also get to
use the delayslot on the bralid instruction, which is nice. Also the
syscall params should be mapped into exactly the same registers as for
the function call that's making it, so it should produce some pretty
streamlined assembly.
> if you can tell me how you want, i can generate a patch. ;)
Great, well see if you can get my example above going, then map it into
the syscall0 -> syscall5 macros
Thanks,
John
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/