[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] [patch] errno corruption
At Thu, 18 Mar 2004 15:32:25 +0900,
I wrote:
[...]
> ok, here is my version of _sycall2
>
> #define SYSCALL_CLOBBERS "r3", "r4", "r11", "r12", "r17"
>
> #define _syscall2(type, name, type1, arg1, type2, arg2) \
> type name (type1 arg1, type2 arg2) \
> { \
> register long __r5 __asm__ ("r5") = arg1; \
> register long __r6 __asm__ ("r6") = arg2; \
> long __ret; \
> __asm__ __volatile__ ("bralid r17, 0x8 \n\t" \
> "addik r12, r0, %1 \n\t" \
> "addk %0, r3, r0 \n\t" \
> : "=r" (__ret) \
> : "i" (__NR_##name), \
> "r" (__r5), \
> "r" (__r6) \
> : SYSCALL_CLOBBERS); \
> __syscall_return (type, __ret); \
> }
>
> the difference from John's are:
I should have explain why.
> - keep using C declarations for syscall arguments.
if we do
__asm__ __volatile__ ("addk SYSCALL_ARG0, %2, r0 \n\t" \
"addk SYSCALL_ARG1, %3, r0 \n\t" \
we add two more inst., which should be optimized out by the compiler.
> - keey using __syscall_return
because we are now using auto variable for __ret, __syscall_return
work as we expect.
> - no mention of SYSCALL_ARG# in clobbers. they are listed in input operand
from gcc info:
> You may not write a clobber description in a way that overlaps
> with an input or output operand.
> - all volatile registers, except r5-r10, are in clobbers
because we are implementing a syscall as a function call, the compiler
are free to modify volatile registers implicitly.
if syscall use any of r5-r10, it should list it in input operand.
> - use type# and arg# instead of a b c.
I just thought it's more readable.
regards,
--
yashi
___________________________
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/